From 0fe57f5eb755d618f3d35adf6ab2e19a5c16792a Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 6 Nov 2017 21:15:18 -0500 Subject: allows for saved props --- lua/autorun/saveprops.lua | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lua/autorun/saveprops.lua (limited to 'lua/autorun') diff --git a/lua/autorun/saveprops.lua b/lua/autorun/saveprops.lua new file mode 100644 index 0000000..ec3455d --- /dev/null +++ b/lua/autorun/saveprops.lua @@ -0,0 +1,39 @@ +if CLIENT then return end +local function saveparts() + local spawndata = {"local e"} + for k,v in pairs(ents.GetAll()) do + if v:GetPersistent() then + local c = v:GetColor() + local a = v:GetAngles() + local p = v:GetPos() + spawndata[#spawndata + 1] = string.format([[ +e = ents.Create(%q) +e:SetModel(%q) +e:SetMaterial(%q) +e:SetColor(Color(%d,%d,%d,%d)) +e:SetAngles(Angle(%d,%d,%d)) +e:SetPos(Vector(%d,%d,%d)) +e:Spawn() +e:GetPhysicsObject():EnableMotion(false) + ]], + v:GetClass(), + v:GetModel(), + v:GetMaterial(), + c.r,c.g,c.b,c.a, + a.p,a.y,a.r, + p.x,p.y,p.z) + end + end + local fstr = table.concat(spawndata,"\n") + local path = "artery/maps/" .. game.GetMap() .. "/ents.txt" + print("Writing file", fstr," to",path) + file.Write(path,fstr) +end + +concommand.Add("artery_save_persistent_props",saveparts) + +--[[ +hook.Add("ShutDown","artery_save_persistent_props",function() + +end) +]] -- cgit v1.2.3-70-g09d2