aboutsummaryrefslogtreecommitdiff
path: root/entities
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-01-04 23:27:36 -0500
committerAlexander Pickering <alexandermpickering@gmail.com>2017-01-04 23:27:36 -0500
commit4879eb1d78520ce0ac9b0bb0ef5244cf65ad7c99 (patch)
treeac47724191a8959c19b2408d4da384d64b6098ec /entities
parent2c4329e2b6e19182a441f79a5c3010011f8ae767 (diff)
downloadartery-4879eb1d78520ce0ac9b0bb0ef5244cf65ad7c99.tar.gz
artery-4879eb1d78520ce0ac9b0bb0ef5244cf65ad7c99.tar.bz2
artery-4879eb1d78520ce0ac9b0bb0ef5244cf65ad7c99.zip
Started refactoring item and inventory system
Diffstat (limited to 'entities')
-rw-r--r--entities/entities/art_chest/cl_init.lua2
-rw-r--r--entities/entities/art_chipmill/cl_init.lua121
-rw-r--r--entities/entities/art_chipmill/init.lua81
-rw-r--r--entities/entities/art_chipmill/shared.lua30
-rw-r--r--entities/entities/art_lootchest/cl_init.lua1
-rw-r--r--entities/entities/art_lootchest/init.lua6
-rw-r--r--entities/entities/npc_shop/cl_init.lua1
-rw-r--r--entities/entities/npc_shop/init.lua41
8 files changed, 19 insertions, 264 deletions
diff --git a/entities/entities/art_chest/cl_init.lua b/entities/entities/art_chest/cl_init.lua
index 1ba18b4..89745c0 100644
--- a/entities/entities/art_chest/cl_init.lua
+++ b/entities/entities/art_chest/cl_init.lua
@@ -1,6 +1,6 @@
include('shared.lua')
--local invfuncs = include("../../../gamemode/shared/inventory_common.lua")
-local invfuncs = ART.invfuncs
+local invfuncs = nrequire("inventory/inventory.lua")
ENT.RenderGroup = RENDERGROUP_BOTH
diff --git a/entities/entities/art_chipmill/cl_init.lua b/entities/entities/art_chipmill/cl_init.lua
deleted file mode 100644
index 6eb1d1f..0000000
--- a/entities/entities/art_chipmill/cl_init.lua
+++ /dev/null
@@ -1,121 +0,0 @@
-
-ART.chips = {}
-ART.RegisterChipType = function(tbl)
- assert(ART.chips[tbl.Name] == nil,"Trying to register a chip twice:"..tbl.Name)
- ART.chips[tbl.Name] = tbl
-end
-include('shared.lua')
-
-ENT.RenderGroup = RENDERGROUP_BOTH
-
-function ENT:Initialize()
-end
-
-function ENT:OnRemove()
-end
-
-function ENT:Think()
-end
-
-local function drawchipsavaliable(panel, chips)
- for k,v in pairs(chips) do
- local chiptbl = ART.chips[k]
- local chippanel = vgui.Create("DPanel",panel)
- chippanel:SetSize(64,80)
- chippanel.chip = chiptbl
- chippanel:Droppable("chiptype")
- local chipitem = vgui.Create( "DImage",chippanel )
- chipitem:SetMaterial( chiptbl:GetImage() )
- chipitem:SetSize(64,64)
- local chipname = vgui.Create("DLabel",chippanel)
- chipname:SetPos( 0, 64 )
- chipname:SetText( k )
- chipname:SetDark(true)
- chipname:SetContentAlignment(5)
- --chipitem:Dock(TOP)
- panel:AddItem(chippanel)
- end
-end
-local workspacesize = {5,5}
-local workspacegridemptys = {}
-local workspacechips = {}
-for k=1,workspacesize[2] do
- workspacechips[k] = {}
-end
-local function drawworkgrid(panel,blocks)
- workspacegridemptys = {}
- local grid = vgui.Create( "DGrid", panel )
- grid:SetPos( 0, 0 )
- grid:SetCols( workspacesize[1] )
- grid:SetColWide( 64 )
- grid:SetRowHeight(64)
-
- for i = 1, workspacesize[1] * workspacesize[2] do
- local griditem = vgui.Create( "DPanel" )
- griditem:SetText( i )
- griditem:SetSize( 64, 64 )
- grid:AddItem( griditem )
- griditem:Receiver( "chiptype", function(receiver,
- tableOfDroppedPanels,
- isDropped,
- menuIndex,
- mouseX,
- mouseY )
- local chiptbl = tableOfDroppedPanels[1].chip
- print("Chiptable was:")
- PrintTable(chiptbl)
- print("Receiver was:",receiver)
- if isDropped then
- --workspacechips[i]
- print("The icon was dropped on me!")
- elseif griditem.image == nil then
- for k,v in pairs(workspacegridemptys) do
- if v.ghostimage == nil then continue end
- v.ghostimage:Remove()
- v.ghostimage = nil
- end
- griditem.ghostimage = vgui.Create( "DImage", griditem )
- griditem.ghostimage:SetMaterial( chiptbl:GetImage() )
- griditem.ghostimage:SetSize(64,64)
- end
- print("Something was dragged and dropped!")
- end, {} )
- table.insert(workspacegridemptys,griditem)
- end
-end
-
-net.Receive("openchipmill",function()
- local width,height = ScrW(),ScrH()
- local chipframe = vgui.Create( "DFrame" )
- chipframe:SetPos( width / 10, height / 10 )
- chipframe:SetSize( width / 1.25, height / 1.25 )
- chipframe:SetTitle( "Chip mill" )
- chipframe:SetDraggable( true )
- chipframe:MakePopup()
-
- local chipsavaliable = {
- ["Clock"] = 1,
- }
- chipsavaliablepanel = vgui.Create( "DPanel", chipframe )
- chipsavaliablepanel:Dock(RIGHT)
- local chipscroll = vgui.Create( "DScrollPanel", chipsavaliablepanel )
- chipscroll:Dock(FILL)
- drawchipsavaliable(chipscroll,chipsavaliable)
-
- chipworkspace = vgui.Create( "DPanel",chipframe )
- chipworkspace:Dock(FILL)
- drawworkgrid(chipworkspace,{})
-
- chiptools = vgui.Create( "DPanel",chipframe )
- chiptools:Dock(LEFT)
-
- millfunctions = vgui.Create( "DPanel",chipframe )
- millfunctions:Dock(BOTTOM)
-
-
-end)
-
-function ENT:Draw()
-
- self:DrawModel()
-end
diff --git a/entities/entities/art_chipmill/init.lua b/entities/entities/art_chipmill/init.lua
deleted file mode 100644
index aa1f0e7..0000000
--- a/entities/entities/art_chipmill/init.lua
+++ /dev/null
@@ -1,81 +0,0 @@
-AddCSLuaFile( "cl_init.lua" )
-AddCSLuaFile( "shared.lua" )
-
-ART.RegisterChipType = function(tbl)
- print("Trying to register chip type!")
-end
-include("shared.lua")
-
-local mdltbl = {
-{"models/props_c17/furnituretable002a.mdl",
-Vector(2,1,-30),
-Angle(0,-90,0)},
-{"models/props_junk/meathook001a.mdl",
-Vector(22,10,2),
-Angle(-1,126,160)},
-{"models/props_interiors/pot01a.mdl",
-Vector(2,-3,-13),
-Angle(0,180,180)},
-{"models/props_junk/metal_paintcan001a.mdl",
-Vector(-4,-2,-16),
-Angle(0,-45,0)},
-{"models/props_c17/furnituretable002a.mdl",
-Vector(2,-3,-30),
-Angle(85,-90,1)},
-{"models/props_c17/tools_wrench01a.mdl",
-Vector(-23,2,-10),
-Angle(-2,-26,0)},
-{"models/props_c17/trappropeller_lever.mdl",
-Vector(21,-2,-10),
-Angle(88,-104,63)},
-{"models/props_junk/garbage_takeoutcarton001a.mdl",
-Vector(23,11,11),
-Angle(-11,39,-179)},
-{"models/props_junk/garbage_milkcarton002a.mdl",
-Vector(17,6,16),
-Angle(71,34,177)},
-{"models/props_junk/garbage_metalcan001a.mdl",
-Vector(12,2,13),
-Angle(-5,-42,-162)},
-{"models/props_junk/flare.mdl",
-Vector(8,0,10),
-Angle(-13,-89,152)},
-}
-
-function ENT:Initialize()
- self:SetModel("models/hunter/blocks/cube2x2x1.mdl")
- self:SetAngles(Angle(90,90,180))
- self:PhysicsInit( SOLID_VPHYSICS )
- self:SetMoveType( MOVETYPE_NONE )
- self:SetSolid( SOLID_VPHYSICS )
- self:SetCollisionGroup( COLLISION_GROUP_INTERACTIVE )
- self:SetUseType(SIMPLE_USE)
-
- local phys = self:GetPhysicsObject()
- --Wait a second so that we have a valid pos, self:GetPos() will return origin without this.
- timer.Simple(1,function()
- self:SetPos(self:GetPos() + Vector(0,0,30))
- self:SetColor( Color( 0, 0, 0, 0 ) )
- self:SetRenderMode( RENDERMODE_TRANSALPHA )
- for k,v in pairs(mdltbl) do
- print("Createing a " .. k)
- local part = ents.Create("prop_dynamic")
- part:SetModel(v[1])
- part:SetPos(self:GetPos() + v[2])
- part:SetAngles(v[3])
- part:Spawn()
- end
- end)
-
-
- phys:EnableMotion(false)
- phys:Sleep()
-end
-
-util.AddNetworkString("openchipmill")
-
-function ENT:Use(ply)
- net.Start("openchipmill")
- net.WriteEntity(self)
- net.Send(ply)
-end
diff --git a/entities/entities/art_chipmill/shared.lua b/entities/entities/art_chipmill/shared.lua
deleted file mode 100644
index 82eef2c..0000000
--- a/entities/entities/art_chipmill/shared.lua
+++ /dev/null
@@ -1,30 +0,0 @@
-ENT.Type = "anim"
-ENT.Base = "base_anim"
-
---[[
- The different kinds of chips
-]]
-
-local clockon = Material("materials/chipicons/clock1.png")
-local clockoff = Material("materials/chipicons/clock2.png")
-local clocktype = {
- ["Name"] = "Clock",
- ["GetImage"] = function(self)
- if self.A == 1 then
- return clockon
- else
- return clockoff
- end
- end,
- ["OnTick"] = function(self)
- self.A = self.A == 1 and 0 or 1
- end,
- ["Inputs"] = {},
- ["Outputs"] = {
- ["A"] = function(self)
- return self.A
- end,
- },
-}
-
-ART.RegisterChipType(clocktype)
diff --git a/entities/entities/art_lootchest/cl_init.lua b/entities/entities/art_lootchest/cl_init.lua
index 4cfd132..5eb6b76 100644
--- a/entities/entities/art_lootchest/cl_init.lua
+++ b/entities/entities/art_lootchest/cl_init.lua
@@ -1,5 +1,4 @@
include('shared.lua')
--local invfuncs = include("../../../gamemode/shared/inventory_common.lua")
-local invfuncs = ART.invfuncs
ENT.RenderGroup = RENDERGROUP_BOTH
diff --git a/entities/entities/art_lootchest/init.lua b/entities/entities/art_lootchest/init.lua
index 516dc98..2ef04a7 100644
--- a/entities/entities/art_lootchest/init.lua
+++ b/entities/entities/art_lootchest/init.lua
@@ -2,12 +2,6 @@ AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include("shared.lua")
-local invfuncs = include("../../../gamemode/shared/inventory_common.lua")
-
---Some things that can be looted
-local lootables = {
-
-}
function CreateRandomLoot(time)
diff --git a/entities/entities/npc_shop/cl_init.lua b/entities/entities/npc_shop/cl_init.lua
index 4cfd132..5eb6b76 100644
--- a/entities/entities/npc_shop/cl_init.lua
+++ b/entities/entities/npc_shop/cl_init.lua
@@ -1,5 +1,4 @@
include('shared.lua')
--local invfuncs = include("../../../gamemode/shared/inventory_common.lua")
-local invfuncs = ART.invfuncs
ENT.RenderGroup = RENDERGROUP_BOTH
diff --git a/entities/entities/npc_shop/init.lua b/entities/entities/npc_shop/init.lua
index 93b5755..a6d49d3 100644
--- a/entities/entities/npc_shop/init.lua
+++ b/entities/entities/npc_shop/init.lua
@@ -2,12 +2,6 @@ AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include("shared.lua")
-local invfuncs = include("../../../gamemode/shared/inventory_common.lua")
-
---Some things that can be looted
-local lootables = {
-
-}
function CreateRandomLoot(time)
@@ -15,32 +9,33 @@ end
function ENT:Initialize()
- self.Openedby = {}
+ self.Openedby = {}
- self:PhysicsInit( SOLID_VPHYSICS )
- self:SetMoveType( MOVETYPE_NONE )
- self:SetUseType(SIMPLE_USE)
+ self:PhysicsInit( SOLID_VPHYSICS )
+ self:SetMoveType( MOVETYPE_NONE )
+ self:SetUseType(SIMPLE_USE)
- self:SetSolid(SOLID_BBOX )
- self:SetCollisionGroup(COLLISION_GROUP_NPC )
+ self:SetSolid(SOLID_BBOX )
+ self:SetCollisionGroup(COLLISION_GROUP_NPC )
- print("Initalizeing shop npc")
- if(self.Model) then self:SetModel(self.Model)
- else print("NPC created without model, this might be a bug!") end
+ print("Initalizeing shop npc")
+ if self.Model then self:SetModel(self.Model)
+ else print("NPC created without model, this might be a bug!") end
- if self.Pos then self:SetPos(self.Pos)
- else print("NPC created without a position, this might be a bug!") end
+ if self.Pos then self:SetPos(self.Pos)
+ else print("NPC created without a position, this might be a bug!") end
- self.talking = false
+ self.talking = false
- if self.Name then self:SetName(self.Name)
- else print("NPC created without a name! They won't be able to open doors!") end
+ if self.Name then self:SetName(self.Name)
+ else print("NPC created without a name! They won't be able to open doors!") end
- if self.OnSpawn then self.OnSpawn(self) end
+ if self.OnSpawn then self.OnSpawn(self) end
- self:SetUseType( SIMPLE_USE )
+ self:SetUseType( SIMPLE_USE )
end
function ENT:Use(ply)
- ART.OpenShop(self.shopitems,ply)
+ --TODO:Fix shop
+ ART.OpenShop(self.shopitems,ply)
end