local mapfile = "/home/th3r00t/.local/share/blightmud/sindome.map"
Map = Mapper.create("sindome")

local function file_exists(file)
	local f = io.open(file, "r")
	if f then
		f:close()
		return true
	else
		return false
	end
end

local function load_map()
	if file_exists(mapfile) then
		blight.status_line(1, "Loading map...")
		Map:load(mapfile)
	end
end


local function sindome_connect()
	blight.status_height(1)
	blight.status_line(0, "Connecting to Sindome...")
	blight.status_line(1, "Logging in...")
	mud.send("connect ryn XeGEb")
	blight.status_line(1, "Connected To Sindome.")
	blight.status_line(0, "Sindome")
	load_map()
	Map:print()
end

mud.on_disconnect(function()
	blight.status_line(0, "Disconnected.")
	if Map then
		Map:save(mapfile)
	end
end)

sindome_connect()
