diff options
Diffstat (limited to 'client/game.lua')
-rw-r--r-- | client/game.lua | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/client/game.lua b/client/game.lua index 4fc148b..43e2352 100644 --- a/client/game.lua +++ b/client/game.lua @@ -204,7 +204,6 @@ local function handle_net() remote_players[id]=nil elseif op == "move" then local id,x,y = j.id,j.x,j.y - assert(remote_players[id],"wheeze "..id) remote_players[id].pos.x = x remote_players[id].pos.y = y elseif op == "you" then @@ -213,7 +212,10 @@ local function handle_net() pos=coords.Pos:make(pl.x,pl.y), color=pl.color, id=pl.id, username=pl.username, + inv = {}, } + elseif op == "inv" then + local_player.inv = j.inv elseif op == "chunk" then local ch = ChunkC:from_packet_data(j) map:add_chunk(ch) @@ -240,8 +242,10 @@ local function update(dt) local mh = camera:screen_to_world(Pos:make(msx,msy)):to_hex():round() if map:at(mh) == 0 and love.mouse.isDown(1) then - map:set_at(mh,selected_tile) - send_settile(mh,selected_tile) + if (local_player.inv[selected_tile] or 0) > 0 then + map:set_at(mh,selected_tile) + send_settile(mh,selected_tile) + end elseif map:at(mh) ~= 0 and love.mouse.isDown(2) then map:set_at(mh,0) send_settile(mh,0) @@ -337,6 +341,18 @@ local function draw() },"\n"),10,10) end + local inv_rows = {'inventory:'} + for t=1,9 do + local c = local_player.inv[t] or 0 + local s = t..': '..util.tile_names[t]..' x'..c + if selected_tile == t then + s = s .. ' <--' + end + table.insert(inv_rows, s) + end + util.print_good(table.concat(inv_rows,'\n'),0,0) + + if show_controls then util.print_good(help_text,"center","center") end |