Change emitter state with tool only

master
Wuzzy 2022-01-30 19:17:55 +01:00
parent b736d80ec1
commit 28a6e96b7b
2 changed files with 3 additions and 9 deletions

View File

@ -388,7 +388,7 @@ register_element("emitter", {
},
light_source_on = 7,
on_rightclick = function(pos, node)
_lzr_on_toggle = function(pos, node)
if lzr_gamestate.get_state() == lzr_gamestate.LEVEL_COMPLETE then
return
end

View File

@ -15,14 +15,8 @@ minetest.register_tool("lzr_laser:emit_toggler", {
return itemstack
end
local def = minetest.registered_nodes[node.name]
-- Deactivate emitter
if def._lzr_inactive then
minetest.swap_node(pos, {name=def._lzr_inactive, param2=node.param2})
lzr_laser.full_laser_update(lzr_globals.PLAYFIELD_START, lzr_globals.PLAYFIELD_END)
-- Activate emitter
elseif def._lzr_active then
minetest.swap_node(pos, {name=def._lzr_active, param2=node.param2})
lzr_laser.full_laser_update(lzr_globals.PLAYFIELD_START, lzr_globals.PLAYFIELD_END)
if def._lzr_on_toggle then
def._lzr_on_toggle(pos, node)
end
return itemstack
end,