Monitors can be switched on/off

This commit is contained in:
Pierre-Yves Rollo 2018-12-08 16:45:27 +01:00
parent 6b9fdf98f2
commit 31cc460c6d

View File

@ -93,9 +93,9 @@ local cathodic_collision_box = {
digiterms.register_monitor('digiterms:cathodic_amber_monitor', {
description = "Cathodic amber monitor",
sunlight_propagates = false,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = false,
tiles = { "digiterms_amber_top.png", "digiterms_amber_bottom.png",
"digiterms_amber_sides.png", "digiterms_amber_sides.png^[transformFX]",
"digiterms_amber_back.png", "digiterms_amber_front.png",},
@ -114,13 +114,44 @@ digiterms.register_monitor('digiterms:cathodic_amber_monitor', {
color = "#FFA000", font_name = digiterms.font, halign="left", valing="top",
},
},
on_punch = function(pos, node)
display_api.on_destruct(pos)
local meta = minetest.get_meta(pos)
meta:set_string("display_text", nil)
minetest.swap_node(pos, {name = 'digiterms:cathodic_amber_monitor_off',
param = node.param, param2 = node.param2 })
end
})
minetest.register_node('digiterms:cathodic_amber_monitor_off', {
paramtype = "light",
paramtype2 = "facedir",
description = "Cathodic amber monitor",
drops = "digiterms:cathodic_amber_monitor",
sunlight_propagates = false,
tiles = { "digiterms_amber_top.png", "digiterms_amber_bottom.png",
"digiterms_amber_sides.png", "digiterms_amber_sides.png^[transformFX]",
"digiterms_amber_back.png", "digiterms_amber_front_off.png",},
drawtype = "nodebox",
groups = {choppy = 1, oddly_breakable_by_hand = 1},
node_box = cathodic_node_box,
collision_box = cathodic_collision_box,
selection_box = cathodic_collision_box,
on_place = minetest.rotate_node,
on_receive_fields = common_node_def.on_receive_fields,
on_punch = function(pos, node)
minetest.swap_node(pos, {name = 'digiterms:cathodic_amber_monitor',
param = node.param, param2 = node.param2 })
display_api.update_entities(pos)
end,
})
digiterms.register_monitor('digiterms:cathodic_green_monitor', {
description = "Cathodic green monitor",
sunlight_propagates = false,
paramtype = "light",
paramtype2 = "facedir",
description = "Cathodic green monitor",
sunlight_propagates = false,
tiles = { "digiterms_green_top.png", "digiterms_green_bottom.png",
"digiterms_green_sides.png", "digiterms_green_sides.png^[transformFX]",
"digiterms_green_back.png", "digiterms_green_front.png",},
@ -139,4 +170,34 @@ digiterms.register_monitor('digiterms:cathodic_green_monitor', {
color = "#00FF00", font_name = digiterms.font, halign="left", valing="top",
},
},
on_punch = function(pos, node)
display_api.on_destruct(pos)
local meta = minetest.get_meta(pos)
meta:set_string("display_text", nil)
minetest.swap_node(pos, {name = 'digiterms:cathodic_green_monitor_off',
param = node.param, param2 = node.param2 })
end
})
minetest.register_node('digiterms:cathodic_green_monitor_off', {
paramtype = "light",
paramtype2 = "facedir",
description = "Cathodic green monitor",
drops = "digiterms:cathodic_green_monitor",
sunlight_propagates = false,
tiles = { "digiterms_green_top.png", "digiterms_green_bottom.png",
"digiterms_green_sides.png", "digiterms_green_sides.png^[transformFX]",
"digiterms_green_back.png", "digiterms_green_front_off.png",},
drawtype = "nodebox",
groups = {choppy = 1, oddly_breakable_by_hand = 1},
node_box = cathodic_node_box,
collision_box = cathodic_collision_box,
selection_box = cathodic_collision_box,
on_place = minetest.rotate_node,
on_receive_fields = common_node_def.on_receive_fields,
on_punch = function(pos, node)
minetest.swap_node(pos, {name = 'digiterms:cathodic_green_monitor',
param = node.param, param2 = node.param2 })
display_api.update_entities(pos)
end,
})