math.randomseed( os.time() )

-- GLOBALS
_isMultiplayer, _localPlayer, _externalPlayer, _aiPlayer = false, 1, 2, 2
_mapSeed, _mapSize = os.time(), 2

-- GLOBAL SETTINGS
_settings = {
	enableMusic = true,
	hostIp =  "127.0.0.1",
	hostPort = 3000,
	playerName = "Player"
}

dofile("players.lua")
dofile("multiplayer.lua")

dofile("game.lua")
dofile("menu.lua")

local function mainInit()

	local path = daisy.getUserFolderPath("/")
	local newTable = table.load(path .. "HouseGlobe.cfg")
	if newTable and newTable.hostIp and newTable.hostPort and newTable.playerName then
		_settings = newTable
	end

	registerMenuState()
	--registerGameState()

end
hook.add("gameInit", mainInit)

local function mainClose()
	local path = daisy.getUserFolderPath("/")
	table.save(_settings, path .. "HouseGlobe.cfg")
end
hook.add("gameClose", mainClose)