----------------------------
-- SSTRP
-- Author: MNWRP
--
-- Alpha Version
-- doors.lua
----------------------------

Doors = {}

function LoadDoors()

	if(file.Exists("SSTRP/MapData/" .. game.GetMap() .. ".txt")) then

		local rawdata = file.Read("SSTRP/MapData/" .. game.GetMap() .. ".txt");
		local tabledata = util.KeyValuesToTable(rawdata);
		
		Doors = tabledata;
		
	end
	
end

function GetDoorGroup(entity)
		
	local pos = entity:GetPos();
	local doorgroups = {};

	for k, v in pairs(Doors) do
		
		if(tonumber(v["x"]) == math.ceil(tonumber(pos.x)) and tonumber(v["y"]) == math.ceil(tonumber(pos.y)) and tonumber(v["z"]) == math.ceil(tonumber(pos.z))) then
			
			table.insert(doorgroups, v["group"]);
				
		end
			
	end

	return doorgroups;

end
