diff options
| author | Apickx <apickx@cogarr.com> | 2025-02-12 16:41:17 -0600 |
|---|---|---|
| committer | Apickx <apickx@cogarr.com> | 2025-02-12 16:41:17 -0600 |
| commit | 94cc3813c462df5f7bfd875d5a817b0da42006e6 (patch) | |
| tree | de80af0fe1300e822c6b553d15dbf2136f31f1b9 /data/artery/global/art_sawhorse | |
| parent | d22897e044a422e125f46e52c3467473a3656378 (diff) | |
| download | artery_stranded-master.tar.gz artery_stranded-master.tar.bz2 artery_stranded-master.zip | |
Diffstat (limited to 'data/artery/global/art_sawhorse')
| -rw-r--r-- | data/artery/global/art_sawhorse/cl_ent_sawhorse.lua | 118 | ||||
| -rw-r--r-- | data/artery/global/art_sawhorse/sh_ent_sawhorse.lua | 106 | ||||
| -rw-r--r-- | data/artery/global/art_sawhorse/sv_ent_sawhorse.lua | 172 |
3 files changed, 198 insertions, 198 deletions
diff --git a/data/artery/global/art_sawhorse/cl_ent_sawhorse.lua b/data/artery/global/art_sawhorse/cl_ent_sawhorse.lua index 2cbe16a..f80784d 100644 --- a/data/artery/global/art_sawhorse/cl_ent_sawhorse.lua +++ b/data/artery/global/art_sawhorse/cl_ent_sawhorse.lua @@ -1,59 +1,59 @@ ---[[ - Client stuff! -]] -local ENT = nrequire("sh_ent_sawhorse.lua") - -function ENT:Draw() - - self.Entity:DrawModel() - -end - -net.Receive("art_sawhorse_open",function() - local who = net.ReadEntity() - print("Opening sawhorse") - local selectframe = vgui.Create("DFrame") - selectframe:SetSize(ScrW()/2, ScrH()/2) - selectframe:Center() - selectframe:SetTitle("Sawhorse") - - local scroll = vgui.Create( "DScrollPanel",selectframe ) - scroll:Dock(FILL) - - local grid = vgui.Create( "DGrid", scroll ) - grid:SetPos( 10, 30 ) - grid:SetCols( 2 ) - grid:SetColWide( 200 ) - grid:SetRowHeight(100) - grid:Dock(FILL) - - print("s.props is",ENT.props) - PrintTable(ENT.props) - - for k,v in pairs(ENT.props) do - local p = vgui.Create("DPanel") - p:SetSize(200,100) - --p:Dock(FILL) - local but = vgui.Create("DModelPanel",p) - but:SetModel(v.model) - but:SetSize(100,100) - but:Dock(LEFT) - but.DoClick = function(self) - net.Start("art_sawhorse_select") - net.WriteString(k) - net.WriteEntity(who) - net.SendToServer() - print("I want to make a ", k) - end - local label = vgui.Create("DLabel",p) - label:SetSize(100,100) - label:Dock(RIGHT) - label:SetText(string.format("%s\nCost:%d wood",k,v.cost)) - label:SetDark(true) - grid:AddItem(p) - end - - selectframe:MakePopup() -end) - -scripted_ents.Register(ENT,"art_sawhorse") +--[[
+ Client stuff!
+]]
+local ENT = nrequire("sh_ent_sawhorse.lua")
+
+function ENT:Draw()
+
+ self.Entity:DrawModel()
+
+end
+
+net.Receive("art_sawhorse_open",function()
+ local who = net.ReadEntity()
+ print("Opening sawhorse")
+ local selectframe = vgui.Create("DFrame")
+ selectframe:SetSize(ScrW()/2, ScrH()/2)
+ selectframe:Center()
+ selectframe:SetTitle("Sawhorse")
+
+ local scroll = vgui.Create( "DScrollPanel",selectframe )
+ scroll:Dock(FILL)
+
+ local grid = vgui.Create( "DGrid", scroll )
+ grid:SetPos( 10, 30 )
+ grid:SetCols( 2 )
+ grid:SetColWide( 200 )
+ grid:SetRowHeight(100)
+ grid:Dock(FILL)
+
+ print("s.props is",ENT.props)
+ PrintTable(ENT.props)
+
+ for k,v in pairs(ENT.props) do
+ local p = vgui.Create("DPanel")
+ p:SetSize(200,100)
+ --p:Dock(FILL)
+ local but = vgui.Create("DModelPanel",p)
+ but:SetModel(v.model)
+ but:SetSize(100,100)
+ but:Dock(LEFT)
+ but.DoClick = function(self)
+ net.Start("art_sawhorse_select")
+ net.WriteString(k)
+ net.WriteEntity(who)
+ net.SendToServer()
+ print("I want to make a ", k)
+ end
+ local label = vgui.Create("DLabel",p)
+ label:SetSize(100,100)
+ label:Dock(RIGHT)
+ label:SetText(string.format("%s\nCost:%d wood",k,v.cost))
+ label:SetDark(true)
+ grid:AddItem(p)
+ end
+
+ selectframe:MakePopup()
+end)
+
+scripted_ents.Register(ENT,"art_sawhorse")
diff --git a/data/artery/global/art_sawhorse/sh_ent_sawhorse.lua b/data/artery/global/art_sawhorse/sh_ent_sawhorse.lua index bf0e640..49ede91 100644 --- a/data/artery/global/art_sawhorse/sh_ent_sawhorse.lua +++ b/data/artery/global/art_sawhorse/sh_ent_sawhorse.lua @@ -1,53 +1,53 @@ - -local ENT = {} - -ENT.Type = "anim" -ENT.Base = "art_chest" -ENT.PrintName = "art_sawhorse" -ENT.Author = "Apickx" - -ENT.Spawnable = false -ENT.AdminSpawnable = false - -local skil = nrequire("sh_skillcommon.lua") -skil.RegisterSkill({"Crafting","Carpentry"}) - -ENT.props = { - ["A short board"] = { - model = "models/props_debris/wood_board06a.mdl", - cost = 1 - }, - ["A longer board"] = { - model = "models/props_debris/wood_board07a.mdl", - cost = 2, - }, - ["A pallet"] = { - model = "models/props_junk/wood_pallet001a.mdl", - cost = 2 - }, - ["A large flat peice of wood"] = { - model = "models/props_wasteland/wood_fence01a.mdl", - cost = 3 - }, - ["A small flat peice of wood"] = { - model = "models/props_wasteland/wood_fence02a.mdl", - cost = 2 - }, - ["A very strong, boyent fence"] = { - model = "models/props_c17/FurnitureShelf001a.mdl", - cost = 2 - }, - ["A round table"] = { - model = "models/props_c17/FurnitureTable001a.mdl", - cost = 1 - }, - ["A rectangle table"] = { - model = "models/props_c17/FurnitureTable002a.mdl", - cost = 1 - }, - ["A tall pole"] = { - model = "models/props_docks/dock01_pole01a_128.mdl", - cost = 2 - } -} -return ENT +
+local ENT = {}
+
+ENT.Type = "anim"
+ENT.Base = "art_chest"
+ENT.PrintName = "art_sawhorse"
+ENT.Author = "Apickx"
+
+ENT.Spawnable = false
+ENT.AdminSpawnable = false
+
+local skil = nrequire("sh_skillcommon.lua")
+skil.RegisterSkill({"Crafting","Carpentry"})
+
+ENT.props = {
+ ["A short board"] = {
+ model = "models/props_debris/wood_board06a.mdl",
+ cost = 1
+ },
+ ["A longer board"] = {
+ model = "models/props_debris/wood_board07a.mdl",
+ cost = 2,
+ },
+ ["A pallet"] = {
+ model = "models/props_junk/wood_pallet001a.mdl",
+ cost = 2
+ },
+ ["A large flat peice of wood"] = {
+ model = "models/props_wasteland/wood_fence01a.mdl",
+ cost = 3
+ },
+ ["A small flat peice of wood"] = {
+ model = "models/props_wasteland/wood_fence02a.mdl",
+ cost = 2
+ },
+ ["A very strong, boyent fence"] = {
+ model = "models/props_c17/FurnitureShelf001a.mdl",
+ cost = 2
+ },
+ ["A round table"] = {
+ model = "models/props_c17/FurnitureTable001a.mdl",
+ cost = 1
+ },
+ ["A rectangle table"] = {
+ model = "models/props_c17/FurnitureTable002a.mdl",
+ cost = 1
+ },
+ ["A tall pole"] = {
+ model = "models/props_docks/dock01_pole01a_128.mdl",
+ cost = 2
+ }
+}
+return ENT
diff --git a/data/artery/global/art_sawhorse/sv_ent_sawhorse.lua b/data/artery/global/art_sawhorse/sv_ent_sawhorse.lua index 393aaed..100864a 100644 --- a/data/artery/global/art_sawhorse/sv_ent_sawhorse.lua +++ b/data/artery/global/art_sawhorse/sv_ent_sawhorse.lua @@ -1,86 +1,86 @@ ---[[ - This entity gives townies things to do -]] - -local ENT = nrequire("sh_ent_sawhorse.lua") - -DEFINE_BASECLASS("art_chest") -- this defined a local variable called BaseClass - -AddCSLuaFile( "cl_init.lua" ) -AddCSLuaFile( "shared.lua" ) - -print("Hello from art_sawhorse init.lua!") - -local s = include("shared.lua") -local inv = nrequire("core/inventory/inventory.lua") -local itm = nrequire("core/inventory/item.lua") - -function ENT:Initialize( ) - self.InvType = "Crafting Inventory" - BaseClass.Initialize(self) - timer.Simple(0.1,function() - self.data.inventories[self:GetCreationID()].accepts = { - ["Wood"] = true, - } - end) - self.Entity:SetModel("models/props/cs_militia/sawhorse.mdl") - self.Entity:PhysicsInit( SOLID_VPHYSICS ) - self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) - self.Entity:SetSolid( SOLID_VPHYSICS ) - self.Entity:Activate() - local phys = self.Entity:GetPhysicsObject() - if (phys:IsValid()) then - phys:Wake() - phys:SetMass(100) - end - self.selfPos = self.Entity - self:SetUseType(SIMPLE_USE) -end - - -util.AddNetworkString("art_sawhorse_open") -util.AddNetworkString("art_sawhorse_select") -util.AddNetworkString("art_sawhorse_puzzle") -util.AddNetworkString("art_sawhorse_put") -util.AddNetworkString("art_sawhorse_close") - -function ENT:Use(a,c,u,v) - net.Start("art_sawhorse_open") - net.WriteEntity(self) - net.Send(c) - BaseClass.Use(self,a,c,u,v) -end - -net.Receive("art_sawhorse_select",function(ln,ply) - local name = net.ReadString() - local who = net.ReadEntity() - print("props are:") - PrintTable(ENT.props) - assert(ENT.props[name],"Player " .. ply:Nick() .. " tried to make a prop we don't have:" .. name) - local cost = ENT.props[name].cost - print("player wanted to make a ",name,cost) - local num = 0 - local myinv = who.data.inventories[who:GetCreationID()] - local cursor = myinv:Has("Wood") - local titm = nil - while cursor ~= nil and num < cost do - titm = myinv:Remove(cursor) - num = num + 1 - cursor = myinv:Has("Wood") - end - if num == cost then - local e = ents.Create("prop_physics") - e:SetPos(who:GetPos() + Vector(0,0,100)) - e:SetModel(ENT.props[name].model) - e:Spawn() - ply:AddSkill("Carpentry",cost) - else - --Put stuff back in if we didn't have enough! - for i = 1,num do - local pos = myinv:FindPlaceFor(titm) - myinv:Put(pos,titm) - end - end -end) - -scripted_ents.Register(ENT,"art_sawhorse") +--[[
+ This entity gives townies things to do
+]]
+
+local ENT = nrequire("sh_ent_sawhorse.lua")
+
+DEFINE_BASECLASS("art_chest") -- this defined a local variable called BaseClass
+
+AddCSLuaFile( "cl_init.lua" )
+AddCSLuaFile( "shared.lua" )
+
+print("Hello from art_sawhorse init.lua!")
+
+local s = include("shared.lua")
+local inv = nrequire("core/inventory/inventory.lua")
+local itm = nrequire("core/inventory/item.lua")
+
+function ENT:Initialize( )
+ self.InvType = "Crafting Inventory"
+ BaseClass.Initialize(self)
+ timer.Simple(0.1,function()
+ self.data.inventories[self:GetCreationID()].accepts = {
+ ["Wood"] = true,
+ }
+ end)
+ self.Entity:SetModel("models/props/cs_militia/sawhorse.mdl")
+ self.Entity:PhysicsInit( SOLID_VPHYSICS )
+ self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
+ self.Entity:SetSolid( SOLID_VPHYSICS )
+ self.Entity:Activate()
+ local phys = self.Entity:GetPhysicsObject()
+ if (phys:IsValid()) then
+ phys:Wake()
+ phys:SetMass(100)
+ end
+ self.selfPos = self.Entity
+ self:SetUseType(SIMPLE_USE)
+end
+
+
+util.AddNetworkString("art_sawhorse_open")
+util.AddNetworkString("art_sawhorse_select")
+util.AddNetworkString("art_sawhorse_puzzle")
+util.AddNetworkString("art_sawhorse_put")
+util.AddNetworkString("art_sawhorse_close")
+
+function ENT:Use(a,c,u,v)
+ net.Start("art_sawhorse_open")
+ net.WriteEntity(self)
+ net.Send(c)
+ BaseClass.Use(self,a,c,u,v)
+end
+
+net.Receive("art_sawhorse_select",function(ln,ply)
+ local name = net.ReadString()
+ local who = net.ReadEntity()
+ print("props are:")
+ PrintTable(ENT.props)
+ assert(ENT.props[name],"Player " .. ply:Nick() .. " tried to make a prop we don't have:" .. name)
+ local cost = ENT.props[name].cost
+ print("player wanted to make a ",name,cost)
+ local num = 0
+ local myinv = who.data.inventories[who:GetCreationID()]
+ local cursor = myinv:Has("Wood")
+ local titm = nil
+ while cursor ~= nil and num < cost do
+ titm = myinv:Remove(cursor)
+ num = num + 1
+ cursor = myinv:Has("Wood")
+ end
+ if num == cost then
+ local e = ents.Create("prop_physics")
+ e:SetPos(who:GetPos() + Vector(0,0,100))
+ e:SetModel(ENT.props[name].model)
+ e:Spawn()
+ ply:AddSkill("Carpentry",cost)
+ else
+ --Put stuff back in if we didn't have enough!
+ for i = 1,num do
+ local pos = myinv:FindPlaceFor(titm)
+ myinv:Put(pos,titm)
+ end
+ end
+end)
+
+scripted_ents.Register(ENT,"art_sawhorse")
|
