digicontrol/filter.lua

53 lines
1.5 KiB
Lua
Raw Normal View History

2021-01-23 11:27:31 +01:00
minetest.register_node("digicontrol:filter", {
description = "Digilines Filter",
inventory_image = "digicontrol_filter.png",
tiles = {
"digicontrol_filter.png",
"digicontrol_bottom.png",
"digicontrol_side_port.png",
"digicontrol_side_port.png",
"digicontrol_side.png",
"digicontrol_side.png"
},
drawtype = "nodebox",
node_box = digicontrol.node_box,
selection_box = digicontrol.selection_box,
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
groups = {digicontrol = 1, dig_immediate = 2},
2021-01-24 12:41:06 +01:00
on_rotate = digicontrol.on_rotate,
after_place_node = digilines.update_autoconnect,
after_destruct = digilines.update_autoconnect,
2021-01-23 12:33:53 +01:00
on_construct = function(pos)
2021-01-24 12:41:06 +01:00
minetest.get_meta(pos):set_string("formspec", "field[channel;Digiline Channel;${channel}]")
2021-01-23 12:33:53 +01:00
end,
on_receive_fields = function(pos, _, fields, sender)
if minetest.is_protected(pos, sender:get_player_name()) then return end
if fields.channel then
minetest.get_meta(pos):set_string("channel", fields.channel)
end
end,
2021-01-23 11:27:31 +01:00
digiline = {
semiconductor = {
2021-01-24 07:55:47 +01:00
rules = function(node, pos, _, channel)
2021-01-23 11:27:31 +01:00
local setchannel = minetest.get_meta(pos):get_string("channel")
if channel ~= setchannel then return {} end
2021-01-24 07:55:47 +01:00
return {
digicontrol.get_rule(1, node.param2),
digicontrol.get_rule(3, node.param2)
}
2021-01-23 11:27:31 +01:00
end
},
wire = {
rules = function(node)
return {
digicontrol.get_rule(1, node.param2),
digicontrol.get_rule(3, node.param2)
}
end
}
}
})