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

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 empiremud_connect()
	blight.status_height(1)
	blight.status_line(0, "Connecting to Enpire Mud...")
	blight.status_line(1, "Logging in...")
	mud.send("Raelon")
	mud.send("b2edxfrr1")
	blight.status_line(1, "Connected To Enpire Mud.")
	blight.status_line(0, "Enpire Mud")
	load_map()
	Map:print()
end

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

empiremud_connect()
