add limiter, simplify filter code
This commit is contained in:
parent
474fa1bfb8
commit
a285363c92
@ -7,11 +7,11 @@ Adds nodes to control the flow of digiline messages.
|
|||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
- limiter and router
|
- router (sorting tube for digiline messages)
|
||||||
- crossing and double corner insulated wires
|
- crossing and double corner insulated wires
|
||||||
- compatibility for replacing `digiline_routing`
|
- compatibility for replacing `digiline_routing`
|
||||||
- craft recipes
|
- craft recipes
|
||||||
- isulated wires from `digistuff` (when not installed)
|
- insulated wires from `digistuff` (when not installed)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
10
filter.lua
10
filter.lua
@ -28,20 +28,14 @@ minetest.register_node("digicontrol:filter", {
|
|||||||
end,
|
end,
|
||||||
digiline = {
|
digiline = {
|
||||||
semiconductor = {
|
semiconductor = {
|
||||||
rules = function(node, pos, from, channel)
|
rules = function(node, pos, _, channel)
|
||||||
local setchannel = minetest.get_meta(pos):get_string("channel")
|
local setchannel = minetest.get_meta(pos):get_string("channel")
|
||||||
if channel ~= setchannel then return {} end
|
if channel ~= setchannel then return {} end
|
||||||
local side = digicontrol.get_side(pos, from, node.param2)
|
|
||||||
if side == 3 then
|
|
||||||
return {
|
|
||||||
digicontrol.get_rule(1, node.param2)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return {
|
return {
|
||||||
|
digicontrol.get_rule(1, node.param2),
|
||||||
digicontrol.get_rule(3, node.param2)
|
digicontrol.get_rule(3, node.param2)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
},
|
},
|
||||||
wire = {
|
wire = {
|
||||||
rules = function(node)
|
rules = function(node)
|
||||||
|
2
init.lua
2
init.lua
@ -45,5 +45,5 @@ dofile(MP.."/diode.lua")
|
|||||||
dofile(MP.."/splitter.lua")
|
dofile(MP.."/splitter.lua")
|
||||||
dofile(MP.."/trisplitter.lua")
|
dofile(MP.."/trisplitter.lua")
|
||||||
dofile(MP.."/filter.lua")
|
dofile(MP.."/filter.lua")
|
||||||
--dofile(MP.."/limiter.lua")
|
dofile(MP.."/limiter.lua")
|
||||||
--dofile(MP.."/router.lua")
|
--dofile(MP.."/router.lua")
|
||||||
|
58
limiter.lua
Normal file
58
limiter.lua
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
|
||||||
|
minetest.register_node("digicontrol:limiter", {
|
||||||
|
description = "Digilines Limiter",
|
||||||
|
inventory_image = "digicontrol_limiter.png",
|
||||||
|
tiles = {
|
||||||
|
"digicontrol_limiter.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},
|
||||||
|
on_construct = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("formspec", "field[limit;Message Limit (messages/second);${limit}]")
|
||||||
|
meta:set_string("limit", "1")
|
||||||
|
end,
|
||||||
|
on_receive_fields = function(pos, _, fields, sender)
|
||||||
|
if minetest.is_protected(pos, sender:get_player_name()) then return end
|
||||||
|
if fields.limit then
|
||||||
|
local limit = tonumber(fields.limit)
|
||||||
|
if limit then
|
||||||
|
minetest.get_meta(pos):set_string("limit", math.min(limit, 10))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
digiline = {
|
||||||
|
semiconductor = {
|
||||||
|
rules = function(node, pos)
|
||||||
|
local timer = minetest.get_node_timer(pos)
|
||||||
|
local limit = tonumber(minetest.get_meta(pos):get_string("limit"))
|
||||||
|
if not limit or limit == 0 or timer:is_started() then return {} end
|
||||||
|
if limit > 0 then
|
||||||
|
timer:start(1 / limit)
|
||||||
|
end
|
||||||
|
return {
|
||||||
|
digicontrol.get_rule(1, node.param2),
|
||||||
|
digicontrol.get_rule(3, node.param2)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
},
|
||||||
|
wire = {
|
||||||
|
rules = function(node)
|
||||||
|
return {
|
||||||
|
digicontrol.get_rule(1, node.param2),
|
||||||
|
digicontrol.get_rule(3, node.param2)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
BIN
textures/digicontrol_limiter.png
Normal file
BIN
textures/digicontrol_limiter.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.8 KiB |
Loading…
Reference in New Issue
Block a user