poppy-client/main.lua

68 lines
1.6 KiB
Lua

function dofile(fileString)
local chunk = love.filesystem.load(fileString)
chunk()
end
function love.load(args)
if args[1] == "--nwTest" then
local format = require("shared.networkFormat")
format.testEncoder()
elseif args[1] == "--server" then
if not args[2]then
print("Missing server adress!")
love.event.quit()
return
end
local host = args[2]
local port = "11150"
if args[3] then port = args[3] end
local serverloop = require("server.main")
print("Starting server! [" .. host .. "] <" .. port .. ">")
serverloop.init({host, port})
elseif args[1] == "--client" then
if not args[2]then
print("Missing server adress!")
love.event.quit()
return
end
dofile "lua/gameloop.lua"
dofile "lua/layout.lua"
dofile "lua/ui.lua"
dofile "lua/camera.lua"
dofile "lua/physics.lua"
dofile "lua/drawing.lua"
setmetatable(_G, {
__index = function(self, idx)
if rawget(self, idx) == nil then
error("attempted to read implicit global:" .. idx)
end
end
})
PHYSICS_DEBUG = false
NETWORK_DEBUG = true
local host = args[2]
local port = "11150"
if args[3] then port = args[3] end
local avatar = love.image.newImageData("textures/player/nephele/fallback.png")
local avatarHash = love.data.hash("sha512", avatar:getString())
levelloop.init({ adress = host, port = port }, "Fallback player", avatarHash)
elseif args[1] == "--help" then
print(" --server [host] <port>")
print(" Start a local server")
print("")
print(" --help")
print(" print this help")
return
else
constants = require("server.constants")
local menu = require("lua.menuloop")
menu.init()
end
end