diff options
author | ubq323 <ubq323@ubq323.website> | 2023-02-25 15:24:33 +0000 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2023-03-14 23:11:13 +0000 |
commit | 3c66e7a4d91e2c891cd3b93346ee1f211eb4b6a5 (patch) | |
tree | d614d872298b11c1e652fb8db9caa212872e7467 /client/main.lua | |
parent | 242a0b4e7deb356a0015fbf536158962ad2ea29c (diff) |
don't draw chunks definitely not on screen; add targeting reticle; save chunks before exiting on sigint; add /tp 'command'
Diffstat (limited to 'client/main.lua')
-rw-r--r-- | client/main.lua | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/client/main.lua b/client/main.lua index 74a8be9..c2d5a76 100644 --- a/client/main.lua +++ b/client/main.lua @@ -75,7 +75,17 @@ function love.keypressed(key,scancode,isrepeat) elseif ui_mode == "chat" then if key == "return" then ui_mode = "normal" - peer:send(json.encode{t="chat",msg=this_chatmsg}) + if this_chatmsg:sub(1,3) == "/tp" then + local x,y = this_chatmsg:match("/tp (%S+) (%S+)") + if x then + x,y = tonumber(x),tonumber(y) + local_player.pos.x=x + local_player.pos.y=y + local_player.pos_dirty=true + end + else + peer:send(json.encode{t="chat",msg=this_chatmsg}) + end -- msgbox.add("[me] "..this_chatmsg) elseif key == "escape" then ui_mode = "normal" @@ -264,6 +274,26 @@ function love.draw() local wm = camera:screen_to_world(sm) local hm = wm:to_hex() + -- draw reticle + local hmr = hm:round() + local mouse_tile = map:at(hmr) + if mouse_tile then + local col = {0.5,0.5,0.5} + if mouse_tile == 0 then col = {0,0,0} end + local c = hmr:to_pos() + local verts = {} + for i=0,5 do + local angle = math.pi*2*(i+0.5)/6 + table.insert(verts, c.x+math.cos(angle)) + table.insert(verts, c.y+math.sin(angle)) + end + love.graphics.setColor(col) + love.graphics.setLineWidth(0.05) + love.graphics.polygon("line",verts) + end + + + love.graphics.origin() util.print_good(tostring(selected_tile), "center",10) if _G.debugmode and local_player then |