forked from mtcontrib/digiterms
Preparation to add some more monitors
This commit is contained in:
parent
0cbffd0753
commit
8974ac0c2d
93
nodes.lua
93
nodes.lua
@ -1,5 +1,5 @@
|
|||||||
--[[
|
--[[
|
||||||
digimons mod for Minetest - Digiline monitors using Display API / Font API
|
digimons mod for Minetest - Digilines monitors using Display API / Font API
|
||||||
(c) Pierre-Yves Rollo
|
(c) Pierre-Yves Rollo
|
||||||
|
|
||||||
This file is part of digimons.
|
This file is part of digimons.
|
||||||
@ -18,7 +18,60 @@
|
|||||||
along with signs. If not, see <http://www.gnu.org/licenses/>.
|
along with signs. If not, see <http://www.gnu.org/licenses/>.
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
minetest.register_node('digimons:cathodic_amber_monitor', {
|
local common_node_def = {
|
||||||
|
groups = { display_api = 1},
|
||||||
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
minetest.rotate_node(itemstack, placer, pointed_thing)
|
||||||
|
return display_api.on_place(itemstack, placer, pointed_thing)
|
||||||
|
end,
|
||||||
|
on_destruct = display_api.on_destruct,
|
||||||
|
on_rotate = display_api.on_rotate,
|
||||||
|
on_punch = display_api.update_entities,
|
||||||
|
on_construct = function(pos)
|
||||||
|
minetest.get_meta(pos):set_string("formspec",
|
||||||
|
"field[channel;Channel;${channel}]")
|
||||||
|
display_api.on_construct(pos)
|
||||||
|
end,
|
||||||
|
on_receive_fields = function(pos, formname, fields, player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
if minetest.is_protected(pos, name) then
|
||||||
|
minetest.record_protection_violation(pos, name)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if (fields.channel) then
|
||||||
|
minetest.get_meta(pos):set_string("channel", fields.channel)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
digiline = {
|
||||||
|
receptor = {},
|
||||||
|
effector = {
|
||||||
|
action = function(pos, _, channel, msg)
|
||||||
|
if channel ~= minetest.get_meta(pos):get_string("channel") then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
digimons.push_text_on_screen(pos, msg)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
function digimons.register_monitor(nodename, nodedef)
|
||||||
|
def = table.copy(common_node_def)
|
||||||
|
for key, value in pairs(nodedef) do
|
||||||
|
if key == 'groups' then
|
||||||
|
def[key] = def[key] or {}
|
||||||
|
for key2, value2 in pairs(value) do
|
||||||
|
def[key][key2] = value2
|
||||||
|
end
|
||||||
|
else
|
||||||
|
def[key] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
minetest.register_node(nodename, nodedef)
|
||||||
|
end
|
||||||
|
|
||||||
|
digimons.register_monitor('digimons:cathodic_amber_monitor', {
|
||||||
description = "Cathodic amber monitor",
|
description = "Cathodic amber monitor",
|
||||||
sunlight_propagates = false,
|
sunlight_propagates = false,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
@ -27,7 +80,7 @@ minetest.register_node('digimons:cathodic_amber_monitor', {
|
|||||||
"digimons_amber_sides.png", "digimons_amber_sides.png^[transformFX]",
|
"digimons_amber_sides.png", "digimons_amber_sides.png^[transformFX]",
|
||||||
"digimons_amber_back.png", "digimons_amber_front.png",},
|
"digimons_amber_back.png", "digimons_amber_front.png",},
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
groups = {choppy = 1, oddly_breakable_by_hand = 1, display_modpack_node = 1},
|
groups = {choppy = 1, oddly_breakable_by_hand = 1},
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
@ -49,38 +102,4 @@ minetest.register_node('digimons:cathodic_amber_monitor', {
|
|||||||
color = "#FFA000", font_name = "mozart", halign="left", valing="top",
|
color = "#FFA000", font_name = "mozart", halign="left", valing="top",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
|
||||||
minetest.rotate_node(itemstack, placer, pointed_thing)
|
|
||||||
return display_api.on_place(itemstack, placer, pointed_thing)
|
|
||||||
end,
|
|
||||||
on_construct = function(pos)
|
|
||||||
minetest.get_meta(pos):set_string("formspec",
|
|
||||||
"field[channel;Channel;${channel}]")
|
|
||||||
display_api.on_construct(pos)
|
|
||||||
end,
|
|
||||||
on_destruct = display_api.on_destruct,
|
|
||||||
on_rotate = display_api.on_rotate,
|
|
||||||
on_receive_fields = function(pos, formname, fields, player)
|
|
||||||
local name = player:get_player_name()
|
|
||||||
if minetest.is_protected(pos, name) then
|
|
||||||
minetest.record_protection_violation(pos, name)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if (fields.channel) then
|
|
||||||
minetest.get_meta(pos):set_string("channel", fields.channel)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
on_punch = display_api.update_entities,
|
|
||||||
digiline = {
|
|
||||||
receptor = {},
|
|
||||||
effector = {
|
|
||||||
action = function(pos, _, channel, msg)
|
|
||||||
if channel ~= minetest.get_meta(pos):get_string("channel") then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
digimons.push_text_on_screen(pos, msg)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user