From 4adec24c3a2a53f518d817ae8a6ddd0c4c47422c Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Wed, 25 May 2016 22:06:26 -0400 Subject: more work on the structure system --- gamemode/structuresystem/loadstructures.lua | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 gamemode/structuresystem/loadstructures.lua (limited to 'gamemode/structuresystem/loadstructures.lua') diff --git a/gamemode/structuresystem/loadstructures.lua b/gamemode/structuresystem/loadstructures.lua new file mode 100644 index 0000000..858d976 --- /dev/null +++ b/gamemode/structuresystem/loadstructures.lua @@ -0,0 +1,34 @@ +print("Loading structures!") +GMS = GMS or {} +GMS.Structures = GMS.Structures or {} +GMS.UniqueStructures = {} + +function registerStructure(tbl) + assert(tbl.Name != nil, "Structure's name is nil!") + GMS.Structures[tbl.Name] = tbl +end + +concommand.Add("gms_spawnstructure",function(ply,cmd,args) + if !ply:IsDeveloper() then return end + assert(args[1] != "","Failed to find structure name") + assert(GMS.Structures[args[1]] != nil, "Structure \"" .. args[1] .. "\" does not exist!") + + local tr = ply:GetEyeTrace() + local e = ents.Create("gms_generic_structure") + + local tbl = GMS.Structures[args[1]] + if tbl.uniquedata then + tbl = table.Copy(tbl) + GMS.UniqueStructures[e:EntIndex()] = tbl + end + + for k,v in pairs(tbl) do + print("Setting " .. k .. " to") + print(v) + e[k] = v + end + e:Spawn() + e:SetPos(tr.HitPos) + SPropProtection.PlayerMakePropOwner( ply, e ) + --e:SetNWString("Owner",ply:Nick()) +end) -- cgit v1.2.3-70-g09d2