Skip to content

Commit 1eae30f

Browse files
authored
tweak visuals (#106)
1 parent 697f63d commit 1eae30f

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

engine.lua

+5-16
Original file line numberDiff line numberDiff line change
@@ -251,25 +251,14 @@ minetest.register_node("jumpdrive:engine", {
251251
end
252252
end,
253253

254-
on_punch = function(pos, _, player)
255-
if not has_vizlib then
256-
-- no visualization lib
257-
return
258-
end
254+
on_punch = has_vizlib and function(pos, _, player)
259255
if not player or player:get_wielded_item():get_name() ~= "" then
260-
-- non-empty hand
261-
return
262-
end
263-
if minetest.is_protected(pos, player:get_player_name()) then
264-
-- non-owner
256+
-- Only show jump area when using an empty hand
265257
return
266258
end
267-
268-
local meta = minetest.get_meta(pos);
269-
local radius = meta:get_int("radius")
270-
271-
vizlib.draw_cube(pos, radius + 0.5, { color = "#00ff00" })
272-
end
259+
local radius = minetest.get_meta(pos):get_int("radius")
260+
vizlib.draw_cube(pos, radius + 0.5, { color = "#00ff00", player = player })
261+
end or nil,
273262
})
274263

275264
if minetest.get_modpath("technic") then

jump.lua

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ jumpdrive.simulate_jump = function(pos, player, show_marker)
99
end
1010

1111
local meta = minetest.get_meta(pos)
12+
13+
if show_marker and has_vizlib and os.time() < meta:get_int("simulation_expiry") then
14+
return false, "Error: simulation is still active! please wait before simulating again"
15+
end
16+
1217
local radius = jumpdrive.get_radius(pos)
1318
local distance = vector.distance(pos, targetPos)
1419

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

4653
local msg = nil

0 commit comments

Comments
 (0)