diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2016-05-25 22:40:09 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2016-05-25 22:40:09 -0400 |
| commit | f797cbe348dd52b51da4cd4812cfa291d1434095 (patch) | |
| tree | df4fabacfc6819a981d750c510122f5bbda8083c /gamemode/structuresystem/loadstructures.lua | |
| parent | a5932d386488030b6005c829fe343f74daed9893 (diff) | |
| parent | fd04cb695e1c0e6597456f2b1b7b076310fd81bf (diff) | |
| download | gmstranded-f797cbe348dd52b51da4cd4812cfa291d1434095.tar.gz gmstranded-f797cbe348dd52b51da4cd4812cfa291d1434095.tar.bz2 gmstranded-f797cbe348dd52b51da4cd4812cfa291d1434095.zip | |
Merge branch 'structsystem'hotfix
Diffstat (limited to 'gamemode/structuresystem/loadstructures.lua')
| -rw-r--r-- | gamemode/structuresystem/loadstructures.lua | 34 |
1 files changed, 34 insertions, 0 deletions
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) |
