Skip to content

Commit

Permalink
tweak visuals (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
OgelGames authored Jun 8, 2023
1 parent 697f63d commit 1eae30f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
21 changes: 5 additions & 16 deletions engine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -251,25 +251,14 @@ minetest.register_node("jumpdrive:engine", {
end
end,

on_punch = function(pos, _, player)
if not has_vizlib then
-- no visualization lib
return
end
on_punch = has_vizlib and function(pos, _, player)
if not player or player:get_wielded_item():get_name() ~= "" then
-- non-empty hand
return
end
if minetest.is_protected(pos, player:get_player_name()) then
-- non-owner
-- Only show jump area when using an empty hand
return
end

local meta = minetest.get_meta(pos);
local radius = meta:get_int("radius")

vizlib.draw_cube(pos, radius + 0.5, { color = "#00ff00" })
end
local radius = minetest.get_meta(pos):get_int("radius")
vizlib.draw_cube(pos, radius + 0.5, { color = "#00ff00", player = player })
end or nil,
})

if minetest.get_modpath("technic") then
Expand Down
7 changes: 7 additions & 0 deletions jump.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ jumpdrive.simulate_jump = function(pos, player, show_marker)
end

local meta = minetest.get_meta(pos)

if show_marker and has_vizlib and os.time() < meta:get_int("simulation_expiry") then
return false, "Error: simulation is still active! please wait before simulating again"
end

local radius = jumpdrive.get_radius(pos)
local distance = vector.distance(pos, targetPos)

Expand Down Expand Up @@ -41,6 +46,8 @@ jumpdrive.simulate_jump = function(pos, player, show_marker)
if show_marker and has_vizlib then
vizlib.draw_cube(targetPos, radius + 0.5, { color = "#ff0000" })
vizlib.draw_cube(pos, radius + 0.5, { color = "#00ff00" })
local shape = vizlib.draw_point(targetPos, { color = "#0000ff" })
meta:set_int("simulation_expiry", shape.expiry)
end

local msg = nil
Expand Down

0 comments on commit 1eae30f

Please sign in to comment.