aboutsummaryrefslogtreecommitdiff
path: root/gamemode/server/sv_mapconfig.lua
blob: 67a20aeecced47a4bc45664dd1dae74428224204 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
--Loads map config form a file

local chests = file.Read("artery/maps/" .. game.GetMap() .. "/chests.txt")
local npcs = file.Read("artery/maps/" .. game.GetMap() .. "/npcs.txt")

if chests == nil then return end
if npcs == nil then return end

for _,line in pairs(string.Explode("\n",chests,false)) do
    local chest = util.JSONToTable(line)
    local chestent = ents.Create("art_chest")
    for k,v in pairs(chest.data) do
        chestent[k] = v
    end
    for k,v in pairs(chest.procedures) do
        chestent[k](unpack(v))
    end
    chestent:Spawn()
end