diff options
author | ubq323 <ubq323@ubq323.website> | 2023-01-24 15:28:43 +0000 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2023-01-24 15:28:43 +0000 |
commit | e97b8e844c931c9daff036805ea18d087429d472 (patch) | |
tree | a60d91e49eb54e9101ebf4d285481ad4dd505ce5 /server/server.lua | |
parent | b5484fc37c1f93654f95f21483d52229a34e6330 (diff) |
things and stuff and things
Diffstat (limited to 'server/server.lua')
-rw-r--r-- | server/server.lua | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/server/server.lua b/server/server.lua index 4db0207..c518222 100644 --- a/server/server.lua +++ b/server/server.lua @@ -9,6 +9,7 @@ print(host) -- sequential list of all players local playerlist = {} +local nextid = 1 -- this is maybe suboptimal -- but it is simplest for now @@ -25,17 +26,13 @@ local function player_by_peer(peer) return nil end - -local function gen_id() - local x = math.random(100000) - -- if players[x] then error("cough") end - return x -end local function random_color() return {math.random(),math.random(),math.random()} end local function make_player(peer) - return {pos={100,100},color=random_color(),peer=peer} + local p = {pos={100,100},color=random_color(),peer=peer,id=nextid} + nextid = nextid + 1 + return p end -- maybe json could be used for this @@ -68,7 +65,6 @@ while true do if ev.type == "connect" then local player = make_player(ev.peer) table.insert(playerlist,player) - player.id = #playerlist print("connect",player.peer,player.id) player.peer:send(player_you_packet(player)) |