summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/game.lua22
-rw-r--r--client/util.lua15
2 files changed, 33 insertions, 4 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
diff --git a/client/util.lua b/client/util.lua
index 2c7d90a..a1c4b35 100644
--- a/client/util.lua
+++ b/client/util.lua
@@ -13,6 +13,19 @@ local function print_good(str,x,y)
love.graphics.draw(text,x,y)
end
+local tile_names = {
+ 'red',
+ 'orange',
+ 'yellow',
+ 'green',
+ 'teal',
+ 'blue',
+ 'purple',
+ 'grey',
+ 'ubqorange',
+}
+
return {
- print_good=print_good
+ print_good=print_good,
+ tile_names=tile_names,
}