Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
966f9a56a6 | |||
30c28d882f | |||
78782c9b2b | |||
51cf528732 |
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*~
|
30
COPYING.txt
@ -1,30 +0,0 @@
|
|||||||
The Mesecons Mod for Minetest is
|
|
||||||
Copyright (C) 2011-2016 Mesecons Mod Developer Team and contributors
|
|
||||||
|
|
||||||
See the version control system log for information about other authors.
|
|
||||||
|
|
||||||
License of source code
|
|
||||||
----------------------
|
|
||||||
Copyright (C) 2011-2016 Mesecons Mod Developer Team and contributors
|
|
||||||
|
|
||||||
This program is free software; you can redistribute the Mesecons Mod and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public License version 3
|
|
||||||
published by the Free Software Foundation.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Library General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Library General Public
|
|
||||||
License along with this library; if not, write to the
|
|
||||||
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
||||||
Boston, MA 02110-1301, USA.
|
|
||||||
|
|
||||||
License of media (textures, sounds and documentation)
|
|
||||||
-----------------------------------------------------
|
|
||||||
Copyright (C) 2011-2016 Mesecons Mod Developer Team and contributors
|
|
||||||
|
|
||||||
All textures, sounds and documentation files are licensed under the
|
|
||||||
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
|
||||||
http://creativecommons.org/licenses/by-sa/3.0/
|
|
0
LICENSE.txt
Executable file → Normal file
4
README.md
Executable file → Normal file
@ -22,7 +22,7 @@ OK, I want in.
|
|||||||
--------------
|
--------------
|
||||||
Go get it!
|
Go get it!
|
||||||
|
|
||||||
[DOWNLOAD IT NOW](https://github.com/Jeija/minetest-mod-mesecons/archive/master.zip)
|
[DOWNLOADS PAGE](http://mesecons.net/downloads.php)
|
||||||
|
|
||||||
Now go ahead and install it like any other Minetest mod. Don't know how? Check out [the wonderful page about it](http://wiki.minetest.com/wiki/Mods) over at the Minetest Wiki. For your convenience, here's a quick summary:
|
Now go ahead and install it like any other Minetest mod. Don't know how? Check out [the wonderful page about it](http://wiki.minetest.com/wiki/Mods) over at the Minetest Wiki. For your convenience, here's a quick summary:
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ How do I use this thing?
|
|||||||
------------------------
|
------------------------
|
||||||
How about a [quick overview video](https://www.youtube.com/watch?v=6kmeQj6iW5k)?
|
How about a [quick overview video](https://www.youtube.com/watch?v=6kmeQj6iW5k)?
|
||||||
|
|
||||||
Or maybe a [comprehensive reference](http://mesecons.net/items.html) is your style?
|
Or maybe a [comprehensive reference](http://mesecons.net/items.php) is your style?
|
||||||
|
|
||||||
An overview for the very newest of new beginners? How does [this one](http://uberi.mesecons.net/projects/MeseconsBasics/index.html) look?
|
An overview for the very newest of new beginners? How does [this one](http://uberi.mesecons.net/projects/MeseconsBasics/index.html) look?
|
||||||
|
|
||||||
|
@ -1,62 +0,0 @@
|
|||||||
{
|
|
||||||
"Conductors" : {
|
|
||||||
"Mesecon" : "mesecons/doc/mesecon",
|
|
||||||
"Insulated Wire" : "mesecons_insulated/doc/insulated",
|
|
||||||
"T-Junction" : "mesecons_extrawires/doc/tjunction",
|
|
||||||
"Crossing" : "mesecons_extrawires/doc/crossing",
|
|
||||||
"Corner" : "mesecons_extrawires/doc/corner",
|
|
||||||
"Vertical Wire" : "mesecons_extrawires/doc/vertical",
|
|
||||||
"Mese" : "mesecons_extrawires/doc/mese"
|
|
||||||
},
|
|
||||||
"Receptors" : {
|
|
||||||
"Power Plant" : "mesecons_powerplant/doc/powerplant",
|
|
||||||
"Blinky Plant" : "mesecons_blinkyplant/doc/blinkyplant",
|
|
||||||
"Switch" : "mesecons_switch/doc/switch",
|
|
||||||
"Object Detector" : "mesecons_detector/doc/objectdetector",
|
|
||||||
"Node Detector" : "mesecons_detector/doc/nodedetector",
|
|
||||||
"Wall Lever" : "mesecons_walllever/doc/walllever",
|
|
||||||
"Pressure Plate" : "mesecons_pressureplates/doc/pressureplate_wood",
|
|
||||||
"Pressure Plate" : "mesecons_pressureplates/doc/pressureplate_stone",
|
|
||||||
"Water Turbine" : "mesecons_hydroturbine/doc/waterturbine",
|
|
||||||
"Solar Panel" : "mesecons_solarpanel/doc/solarpanel",
|
|
||||||
"Wall Button" : "mesecons_button/doc/button"
|
|
||||||
},
|
|
||||||
"Effectors" : {
|
|
||||||
"Noteblock" : "mesecons_noteblock/doc/noteblock",
|
|
||||||
"Lamp" : "mesecons_lamp/doc/lamp",
|
|
||||||
"Piston" : "mesecons_pistons/doc/piston",
|
|
||||||
"Sticky Piston" : "mesecons_pistons/doc/piston_sticky",
|
|
||||||
"Movestone" : "mesecons_movestones/doc/movestone",
|
|
||||||
"Sticky Movestone" : "mesecons_movestones/doc/movestone_sticky",
|
|
||||||
"Removestone" : "mesecons_random/doc/removestone",
|
|
||||||
"Ghoststone" : "mesecons_random/doc/ghoststone",
|
|
||||||
"Command Block" : "mesecons_commandblock/doc/commandblock",
|
|
||||||
"Lightstones" : {
|
|
||||||
"Dark Grey" : "mesecons_lightstone/doc/lightstone_darkgrey",
|
|
||||||
"Light Grey" : "mesecons_lightstone/doc/lightstone_lightgrey",
|
|
||||||
"Green" : "mesecons_lightstone/doc/lightstone_green",
|
|
||||||
"Red" : "mesecons_lightstone/doc/lightstone_red",
|
|
||||||
"Blue" : "mesecons_lightstone/doc/lightstone_blue",
|
|
||||||
"Yellow" : "mesecons_lightstone/doc/lightstone_yellow"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Logic" : {
|
|
||||||
"Luacontroller" : "mesecons_luacontroller/doc/luacontroller",
|
|
||||||
"Torch" : "mesecons_torch/doc/torch",
|
|
||||||
"Delayer" : "mesecons_delayer/doc/delayer",
|
|
||||||
"Gates" : {
|
|
||||||
"Diode" : "mesecons_gates/doc/diode",
|
|
||||||
"NOT Gate" : "mesecons_gates/doc/not",
|
|
||||||
"AND Gate" : "mesecons_gates/doc/and",
|
|
||||||
"NAND Gate" : "mesecons_gates/doc/nand",
|
|
||||||
"OR Gate" : "mesecons_gates/doc/or",
|
|
||||||
"NOR Gate" : "mesecons_gates/doc/nor",
|
|
||||||
"XOR Gate" : "mesecons_gates/doc/xor"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Crafts" : {
|
|
||||||
"Silicon" : "mesecons_materials/doc/silicon",
|
|
||||||
"Glue" : "mesecons_materials/doc/glue",
|
|
||||||
"Fiber" : "mesecons_materials/doc/fiber"
|
|
||||||
}
|
|
||||||
}
|
|
1
mesecons/VERSION
Normal file
@ -0,0 +1 @@
|
|||||||
|
0.41 DEV
|
23
mesecons/actionqueue.lua
Executable file → Normal file
@ -23,7 +23,7 @@ function mesecon.queue:add_action(pos, func, params, time, overwritecheck, prior
|
|||||||
-- Otherwise, add the action to the queue
|
-- Otherwise, add the action to the queue
|
||||||
if overwritecheck then -- check if old action has to be overwritten / removed:
|
if overwritecheck then -- check if old action has to be overwritten / removed:
|
||||||
for i, ac in ipairs(mesecon.queue.actions) do
|
for i, ac in ipairs(mesecon.queue.actions) do
|
||||||
if(vector.equals(pos, ac.pos)
|
if(mesecon.cmpPos(pos, ac.pos)
|
||||||
and mesecon.cmpAny(overwritecheck, ac.owcheck)) then
|
and mesecon.cmpAny(overwritecheck, ac.owcheck)) then
|
||||||
toremove = i
|
toremove = i
|
||||||
break
|
break
|
||||||
@ -94,8 +94,25 @@ end
|
|||||||
-- Store and read the ActionQueue to / from a file
|
-- Store and read the ActionQueue to / from a file
|
||||||
-- so that upcoming actions are remembered when the game
|
-- so that upcoming actions are remembered when the game
|
||||||
-- is restarted
|
-- is restarted
|
||||||
mesecon.queue.actions = mesecon.file2table("mesecon_actionqueue")
|
|
||||||
|
local wpath = minetest.get_worldpath()
|
||||||
|
local function file2table(filename)
|
||||||
|
local f = io.open(filename, "r")
|
||||||
|
if f==nil then return {} end
|
||||||
|
local t = f:read("*all")
|
||||||
|
f:close()
|
||||||
|
if t=="" or t==nil then return {} end
|
||||||
|
return minetest.deserialize(t)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function table2file(filename, table)
|
||||||
|
local f = io.open(filename, "w")
|
||||||
|
f:write(minetest.serialize(table))
|
||||||
|
f:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
mesecon.queue.actions = file2table(wpath.."/mesecon_actionqueue")
|
||||||
|
|
||||||
minetest.register_on_shutdown(function()
|
minetest.register_on_shutdown(function()
|
||||||
mesecon.table2file("mesecon_actionqueue", mesecon.queue.actions)
|
mesecon.queue.actions = table2file(wpath.."/mesecon_actionqueue", mesecon.queue.actions)
|
||||||
end)
|
end)
|
||||||
|
0
mesecons/depends.txt
Executable file → Normal file
@ -1 +0,0 @@
|
|||||||
Mesecons are the wires, use them to connect effectors with receptors.
|
|
Before Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 3.8 KiB |
12
mesecons/init.lua
Executable file → Normal file
@ -30,7 +30,7 @@
|
|||||||
-- action_change = function
|
-- action_change = function
|
||||||
-- rules = rules/get_rules
|
-- rules = rules/get_rules
|
||||||
-- },
|
-- },
|
||||||
-- conductor =
|
-- conductor =
|
||||||
-- {
|
-- {
|
||||||
-- state = mesecon.state.on/off
|
-- state = mesecon.state.on/off
|
||||||
-- offstate = opposite state (for state = on only)
|
-- offstate = opposite state (for state = on only)
|
||||||
@ -74,7 +74,7 @@ mesecon.queue:add_function("receptor_on", function (pos, rules)
|
|||||||
|
|
||||||
-- if area (any of the rule targets) is not loaded, keep trying and call this again later
|
-- if area (any of the rule targets) is not loaded, keep trying and call this again later
|
||||||
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
||||||
local np = vector.add(pos, rule)
|
local np = mesecon.addPosRule(pos, rule)
|
||||||
-- if area is not loaded, keep trying
|
-- if area is not loaded, keep trying
|
||||||
if minetest.get_node_or_nil(np) == nil then
|
if minetest.get_node_or_nil(np) == nil then
|
||||||
mesecon.queue:add_action(pos, "receptor_on", {rules}, nil, rules)
|
mesecon.queue:add_action(pos, "receptor_on", {rules}, nil, rules)
|
||||||
@ -84,7 +84,7 @@ mesecon.queue:add_function("receptor_on", function (pos, rules)
|
|||||||
|
|
||||||
-- execute action
|
-- execute action
|
||||||
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
||||||
local np = vector.add(pos, rule)
|
local np = mesecon.addPosRule(pos, rule)
|
||||||
local rulenames = mesecon.rules_link_rule_all(pos, rule)
|
local rulenames = mesecon.rules_link_rule_all(pos, rule)
|
||||||
for _, rulename in ipairs(rulenames) do
|
for _, rulename in ipairs(rulenames) do
|
||||||
mesecon.turnon(np, rulename)
|
mesecon.turnon(np, rulename)
|
||||||
@ -101,7 +101,7 @@ mesecon.queue:add_function("receptor_off", function (pos, rules)
|
|||||||
|
|
||||||
-- if area (any of the rule targets) is not loaded, keep trying and call this again later
|
-- if area (any of the rule targets) is not loaded, keep trying and call this again later
|
||||||
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
||||||
local np = vector.add(pos, rule)
|
local np = mesecon.addPosRule(pos, rule)
|
||||||
if minetest.get_node_or_nil(np) == nil then
|
if minetest.get_node_or_nil(np) == nil then
|
||||||
mesecon.queue:add_action(pos, "receptor_off", {rules}, nil, rules)
|
mesecon.queue:add_action(pos, "receptor_off", {rules}, nil, rules)
|
||||||
return
|
return
|
||||||
@ -109,7 +109,7 @@ mesecon.queue:add_function("receptor_off", function (pos, rules)
|
|||||||
end
|
end
|
||||||
|
|
||||||
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
||||||
local np = vector.add(pos, rule)
|
local np = mesecon.addPosRule(pos, rule)
|
||||||
local rulenames = mesecon.rules_link_rule_all(pos, rule)
|
local rulenames = mesecon.rules_link_rule_all(pos, rule)
|
||||||
for _, rulename in ipairs(rulenames) do
|
for _, rulename in ipairs(rulenames) do
|
||||||
if not mesecon.connected_to_receptor(np, mesecon.invertRule(rule)) then
|
if not mesecon.connected_to_receptor(np, mesecon.invertRule(rule)) then
|
||||||
@ -126,7 +126,7 @@ function mesecon.receptor_off(pos, rules)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
minetest.log("action", "[OK] Mesecons")
|
print("[OK] Mesecons")
|
||||||
|
|
||||||
-- Deprecated stuff
|
-- Deprecated stuff
|
||||||
-- To be removed in future releases
|
-- To be removed in future releases
|
||||||
|
193
mesecons/internal.lua
Executable file → Normal file
@ -76,9 +76,7 @@ function mesecon.get_conductor(nodename)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.get_any_outputrules(node)
|
function mesecon.get_any_outputrules (node)
|
||||||
if not node then return nil end
|
|
||||||
|
|
||||||
if mesecon.is_conductor(node.name) then
|
if mesecon.is_conductor(node.name) then
|
||||||
return mesecon.conductor_get_rules(node)
|
return mesecon.conductor_get_rules(node)
|
||||||
elseif mesecon.is_receptor(node.name) then
|
elseif mesecon.is_receptor(node.name) then
|
||||||
@ -86,9 +84,7 @@ function mesecon.get_any_outputrules(node)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.get_any_inputrules(node)
|
function mesecon.get_any_inputrules (node)
|
||||||
if not node then return nil end
|
|
||||||
|
|
||||||
if mesecon.is_conductor(node.name) then
|
if mesecon.is_conductor(node.name) then
|
||||||
return mesecon.conductor_get_rules(node)
|
return mesecon.conductor_get_rules(node)
|
||||||
elseif mesecon.is_effector(node.name) then
|
elseif mesecon.is_effector(node.name) then
|
||||||
@ -96,7 +92,7 @@ function mesecon.get_any_inputrules(node)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.get_any_rules(node)
|
function mesecon.get_any_rules (node)
|
||||||
return mesecon.mergetable(mesecon.get_any_inputrules(node) or {},
|
return mesecon.mergetable(mesecon.get_any_inputrules(node) or {},
|
||||||
mesecon.get_any_outputrules(node) or {})
|
mesecon.get_any_outputrules(node) or {})
|
||||||
end
|
end
|
||||||
@ -186,9 +182,7 @@ end
|
|||||||
|
|
||||||
-- Activation:
|
-- Activation:
|
||||||
mesecon.queue:add_function("activate", function (pos, rulename)
|
mesecon.queue:add_function("activate", function (pos, rulename)
|
||||||
local node = mesecon.get_node_force(pos)
|
local node = minetest.get_node(pos)
|
||||||
if not node then return end
|
|
||||||
|
|
||||||
local effector = mesecon.get_effector(node.name)
|
local effector = mesecon.get_effector(node.name)
|
||||||
|
|
||||||
if effector and effector.action_on then
|
if effector and effector.action_on then
|
||||||
@ -209,9 +203,7 @@ end
|
|||||||
|
|
||||||
-- Deactivation
|
-- Deactivation
|
||||||
mesecon.queue:add_function("deactivate", function (pos, rulename)
|
mesecon.queue:add_function("deactivate", function (pos, rulename)
|
||||||
local node = mesecon.get_node_force(pos)
|
local node = minetest.get_node(pos)
|
||||||
if not node then return end
|
|
||||||
|
|
||||||
local effector = mesecon.get_effector(node.name)
|
local effector = mesecon.get_effector(node.name)
|
||||||
|
|
||||||
if effector and effector.action_off then
|
if effector and effector.action_off then
|
||||||
@ -232,9 +224,7 @@ end
|
|||||||
|
|
||||||
-- Change
|
-- Change
|
||||||
mesecon.queue:add_function("change", function (pos, rulename, changetype)
|
mesecon.queue:add_function("change", function (pos, rulename, changetype)
|
||||||
local node = mesecon.get_node_force(pos)
|
local node = minetest.get_node(pos)
|
||||||
if not node then return end
|
|
||||||
|
|
||||||
local effector = mesecon.get_effector(node.name)
|
local effector = mesecon.get_effector(node.name)
|
||||||
|
|
||||||
if effector and effector.action_change then
|
if effector and effector.action_change then
|
||||||
@ -259,8 +249,6 @@ end
|
|||||||
-- Conductors
|
-- Conductors
|
||||||
|
|
||||||
function mesecon.is_conductor_on(node, rulename)
|
function mesecon.is_conductor_on(node, rulename)
|
||||||
if not node then return false end
|
|
||||||
|
|
||||||
local conductor = mesecon.get_conductor(node.name)
|
local conductor = mesecon.get_conductor(node.name)
|
||||||
if conductor then
|
if conductor then
|
||||||
if conductor.state then
|
if conductor.state then
|
||||||
@ -275,13 +263,10 @@ function mesecon.is_conductor_on(node, rulename)
|
|||||||
return mesecon.get_bit(binstate, bit)
|
return mesecon.get_bit(binstate, bit)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.is_conductor_off(node, rulename)
|
function mesecon.is_conductor_off(node, rulename)
|
||||||
if not node then return false end
|
|
||||||
|
|
||||||
local conductor = mesecon.get_conductor(node.name)
|
local conductor = mesecon.get_conductor(node.name)
|
||||||
if conductor then
|
if conductor then
|
||||||
if conductor.state then
|
if conductor.state then
|
||||||
@ -296,7 +281,6 @@ function mesecon.is_conductor_off(node, rulename)
|
|||||||
return not mesecon.get_bit(binstate, bit)
|
return not mesecon.get_bit(binstate, bit)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -356,16 +340,16 @@ end
|
|||||||
-- some more general high-level stuff
|
-- some more general high-level stuff
|
||||||
|
|
||||||
function mesecon.is_power_on(pos, rulename)
|
function mesecon.is_power_on(pos, rulename)
|
||||||
local node = mesecon.get_node_force(pos)
|
local node = minetest.get_node(pos)
|
||||||
if node and (mesecon.is_conductor_on(node, rulename) or mesecon.is_receptor_on(node.name)) then
|
if mesecon.is_conductor_on(node, rulename) or mesecon.is_receptor_on(node.name) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.is_power_off(pos, rulename)
|
function mesecon.is_power_off(pos, rulename)
|
||||||
local node = mesecon.get_node_force(pos)
|
local node = minetest.get_node(pos)
|
||||||
if node and (mesecon.is_conductor_off(node, rulename) or mesecon.is_receptor_off(node.name)) then
|
if mesecon.is_conductor_off(node, rulename) or mesecon.is_receptor_off(node.name) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@ -377,45 +361,31 @@ function mesecon.turnon(pos, link)
|
|||||||
local depth = 1
|
local depth = 1
|
||||||
while frontiers[depth] do
|
while frontiers[depth] do
|
||||||
local f = frontiers[depth]
|
local f = frontiers[depth]
|
||||||
local node = mesecon.get_node_force(f.pos)
|
local node = minetest.get_node_or_nil(f.pos)
|
||||||
|
|
||||||
-- area not loaded, postpone action
|
-- area not loaded, postpone action
|
||||||
if not node then
|
if not node then
|
||||||
mesecon.queue:add_action(f.pos, "turnon", {f.link}, nil, true)
|
mesecon.queue:add_action(f.pos, "turnon", {link}, nil, true)
|
||||||
elseif mesecon.is_conductor_off(node, f.link) then
|
elseif mesecon.is_conductor_off(node, f.link) then
|
||||||
local rules = mesecon.conductor_get_rules(node)
|
local rules = mesecon.conductor_get_rules(node)
|
||||||
|
|
||||||
-- Success: If false, at least one neighboring node is unloaded,
|
minetest.swap_node(f.pos, {name = mesecon.get_conductor_on(node, f.link),
|
||||||
-- postpone turning on action
|
param2 = node.param2})
|
||||||
local success = true
|
|
||||||
local neighborlinks = {}
|
|
||||||
|
|
||||||
-- call turnon on neighbors
|
-- call turnon on neighbors: normal rules
|
||||||
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
|
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
|
||||||
local np = vector.add(f.pos, r)
|
local np = mesecon.addPosRule(f.pos, r)
|
||||||
|
|
||||||
-- Neighboring node not loaded, postpone turning on current node
|
-- area not loaded, postpone action
|
||||||
-- since we can't even know if neighboring node has matching rules
|
if not minetest.get_node_or_nil(np) then
|
||||||
if not mesecon.get_node_force(np) then
|
mesecon.queue:add_action(np, "turnon", {rulename},
|
||||||
success = false
|
nil, true)
|
||||||
break
|
|
||||||
else
|
else
|
||||||
neighborlinks[minetest.hash_node_position(np)] = mesecon.rules_link_rule_all(f.pos, r)
|
local links = mesecon.rules_link_rule_all(f.pos, r)
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if success then
|
|
||||||
minetest.swap_node(f.pos, {name = mesecon.get_conductor_on(node, f.link),
|
|
||||||
param2 = node.param2})
|
|
||||||
|
|
||||||
for npos, links in pairs(neighborlinks) do
|
|
||||||
-- links = all links to node, l = each single link
|
|
||||||
for _, l in ipairs(links) do
|
for _, l in ipairs(links) do
|
||||||
table.insert(frontiers, {pos = minetest.get_position_from_hash(npos), link = l})
|
table.insert(frontiers, {pos = np, link = l})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
|
||||||
mesecon.queue:add_action(f.pos, "turnon", {f.link}, nil, true)
|
|
||||||
end
|
end
|
||||||
elseif mesecon.is_effector(node.name) then
|
elseif mesecon.is_effector(node.name) then
|
||||||
mesecon.changesignal(f.pos, node, f.link, mesecon.state.on, depth)
|
mesecon.changesignal(f.pos, node, f.link, mesecon.state.on, depth)
|
||||||
@ -427,7 +397,7 @@ function mesecon.turnon(pos, link)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon.queue:add_function("turnon", function(pos, rulename, recdepth)
|
mesecon.queue:add_function("turnon", function (pos, rulename, recdepth)
|
||||||
mesecon.turnon(pos, rulename, recdepth)
|
mesecon.turnon(pos, rulename, recdepth)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -437,45 +407,31 @@ function mesecon.turnoff(pos, link)
|
|||||||
local depth = 1
|
local depth = 1
|
||||||
while frontiers[depth] do
|
while frontiers[depth] do
|
||||||
local f = frontiers[depth]
|
local f = frontiers[depth]
|
||||||
local node = mesecon.get_node_force(f.pos)
|
local node = minetest.get_node_or_nil(f.pos)
|
||||||
|
|
||||||
-- area not loaded, postpone action
|
-- area not loaded, postpone action
|
||||||
if not node then
|
if not node then
|
||||||
mesecon.queue:add_action(f.pos, "turnoff", {f.link}, nil, true)
|
mesecon.queue:add_action(f.pos, "turnoff", {link}, nil, true)
|
||||||
elseif mesecon.is_conductor_on(node, f.link) then
|
elseif mesecon.is_conductor_on(node, f.link) then
|
||||||
local rules = mesecon.conductor_get_rules(node)
|
local rules = mesecon.conductor_get_rules(node)
|
||||||
|
|
||||||
-- Success: If false, at least one neighboring node is unloaded,
|
minetest.swap_node(f.pos, {name = mesecon.get_conductor_off(node, f.link),
|
||||||
-- postpone turning on action
|
param2 = node.param2})
|
||||||
local success = true
|
|
||||||
local neighborlinks = {}
|
|
||||||
|
|
||||||
-- call turnoff on neighbors
|
-- call turnoff on neighbors: normal rules
|
||||||
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
|
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
|
||||||
local np = vector.add(f.pos, r)
|
local np = mesecon.addPosRule(f.pos, r)
|
||||||
|
|
||||||
-- Neighboring node not loaded, postpone turning off current node
|
-- area not loaded, postpone action
|
||||||
-- since we can't even know if neighboring node has matching rules
|
if not minetest.get_node_or_nil(np) then
|
||||||
if not mesecon.get_node_force(np) then
|
mesecon.queue:add_action(np, "turnoff", {rulename},
|
||||||
success = false
|
nil, true)
|
||||||
break
|
|
||||||
else
|
else
|
||||||
neighborlinks[minetest.hash_node_position(np)] = mesecon.rules_link_rule_all(f.pos, r)
|
local links = mesecon.rules_link_rule_all(f.pos, r)
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if success then
|
|
||||||
minetest.swap_node(f.pos, {name = mesecon.get_conductor_off(node, f.link),
|
|
||||||
param2 = node.param2})
|
|
||||||
|
|
||||||
for npos, links in pairs(neighborlinks) do
|
|
||||||
-- links = all links to node, l = each single link
|
|
||||||
for _, l in ipairs(links) do
|
for _, l in ipairs(links) do
|
||||||
table.insert(frontiers, {pos = minetest.get_position_from_hash(npos), link = l})
|
table.insert(frontiers, {pos = np, link = l})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
|
||||||
mesecon.queue:add_action(f.pos, "turnoff", {f.link}, nil, true)
|
|
||||||
end
|
end
|
||||||
elseif mesecon.is_effector(node.name) then
|
elseif mesecon.is_effector(node.name) then
|
||||||
mesecon.changesignal(f.pos, node, f.link, mesecon.state.off, depth)
|
mesecon.changesignal(f.pos, node, f.link, mesecon.state.off, depth)
|
||||||
@ -487,14 +443,13 @@ function mesecon.turnoff(pos, link)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon.queue:add_function("turnoff", function(pos, rulename, recdepth)
|
mesecon.queue:add_function("turnoff", function (pos, rulename, recdepth)
|
||||||
mesecon.turnoff(pos, rulename, recdepth)
|
mesecon.turnoff(pos, rulename, recdepth)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
function mesecon.connected_to_receptor(pos, link)
|
function mesecon.connected_to_receptor(pos, link)
|
||||||
local node = mesecon.get_node_force(pos)
|
local node = minetest.get_node(pos)
|
||||||
if not node then return false end
|
|
||||||
|
|
||||||
-- Check if conductors around are connected
|
-- Check if conductors around are connected
|
||||||
local rules = mesecon.get_any_inputrules(node)
|
local rules = mesecon.get_any_inputrules(node)
|
||||||
@ -503,7 +458,7 @@ function mesecon.connected_to_receptor(pos, link)
|
|||||||
for _, rule in ipairs(mesecon.rule2meta(link, rules)) do
|
for _, rule in ipairs(mesecon.rule2meta(link, rules)) do
|
||||||
local links = mesecon.rules_link_rule_all_inverted(pos, rule)
|
local links = mesecon.rules_link_rule_all_inverted(pos, rule)
|
||||||
for _, l in ipairs(links) do
|
for _, l in ipairs(links) do
|
||||||
local np = vector.add(pos, l)
|
local np = mesecon.addPosRule(pos, l)
|
||||||
if mesecon.find_receptor_on(np, mesecon.invertRule(l)) then
|
if mesecon.find_receptor_on(np, mesecon.invertRule(l)) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -521,7 +476,7 @@ function mesecon.find_receptor_on(pos, link)
|
|||||||
local depth = 1
|
local depth = 1
|
||||||
while frontiers[depth] do
|
while frontiers[depth] do
|
||||||
local f = frontiers[depth]
|
local f = frontiers[depth]
|
||||||
local node = mesecon.get_node_force(f.pos)
|
local node = minetest.get_node_or_nil(f.pos)
|
||||||
|
|
||||||
if not node then return false end
|
if not node then return false end
|
||||||
if mesecon.is_receptor_on(node.name) then return true end
|
if mesecon.is_receptor_on(node.name) then return true end
|
||||||
@ -530,7 +485,7 @@ function mesecon.find_receptor_on(pos, link)
|
|||||||
|
|
||||||
-- call turnoff on neighbors: normal rules
|
-- call turnoff on neighbors: normal rules
|
||||||
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
|
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
|
||||||
local np = vector.add(f.pos, r)
|
local np = mesecon.addPosRule(f.pos, r)
|
||||||
|
|
||||||
local links = mesecon.rules_link_rule_all_inverted(f.pos, r)
|
local links = mesecon.rules_link_rule_all_inverted(f.pos, r)
|
||||||
for _, l in ipairs(links) do
|
for _, l in ipairs(links) do
|
||||||
@ -541,68 +496,65 @@ function mesecon.find_receptor_on(pos, link)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
depth = depth + 1
|
depth = depth + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.rules_link(output, input, dug_outputrules) --output/input are positions (outputrules optional, used if node has been dug), second return value: the name of the affected input rule
|
function mesecon.rules_link(output, input, dug_outputrules) --output/input are positions (outputrules optional, used if node has been dug), second return value: the name of the affected input rule
|
||||||
local outputnode = mesecon.get_node_force(output)
|
local outputnode = minetest.get_node(output)
|
||||||
local inputnode = mesecon.get_node_force(input)
|
local inputnode = minetest.get_node(input)
|
||||||
|
local outputrules = dug_outputrules or mesecon.get_any_outputrules (outputnode)
|
||||||
local outputrules = dug_outputrules or mesecon.get_any_outputrules(outputnode)
|
local inputrules = mesecon.get_any_inputrules (inputnode)
|
||||||
local inputrules = mesecon.get_any_inputrules(inputnode)
|
|
||||||
if not outputrules or not inputrules then
|
if not outputrules or not inputrules then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, outputrule in ipairs(mesecon.flattenrules(outputrules)) do
|
for _, outputrule in ipairs(mesecon.flattenrules(outputrules)) do
|
||||||
-- Check if output sends to input
|
-- Check if output sends to input
|
||||||
if vector.equals(vector.add(output, outputrule), input) then
|
if mesecon.cmpPos(mesecon.addPosRule(output, outputrule), input) then
|
||||||
for _, inputrule in ipairs(mesecon.flattenrules(inputrules)) do
|
for _, inputrule in ipairs(mesecon.flattenrules(inputrules)) do
|
||||||
-- Check if input accepts from output
|
-- Check if input accepts from output
|
||||||
if vector.equals(vector.add(input, inputrule), output) then
|
if mesecon.cmpPos(mesecon.addPosRule(input, inputrule), output) then
|
||||||
return true, inputrule
|
return true, inputrule
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.rules_link_rule_all(output, rule)
|
function mesecon.rules_link_rule_all(output, rule)
|
||||||
local input = vector.add(output, rule)
|
local input = mesecon.addPosRule(output, rule)
|
||||||
local inputnode = mesecon.get_node_force(input)
|
local inputnode = minetest.get_node(input)
|
||||||
local inputrules = mesecon.get_any_inputrules(inputnode)
|
local inputrules = mesecon.get_any_inputrules (inputnode)
|
||||||
if not inputrules then
|
if not inputrules then
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
local rules = {}
|
local rules = {}
|
||||||
|
|
||||||
for _, inputrule in ipairs(mesecon.flattenrules(inputrules)) do
|
for _, inputrule in ipairs(mesecon.flattenrules(inputrules)) do
|
||||||
-- Check if input accepts from output
|
-- Check if input accepts from output
|
||||||
if vector.equals(vector.add(input, inputrule), output) then
|
if mesecon.cmpPos(mesecon.addPosRule(input, inputrule), output) then
|
||||||
table.insert(rules, inputrule)
|
table.insert(rules, inputrule)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return rules
|
return rules
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.rules_link_rule_all_inverted(input, rule)
|
function mesecon.rules_link_rule_all_inverted(input, rule)
|
||||||
--local irule = mesecon.invertRule(rule)
|
--local irule = mesecon.invertRule(rule)
|
||||||
local output = vector.add(input, rule)
|
local output = mesecon.addPosRule(input, rule)
|
||||||
local outputnode = mesecon.get_node_force(output)
|
local outputnode = minetest.get_node(output)
|
||||||
local outputrules = mesecon.get_any_outputrules(outputnode)
|
local outputrules = mesecon.get_any_outputrules (outputnode)
|
||||||
if not outputrules then
|
if not outputrules then
|
||||||
return {}
|
return {}
|
||||||
end
|
end
|
||||||
local rules = {}
|
local rules = {}
|
||||||
|
|
||||||
for _, outputrule in ipairs(mesecon.flattenrules(outputrules)) do
|
for _, outputrule in ipairs(mesecon.flattenrules(outputrules)) do
|
||||||
if vector.equals(vector.add(output, outputrule), input) then
|
if mesecon.cmpPos(mesecon.addPosRule(output, outputrule), input) then
|
||||||
table.insert(rules, mesecon.invertRule(outputrule))
|
table.insert(rules, mesecon.invertRule(outputrule))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -614,7 +566,7 @@ function mesecon.rules_link_anydir(pos1, pos2)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.is_powered(pos, rule)
|
function mesecon.is_powered(pos, rule)
|
||||||
local node = mesecon.get_node_force(pos)
|
local node = minetest.get_node(pos)
|
||||||
local rules = mesecon.get_any_inputrules(node)
|
local rules = mesecon.get_any_inputrules(node)
|
||||||
if not rules then return false end
|
if not rules then return false end
|
||||||
|
|
||||||
@ -625,11 +577,10 @@ function mesecon.is_powered(pos, rule)
|
|||||||
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
||||||
local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule)
|
local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule)
|
||||||
for _, rname in ipairs(rulenames) do
|
for _, rname in ipairs(rulenames) do
|
||||||
local np = vector.add(pos, rname)
|
local np = mesecon.addPosRule(pos, rname)
|
||||||
local nn = mesecon.get_node_force(np)
|
local nn = minetest.get_node(np)
|
||||||
|
if (mesecon.is_conductor_on (nn, mesecon.invertRule(rname))
|
||||||
if (mesecon.is_conductor_on(nn, mesecon.invertRule(rname))
|
or mesecon.is_receptor_on (nn.name)) then
|
||||||
or mesecon.is_receptor_on(nn.name)) then
|
|
||||||
table.insert(sourcepos, np)
|
table.insert(sourcepos, np)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -637,8 +588,8 @@ function mesecon.is_powered(pos, rule)
|
|||||||
else
|
else
|
||||||
local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule)
|
local rulenames = mesecon.rules_link_rule_all_inverted(pos, rule)
|
||||||
for _, rname in ipairs(rulenames) do
|
for _, rname in ipairs(rulenames) do
|
||||||
local np = vector.add(pos, rname)
|
local np = mesecon.addPosRule(pos, rname)
|
||||||
local nn = mesecon.get_node_force(np)
|
local nn = minetest.get_node(np)
|
||||||
if (mesecon.is_conductor_on (nn, mesecon.invertRule(rname))
|
if (mesecon.is_conductor_on (nn, mesecon.invertRule(rname))
|
||||||
or mesecon.is_receptor_on (nn.name)) then
|
or mesecon.is_receptor_on (nn.name)) then
|
||||||
table.insert(sourcepos, np)
|
table.insert(sourcepos, np)
|
||||||
@ -656,8 +607,8 @@ function mesecon.rotate_rules_right(rules)
|
|||||||
local nr = {}
|
local nr = {}
|
||||||
for i, rule in ipairs(rules) do
|
for i, rule in ipairs(rules) do
|
||||||
table.insert(nr, {
|
table.insert(nr, {
|
||||||
x = -rule.z,
|
x = -rule.z,
|
||||||
y = rule.y,
|
y = rule.y,
|
||||||
z = rule.x,
|
z = rule.x,
|
||||||
name = rule.name})
|
name = rule.name})
|
||||||
end
|
end
|
||||||
@ -668,8 +619,8 @@ function mesecon.rotate_rules_left(rules)
|
|||||||
local nr = {}
|
local nr = {}
|
||||||
for i, rule in ipairs(rules) do
|
for i, rule in ipairs(rules) do
|
||||||
table.insert(nr, {
|
table.insert(nr, {
|
||||||
x = rule.z,
|
x = rule.z,
|
||||||
y = rule.y,
|
y = rule.y,
|
||||||
z = -rule.x,
|
z = -rule.x,
|
||||||
name = rule.name})
|
name = rule.name})
|
||||||
end
|
end
|
||||||
@ -680,8 +631,8 @@ function mesecon.rotate_rules_down(rules)
|
|||||||
local nr = {}
|
local nr = {}
|
||||||
for i, rule in ipairs(rules) do
|
for i, rule in ipairs(rules) do
|
||||||
table.insert(nr, {
|
table.insert(nr, {
|
||||||
x = -rule.y,
|
x = -rule.y,
|
||||||
y = rule.x,
|
y = rule.x,
|
||||||
z = rule.z,
|
z = rule.z,
|
||||||
name = rule.name})
|
name = rule.name})
|
||||||
end
|
end
|
||||||
@ -692,8 +643,8 @@ function mesecon.rotate_rules_up(rules)
|
|||||||
local nr = {}
|
local nr = {}
|
||||||
for i, rule in ipairs(rules) do
|
for i, rule in ipairs(rules) do
|
||||||
table.insert(nr, {
|
table.insert(nr, {
|
||||||
x = rule.y,
|
x = rule.y,
|
||||||
y = -rule.x,
|
y = -rule.x,
|
||||||
z = rule.z,
|
z = rule.z,
|
||||||
name = rule.name})
|
name = rule.name})
|
||||||
end
|
end
|
||||||
|
0
mesecons/legacy.lua
Executable file → Normal file
6
mesecons/oldwires.lua
Executable file → Normal file
@ -10,7 +10,7 @@ minetest.register_node("mesecons:mesecon_off", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5},
|
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5},
|
||||||
},
|
},
|
||||||
groups = {dig_immediate=2, mesecon=1, mesecon_conductor_craftable=1}, --MFF
|
groups = {dig_immediate=3, mesecon=1, mesecon_conductor_craftable=1},
|
||||||
description="Mesecons",
|
description="Mesecons",
|
||||||
mesecons = {conductor={
|
mesecons = {conductor={
|
||||||
state = mesecon.state.off,
|
state = mesecon.state.off,
|
||||||
@ -28,9 +28,9 @@ minetest.register_node("mesecons:mesecon_on", {
|
|||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5},
|
fixed = {-0.5, -0.5, -0.5, 0.5, -0.45, 0.5},
|
||||||
},
|
},
|
||||||
groups = {dig_immediate=2, not_in_creaive_inventory=1, mesecon=1}, --MFF
|
groups = {dig_immediate=3, not_in_creaive_inventory=1, mesecon=1},
|
||||||
drop = "mesecons:mesecon_off 1",
|
drop = "mesecons:mesecon_off 1",
|
||||||
light_source = default.LIGHT_MAX-11,
|
light_source = LIGHT_MAX-11,
|
||||||
mesecons = {conductor={
|
mesecons = {conductor={
|
||||||
state = mesecon.state.on,
|
state = mesecon.state.on,
|
||||||
offstate = "mesecons:mesecon_off"
|
offstate = "mesecons:mesecon_off"
|
||||||
|
12
mesecons/presets.lua
Executable file → Normal file
@ -21,7 +21,7 @@ mesecon.rules.buttonlike =
|
|||||||
{{x = 1, y = 0, z = 0},
|
{{x = 1, y = 0, z = 0},
|
||||||
{x = 1, y = 1, z = 0},
|
{x = 1, y = 1, z = 0},
|
||||||
{x = 1, y =-1, z = 0},
|
{x = 1, y =-1, z = 0},
|
||||||
{x = 1, y =-1, z = 1},
|
{x = 1, y =-1, z = 1},
|
||||||
{x = 1, y =-1, z =-1},
|
{x = 1, y =-1, z =-1},
|
||||||
{x = 2, y = 0, z = 0}}
|
{x = 2, y = 0, z = 0}}
|
||||||
|
|
||||||
@ -30,15 +30,7 @@ mesecon.rules.flat =
|
|||||||
{x =-1, y = 0, z = 0},
|
{x =-1, y = 0, z = 0},
|
||||||
{x = 0, y = 0, z = 1},
|
{x = 0, y = 0, z = 1},
|
||||||
{x = 0, y = 0, z =-1}}
|
{x = 0, y = 0, z =-1}}
|
||||||
|
|
||||||
mesecon.rules.alldirs =
|
|
||||||
{{x= 1, y= 0, z= 0},
|
|
||||||
{x=-1, y= 0, z= 0},
|
|
||||||
{x= 0, y= 1, z= 0},
|
|
||||||
{x= 0, y=-1, z= 0},
|
|
||||||
{x= 0, y= 0, z= 1},
|
|
||||||
{x= 0, y= 0, z=-1}}
|
|
||||||
|
|
||||||
mesecon.rules.buttonlike_get = function(node)
|
mesecon.rules.buttonlike_get = function(node)
|
||||||
local rules = mesecon.rules.buttonlike
|
local rules = mesecon.rules.buttonlike
|
||||||
if node.param2 == 2 then
|
if node.param2 == 2 then
|
||||||
|
14
mesecons/services.lua
Executable file → Normal file
@ -16,7 +16,7 @@ mesecon.on_placenode = function (pos, node)
|
|||||||
-- also call receptor_on if itself is powered already, so that neighboring
|
-- also call receptor_on if itself is powered already, so that neighboring
|
||||||
-- conductors will be activated (when pushing an on-conductor with a piston)
|
-- conductors will be activated (when pushing an on-conductor with a piston)
|
||||||
for _, s in ipairs(sources) do
|
for _, s in ipairs(sources) do
|
||||||
local rule = vector.subtract(pos, s)
|
local rule = {x = pos.x - s.x, y = pos.y - s.y, z = pos.z - s.z}
|
||||||
mesecon.turnon(pos, rule)
|
mesecon.turnon(pos, rule)
|
||||||
end
|
end
|
||||||
--mesecon.receptor_on (pos, mesecon.conductor_get_rules(node))
|
--mesecon.receptor_on (pos, mesecon.conductor_get_rules(node))
|
||||||
@ -28,13 +28,11 @@ mesecon.on_placenode = function (pos, node)
|
|||||||
-- Effectors: Send changesignal and activate or deactivate
|
-- Effectors: Send changesignal and activate or deactivate
|
||||||
if mesecon.is_effector(node.name) then
|
if mesecon.is_effector(node.name) then
|
||||||
local powered_rules = {}
|
local powered_rules = {}
|
||||||
local unpowered_rules = {}
|
|
||||||
|
|
||||||
-- for each input rule, check if powered
|
-- for each input rule, check if powered
|
||||||
for _, r in ipairs(mesecon.effector_get_rules(node)) do
|
for _, r in ipairs(mesecon.effector_get_rules(node)) do
|
||||||
local powered = mesecon.is_powered(pos, r)
|
local powered = mesecon.is_powered(pos, r)
|
||||||
if powered then table.insert(powered_rules, r)
|
if powered then table.insert(powered_rules, r) end
|
||||||
else table.insert(unpowered_rules, r) end
|
|
||||||
|
|
||||||
local state = powered and mesecon.state.on or mesecon.state.off
|
local state = powered and mesecon.state.on or mesecon.state.off
|
||||||
mesecon.changesignal(pos, node, r, state, 1)
|
mesecon.changesignal(pos, node, r, state, 1)
|
||||||
@ -44,10 +42,6 @@ mesecon.on_placenode = function (pos, node)
|
|||||||
for _, r in ipairs(powered_rules) do
|
for _, r in ipairs(powered_rules) do
|
||||||
mesecon.activate(pos, node, r, 1)
|
mesecon.activate(pos, node, r, 1)
|
||||||
end
|
end
|
||||||
else
|
|
||||||
for _, r in ipairs(unpowered_rules) do
|
|
||||||
mesecon.deactivate(pos, node, r, 1)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -87,6 +81,10 @@ end
|
|||||||
|
|
||||||
|
|
||||||
mesecon.queue:add_function("cooldown", function (pos)
|
mesecon.queue:add_function("cooldown", function (pos)
|
||||||
|
if minetest.get_item_group(minetest.get_node(pos).name, "overheat") == 0 then
|
||||||
|
return -- node has been moved, this one does not use overheating - ignore
|
||||||
|
end
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local heat = meta:get_int("heat")
|
local heat = meta:get_int("heat")
|
||||||
|
|
||||||
|
9
mesecons/settings.lua
Executable file → Normal file
@ -1,12 +1,7 @@
|
|||||||
-- SETTINGS
|
-- SETTINGS
|
||||||
function mesecon.setting(setting, default)
|
function mesecon.setting(setting, default)
|
||||||
if type(default) == "boolean" then
|
if type(default) == "bool" then
|
||||||
local read = minetest.setting_getbool("mesecon."..setting)
|
return minetest.setting_getbool("mesecon."..setting) or default
|
||||||
if read == nil then
|
|
||||||
return default
|
|
||||||
else
|
|
||||||
return read
|
|
||||||
end
|
|
||||||
elseif type(default) == "string" then
|
elseif type(default) == "string" then
|
||||||
return minetest.setting_get("mesecon."..setting) or default
|
return minetest.setting_get("mesecon."..setting) or default
|
||||||
elseif type(default) == "number" then
|
elseif type(default) == "number" then
|
||||||
|
BIN
mesecons/textures/jeija_fiber.png
Normal file
After Width: | Height: | Size: 592 B |
Before Width: | Height: | Size: 487 B After Width: | Height: | Size: 487 B |
BIN
mesecons/textures/jeija_mesecon_switch_off.png
Normal file
After Width: | Height: | Size: 598 B |
BIN
mesecons/textures/jeija_mesecon_switch_on.png
Normal file
After Width: | Height: | Size: 692 B |
BIN
mesecons/textures/jeija_mesecon_switch_side.png
Normal file
After Width: | Height: | Size: 553 B |
BIN
mesecons/textures/jeija_silicon.png
Normal file
After Width: | Height: | Size: 867 B |
BIN
mesecons/textures/mesecons_wire_inv.png
Executable file → Normal file
Before Width: | Height: | Size: 186 B After Width: | Height: | Size: 204 B |
BIN
mesecons/textures/mesecons_wire_off.png
Executable file → Normal file
Before Width: | Height: | Size: 378 B After Width: | Height: | Size: 465 B |
BIN
mesecons/textures/mesecons_wire_on.png
Executable file → Normal file
Before Width: | Height: | Size: 366 B After Width: | Height: | Size: 464 B |
92
mesecons/util.lua
Executable file → Normal file
@ -2,7 +2,7 @@ function mesecon.move_node(pos, newpos)
|
|||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local meta = minetest.get_meta(pos):to_table()
|
local meta = minetest.get_meta(pos):to_table()
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
minetest.set_node(newpos, node)
|
minetest.add_node(newpos, node)
|
||||||
minetest.get_meta(pos):from_table(meta)
|
minetest.get_meta(pos):from_table(meta)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ function mesecon.rule2bit(findrule, allrules)
|
|||||||
end
|
end
|
||||||
for m,metarule in ipairs( allrules) do
|
for m,metarule in ipairs( allrules) do
|
||||||
for _, rule in ipairs(metarule ) do
|
for _, rule in ipairs(metarule ) do
|
||||||
if vector.equals(findrule, rule) then
|
if mesecon.cmpPos(findrule, rule) then
|
||||||
return m
|
return m
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -69,7 +69,7 @@ function mesecon.rule2metaindex(findrule, allrules)
|
|||||||
|
|
||||||
for m, metarule in ipairs( allrules) do
|
for m, metarule in ipairs( allrules) do
|
||||||
for _, rule in ipairs(metarule ) do
|
for _, rule in ipairs(metarule ) do
|
||||||
if vector.equals(findrule, rule) then
|
if mesecon.cmpPos(findrule, rule) then
|
||||||
return m
|
return m
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -129,11 +129,19 @@ function mesecon.set_bit(binary,bit,value)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return binary
|
return binary
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.invertRule(r)
|
function mesecon.invertRule(r)
|
||||||
return vector.multiply(r, -1)
|
return {x = -r.x, y = -r.y, z = -r.z}
|
||||||
|
end
|
||||||
|
|
||||||
|
function mesecon.addPosRule(p, r)
|
||||||
|
return {x = p.x + r.x, y = p.y + r.y, z = p.z + r.z}
|
||||||
|
end
|
||||||
|
|
||||||
|
function mesecon.cmpPos(p1, p2)
|
||||||
|
return (p1.x == p2.x and p1.y == p2.y and p1.z == p2.z)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.tablecopy(table) -- deep table copy
|
function mesecon.tablecopy(table) -- deep table copy
|
||||||
@ -195,81 +203,9 @@ function mesecon.flipstate(pos, node)
|
|||||||
local newstate
|
local newstate
|
||||||
if (nodedef.__mesecon_state == "on") then newstate = "off" end
|
if (nodedef.__mesecon_state == "on") then newstate = "off" end
|
||||||
if (nodedef.__mesecon_state == "off") then newstate = "on" end
|
if (nodedef.__mesecon_state == "off") then newstate = "on" end
|
||||||
|
|
||||||
minetest.swap_node(pos, {name = nodedef.__mesecon_basename .. "_" .. newstate,
|
minetest.swap_node(pos, {name = nodedef.__mesecon_basename .. "_" .. newstate,
|
||||||
param2 = node.param2})
|
param2 = node.param2})
|
||||||
|
|
||||||
return newstate
|
return newstate
|
||||||
end
|
end
|
||||||
|
|
||||||
-- File writing / reading utilities
|
|
||||||
local wpath = minetest.get_worldpath()
|
|
||||||
function mesecon.file2table(filename)
|
|
||||||
local f = io.open(wpath..DIR_DELIM..filename, "r")
|
|
||||||
if f == nil then return {} end
|
|
||||||
local t = f:read("*all")
|
|
||||||
f:close()
|
|
||||||
if t == "" or t == nil then return {} end
|
|
||||||
return minetest.deserialize(t)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mesecon.table2file(filename, table)
|
|
||||||
local f = io.open(wpath..DIR_DELIM..filename, "w")
|
|
||||||
f:write(minetest.serialize(table))
|
|
||||||
f:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Forceloading: Force server to load area if node is nil
|
|
||||||
local BLOCKSIZE = 16
|
|
||||||
|
|
||||||
-- convert node position --> block hash
|
|
||||||
local function hash_blockpos(pos)
|
|
||||||
return minetest.hash_node_position({
|
|
||||||
x = math.floor(pos.x/BLOCKSIZE),
|
|
||||||
y = math.floor(pos.y/BLOCKSIZE),
|
|
||||||
z = math.floor(pos.z/BLOCKSIZE)
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- convert block hash --> node position
|
|
||||||
local function unhash_blockpos(hash)
|
|
||||||
return vector.multiply(minetest.get_position_from_hash(hash), BLOCKSIZE)
|
|
||||||
end
|
|
||||||
|
|
||||||
mesecon.forceloaded_blocks = {}
|
|
||||||
|
|
||||||
-- get node and force-load area
|
|
||||||
function mesecon.get_node_force(pos)
|
|
||||||
local hash = hash_blockpos(pos)
|
|
||||||
|
|
||||||
if mesecon.forceloaded_blocks[hash] == nil then
|
|
||||||
-- if no more forceload spaces are available, try again next time
|
|
||||||
if minetest.forceload_block(pos) then
|
|
||||||
mesecon.forceloaded_blocks[hash] = 0
|
|
||||||
end
|
|
||||||
else
|
|
||||||
mesecon.forceloaded_blocks[hash] = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
return minetest.get_node_or_nil(pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_globalstep(function (dtime)
|
|
||||||
for hash, time in pairs(mesecon.forceloaded_blocks) do
|
|
||||||
-- unload forceloaded blocks after 10 minutes without usage
|
|
||||||
if (time > mesecon.setting("forceload_timeout", 600)) then
|
|
||||||
minetest.forceload_free_block(unhash_blockpos(hash))
|
|
||||||
mesecon.forceloaded_blocks[hash] = nil
|
|
||||||
else
|
|
||||||
mesecon.forceloaded_blocks[hash] = time + dtime
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Store and read the forceloaded blocks to / from a file
|
|
||||||
-- so that those blocks are remembered when the game
|
|
||||||
-- is restarted
|
|
||||||
mesecon.forceloaded_blocks = mesecon.file2table("mesecon_forceloaded")
|
|
||||||
minetest.register_on_shutdown(function()
|
|
||||||
mesecon.table2file("mesecon_forceloaded", mesecon.forceloaded_blocks)
|
|
||||||
end)
|
|
||||||
|
14
mesecons/wires.lua
Executable file → Normal file
@ -22,7 +22,7 @@ local wire_getconnect = function (from_pos, self_pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
for _, r in ipairs(mesecon.flattenrules(rules)) do
|
for _, r in ipairs(mesecon.flattenrules(rules)) do
|
||||||
if (vector.equals(vector.add(self_pos, r), from_pos)) then
|
if (mesecon.cmpPos(mesecon.addPosRule(self_pos, r), from_pos)) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -35,7 +35,7 @@ local wire_updateconnect = function (pos)
|
|||||||
local connections = {}
|
local connections = {}
|
||||||
|
|
||||||
for _, r in ipairs(mesecon.rules.default) do
|
for _, r in ipairs(mesecon.rules.default) do
|
||||||
if wire_getconnect(pos, vector.add(pos, r)) then
|
if wire_getconnect(pos, mesecon.addPosRule(pos, r)) then
|
||||||
table.insert(connections, r)
|
table.insert(connections, r)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -83,7 +83,7 @@ local update_on_place_dig = function (pos, node)
|
|||||||
if (not rules) then return end
|
if (not rules) then return end
|
||||||
|
|
||||||
for _, r in ipairs(mesecon.flattenrules(rules)) do
|
for _, r in ipairs(mesecon.flattenrules(rules)) do
|
||||||
local np = vector.add(pos, r)
|
local np = mesecon.addPosRule(pos, r)
|
||||||
if minetest.registered_nodes[minetest.get_node(np).name]
|
if minetest.registered_nodes[minetest.get_node(np).name]
|
||||||
and minetest.registered_nodes[minetest.get_node(np).name].mesecon_wire then
|
and minetest.registered_nodes[minetest.get_node(np).name].mesecon_wire then
|
||||||
wire_updateconnect(np)
|
wire_updateconnect(np)
|
||||||
@ -135,7 +135,7 @@ nid_inc = function (nid)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- BUT: Skip impossible nodeids:
|
-- BUT: Skip impossible nodeids:
|
||||||
if ((nid[0] == 0 and nid[4] == 1) or (nid[1] == 0 and nid[5] == 1)
|
if ((nid[0] == 0 and nid[4] == 1) or (nid[1] == 0 and nid[5] == 1)
|
||||||
or (nid[2] == 0 and nid[6] == 1) or (nid[3] == 0 and nid[7] == 1)) then
|
or (nid[2] == 0 and nid[6] == 1) or (nid[3] == 0 and nid[7] == 1)) then
|
||||||
return nid_inc(nid)
|
return nid_inc(nid)
|
||||||
end
|
end
|
||||||
@ -197,9 +197,9 @@ register_wires = function()
|
|||||||
offstate = "mesecons:wire_"..nodeid.."_off"
|
offstate = "mesecons:wire_"..nodeid.."_off"
|
||||||
}}
|
}}
|
||||||
|
|
||||||
local groups_on = {dig_immediate = 2, mesecon_conductor_craftable = 1,
|
local groups_on = {dig_immediate = 3, mesecon_conductor_craftable = 1,
|
||||||
not_in_creative_inventory = 1} --MFF
|
not_in_creative_inventory = 1}
|
||||||
local groups_off = {dig_immediate = 2, mesecon_conductor_craftable = 1} --MFF
|
local groups_off = {dig_immediate = 3, mesecon_conductor_craftable = 1}
|
||||||
if nodeid ~= "00000000" then
|
if nodeid ~= "00000000" then
|
||||||
groups_off["not_in_creative_inventory"] = 1
|
groups_off["not_in_creative_inventory"] = 1
|
||||||
end
|
end
|
||||||
|
0
mesecons_alias/depends.txt
Executable file → Normal file
0
mesecons_alias/init.lua
Executable file → Normal file
0
mesecons_blinkyplant/depends.txt
Executable file → Normal file
@ -1 +0,0 @@
|
|||||||
The blinky plants toggles between on and off state every three seconds. Can be used to make clocks. Also works after having restarted the game.
|
|
Before Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 2.9 KiB |
24
mesecons_blinkyplant/init.lua
Executable file → Normal file
@ -10,25 +10,11 @@ local toggle_timer = function (pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local on_timer = function (pos)
|
local on_timer = function (pos)
|
||||||
-- DO NOT TOUCH OR.. THREATS! Thanks, MFF
|
local node = minetest.get_node(pos)
|
||||||
local activate = false
|
if(mesecon.flipstate(pos, node) == "on") then
|
||||||
for _, player in pairs(minetest.get_connected_players()) do
|
mesecon.receptor_on(pos)
|
||||||
local p = player:getpos()
|
else
|
||||||
local dist = ((p.x-pos.x)^2 + (p.y-pos.y)^2 + (p.z-pos.z)^2)^0.5
|
mesecon.receptor_off(pos)
|
||||||
if dist < 40 then
|
|
||||||
activate = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if activate then
|
|
||||||
local node = minetest.get_node(pos)
|
|
||||||
if(mesecon.flipstate(pos, node) == "on") then
|
|
||||||
mesecon.receptor_on(pos)
|
|
||||||
else
|
|
||||||
mesecon.receptor_off(pos)
|
|
||||||
end
|
|
||||||
-- Our modification stops there, thank you, @crabman77
|
|
||||||
end
|
end
|
||||||
toggle_timer(pos)
|
toggle_timer(pos)
|
||||||
end
|
end
|
||||||
|
BIN
mesecons_blinkyplant/textures/jeija_blinky_plant_off.png
Executable file → Normal file
Before Width: | Height: | Size: 370 B After Width: | Height: | Size: 454 B |
BIN
mesecons_blinkyplant/textures/jeija_blinky_plant_on.png
Executable file → Normal file
Before Width: | Height: | Size: 395 B After Width: | Height: | Size: 463 B |
0
mesecons_button/depends.txt
Executable file → Normal file
@ -1 +0,0 @@
|
|||||||
This receptor can be attached to walls. It turns on for 1 second if it's punched.
|
|
Before Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 7.8 KiB |
8
mesecons_button/init.lua
Executable file → Normal file
@ -15,7 +15,7 @@ end
|
|||||||
minetest.register_node("mesecons_button:button_off", {
|
minetest.register_node("mesecons_button:button_off", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {
|
tiles = {
|
||||||
"jeija_wall_button_sides.png",
|
"jeija_wall_button_sides.png",
|
||||||
"jeija_wall_button_sides.png",
|
"jeija_wall_button_sides.png",
|
||||||
"jeija_wall_button_sides.png",
|
"jeija_wall_button_sides.png",
|
||||||
"jeija_wall_button_sides.png",
|
"jeija_wall_button_sides.png",
|
||||||
@ -32,7 +32,7 @@ minetest.register_node("mesecons_button:button_off", {
|
|||||||
fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 }
|
fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 }
|
||||||
},
|
},
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {
|
fixed = {
|
||||||
{ -6/16, -6/16, 6/16, 6/16, 6/16, 8/16 }, -- the thin plate behind the button
|
{ -6/16, -6/16, 6/16, 6/16, 6/16, 8/16 }, -- the thin plate behind the button
|
||||||
{ -4/16, -2/16, 4/16, 4/16, 2/16, 6/16 } -- the button itself
|
{ -4/16, -2/16, 4/16, 4/16, 2/16, 6/16 } -- the button itself
|
||||||
@ -40,7 +40,7 @@ minetest.register_node("mesecons_button:button_off", {
|
|||||||
},
|
},
|
||||||
groups = {dig_immediate=2, mesecon_needs_receiver = 1},
|
groups = {dig_immediate=2, mesecon_needs_receiver = 1},
|
||||||
description = "Button",
|
description = "Button",
|
||||||
on_rightclick = function (pos, node)
|
on_punch = function (pos, node)
|
||||||
minetest.swap_node(pos, {name = "mesecons_button:button_on", param2=node.param2})
|
minetest.swap_node(pos, {name = "mesecons_button:button_on", param2=node.param2})
|
||||||
mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||||
minetest.sound_play("mesecons_button_push", {pos=pos})
|
minetest.sound_play("mesecons_button_push", {pos=pos})
|
||||||
@ -67,7 +67,7 @@ minetest.register_node("mesecons_button:button_on", {
|
|||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
legacy_wallmounted = true,
|
legacy_wallmounted = true,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
light_source = default.LIGHT_MAX-7,
|
light_source = LIGHT_MAX-7,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
selection_box = {
|
selection_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
|
0
mesecons_button/sounds/mesecons_button_pop.ogg
Executable file → Normal file
0
mesecons_button/sounds/mesecons_button_push.ogg
Executable file → Normal file
0
mesecons_button/textures/jeija_wall_button_off.png
Executable file → Normal file
Before Width: | Height: | Size: 411 B After Width: | Height: | Size: 411 B |
0
mesecons_button/textures/jeija_wall_button_on.png
Executable file → Normal file
Before Width: | Height: | Size: 449 B After Width: | Height: | Size: 449 B |
BIN
mesecons_button/textures/jeija_wall_button_sides.png
Executable file → Normal file
Before Width: | Height: | Size: 220 B After Width: | Height: | Size: 434 B |
0
mesecons_commandblock/depends.txt
Executable file → Normal file
@ -1 +0,0 @@
|
|||||||
There is no crafting recipe as this should only be available for server admins. Quite similar to the Minecraft counterpart. Executes server commands.
|
|
Before Width: | Height: | Size: 36 KiB |
17
mesecons_commandblock/init.lua
Executable file → Normal file
@ -43,7 +43,7 @@ minetest.register_chatcommand("hp", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
local function initialize_data(meta)
|
local function initialize_data(meta)
|
||||||
local commands = minetest.formspec_escape(meta:get_string("commands"))
|
local commands = meta:get_string("commands")
|
||||||
meta:set_string("formspec",
|
meta:set_string("formspec",
|
||||||
"invsize[9,5;]" ..
|
"invsize[9,5;]" ..
|
||||||
"textarea[0.5,0.5;8.5,4;commands;Commands;"..commands.."]" ..
|
"textarea[0.5,0.5;8.5,4;commands;Commands;"..commands.."]" ..
|
||||||
@ -93,22 +93,9 @@ local function receive_fields(pos, formname, fields, sender)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function resolve_commands(commands, pos)
|
local function resolve_commands(commands, pos)
|
||||||
local players = minetest.get_connected_players()
|
|
||||||
|
|
||||||
-- No players online: remove all commands containing
|
|
||||||
-- @nearest, @farthest and @random
|
|
||||||
if #players == 0 then
|
|
||||||
commands = commands:gsub("[^\r\n]+", function (line)
|
|
||||||
if line:find("@nearest") then return "" end
|
|
||||||
if line:find("@farthest") then return "" end
|
|
||||||
if line:find("@random") then return "" end
|
|
||||||
return line
|
|
||||||
end)
|
|
||||||
return commands
|
|
||||||
end
|
|
||||||
|
|
||||||
local nearest, farthest = nil, nil
|
local nearest, farthest = nil, nil
|
||||||
local min_distance, max_distance = math.huge, -1
|
local min_distance, max_distance = math.huge, -1
|
||||||
|
local players = minetest.get_connected_players()
|
||||||
for index, player in pairs(players) do
|
for index, player in pairs(players) do
|
||||||
local distance = vector.distance(pos, player:getpos())
|
local distance = vector.distance(pos, player:getpos())
|
||||||
if distance < min_distance then
|
if distance < min_distance then
|
||||||
|
BIN
mesecons_commandblock/textures/jeija_close_window.png
Executable file → Normal file
Before Width: | Height: | Size: 191 B After Width: | Height: | Size: 323 B |
BIN
mesecons_commandblock/textures/jeija_commandblock_off.png
Executable file → Normal file
Before Width: | Height: | Size: 183 B After Width: | Height: | Size: 282 B |
BIN
mesecons_commandblock/textures/jeija_commandblock_on.png
Executable file → Normal file
Before Width: | Height: | Size: 183 B After Width: | Height: | Size: 278 B |
0
mesecons_delayer/depends.txt
Executable file → Normal file
@ -1 +0,0 @@
|
|||||||
The delayer delays the signal from the input for a determined time. The time can be set by punching the delayer. Possible delays are: 0.1 seconds, 0.3 seconds, 0.5 seconds and 1 second. You may try to use it for creating songs with the noteblock.
|
|
Before Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 8.3 KiB |
2
mesecons_delayer/init.lua
Executable file → Normal file
@ -35,7 +35,7 @@ end
|
|||||||
|
|
||||||
for i = 1, 4 do
|
for i = 1, 4 do
|
||||||
local groups = {}
|
local groups = {}
|
||||||
if i == 1 then
|
if i == 1 then
|
||||||
groups = {bendy=2,snappy=1,dig_immediate=2}
|
groups = {bendy=2,snappy=1,dig_immediate=2}
|
||||||
else
|
else
|
||||||
groups = {bendy=2,snappy=1,dig_immediate=2, not_in_creative_inventory=1}
|
groups = {bendy=2,snappy=1,dig_immediate=2, not_in_creative_inventory=1}
|
||||||
|
BIN
mesecons_delayer/textures/mesecons_delayer_bottom.png
Executable file → Normal file
Before Width: | Height: | Size: 261 B After Width: | Height: | Size: 438 B |
BIN
mesecons_delayer/textures/mesecons_delayer_ends_off.png
Executable file → Normal file
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 226 B |
BIN
mesecons_delayer/textures/mesecons_delayer_ends_on.png
Executable file → Normal file
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 228 B |
BIN
mesecons_delayer/textures/mesecons_delayer_off_1.png
Executable file → Normal file
Before Width: | Height: | Size: 448 B After Width: | Height: | Size: 562 B |
BIN
mesecons_delayer/textures/mesecons_delayer_off_2.png
Executable file → Normal file
Before Width: | Height: | Size: 449 B After Width: | Height: | Size: 558 B |
BIN
mesecons_delayer/textures/mesecons_delayer_off_3.png
Executable file → Normal file
Before Width: | Height: | Size: 448 B After Width: | Height: | Size: 561 B |
BIN
mesecons_delayer/textures/mesecons_delayer_off_4.png
Executable file → Normal file
Before Width: | Height: | Size: 446 B After Width: | Height: | Size: 556 B |
BIN
mesecons_delayer/textures/mesecons_delayer_on_1.png
Executable file → Normal file
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 635 B |
BIN
mesecons_delayer/textures/mesecons_delayer_on_2.png
Executable file → Normal file
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 632 B |
BIN
mesecons_delayer/textures/mesecons_delayer_on_3.png
Executable file → Normal file
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 635 B |
BIN
mesecons_delayer/textures/mesecons_delayer_on_4.png
Executable file → Normal file
Before Width: | Height: | Size: 539 B After Width: | Height: | Size: 630 B |
BIN
mesecons_delayer/textures/mesecons_delayer_sides_off.png
Executable file → Normal file
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 229 B |
BIN
mesecons_delayer/textures/mesecons_delayer_sides_on.png
Executable file → Normal file
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 234 B |
0
mesecons_detector/depends.txt
Executable file → Normal file
@ -1,6 +0,0 @@
|
|||||||
The node detector is a receptor. It changes its state when either any node
|
|
||||||
or a specific node is detected. Right-click it to set a nodename to scan for.
|
|
||||||
It can also receive digiline signals. You can either send "GET" and it will
|
|
||||||
respond with the detected nodename or you can send any other string and it will
|
|
||||||
set this string as the node to scan for.
|
|
||||||
Nodenames must include the mod they reside in, so for instance default:dirt, not just dirt.
|
|
Before Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 9.8 KiB |
@ -1,3 +0,0 @@
|
|||||||
The object detector is a receptor. It changes its state when a player approaches.
|
|
||||||
Right-click it to set a name to scan for.
|
|
||||||
It can also receive digiline signals which are the name to scan for on the specified channel in the right-click menu.
|
|
Before Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 9.6 KiB |
202
mesecons_detector/init.lua
Executable file → Normal file
@ -4,17 +4,16 @@ local GET_COMMAND = "GET"
|
|||||||
-- Detects players in a certain radius
|
-- Detects players in a certain radius
|
||||||
-- The radius can be specified in mesecons/settings.lua
|
-- The radius can be specified in mesecons/settings.lua
|
||||||
|
|
||||||
-- The following file was modified to detect multiple players
|
|
||||||
local object_detector_make_formspec = function (pos)
|
local object_detector_make_formspec = function (pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec", "size[9,2.5]" ..
|
meta:set_string("formspec", "size[9,2.5]" ..
|
||||||
"field[0.3, 0;12,2;scanname;Name of player(s) to scan for (empty for any, separate with comma):;${scanname}]"..
|
"field[0.3, 0;9,2;scanname;Name of player to scan for (empty for any):;${scanname}]"..
|
||||||
"field[0.3,1.5;4 ,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]"..
|
"field[0.3,1.5;4,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]"..
|
||||||
"button_exit[7,0.75;2,3;;Save]")
|
"button_exit[7,0.75;2,3;;Save]")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function object_detector_on_receive_fields(pos, _, fields)
|
local object_detector_on_receive_fields = function(pos, formname, fields)
|
||||||
if not fields.scanname or not fields.digiline_channel then return end
|
if not fields.scanname or not fields.digiline_channel then return end;
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("scanname", fields.scanname)
|
meta:set_string("scanname", fields.scanname)
|
||||||
@ -23,27 +22,15 @@ local function object_detector_on_receive_fields(pos, _, fields)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- returns true if player was found, false if not
|
-- returns true if player was found, false if not
|
||||||
local function object_detector_scan(pos)
|
local object_detector_scan = function (pos)
|
||||||
local objs = minetest.get_objects_inside_radius(pos, mesecon.setting("detector_radius", 6))
|
local objs = minetest.get_objects_inside_radius(pos, mesecon.setting("detector_radius", 6))
|
||||||
for k, obj in pairs(objs) do
|
for k, obj in pairs(objs) do
|
||||||
local isname = obj:get_player_name() -- "" is returned if it is not a player; "" ~= nil!
|
local isname = obj:get_player_name() -- "" is returned if it is not a player; "" ~= nil!
|
||||||
local scanname = minetest.get_meta(pos):get_string("scanname"):gsub(' ', "")
|
local scanname = minetest.get_meta(pos):get_string("scanname")
|
||||||
if (scanname == "" and isname ~= "") then
|
if (isname == scanname and isname ~= "") or (isname ~= "" and scanname == "") then -- player with scanname found or not scanname specified
|
||||||
minetest.get_meta(pos):set_string("scanedname", "")
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
local founds = {}
|
|
||||||
for _, name in pairs(scanname:split(',')) do
|
|
||||||
if (isname == name and isname ~= "") then
|
|
||||||
table.insert(founds, isname)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if #founds > 0 then
|
|
||||||
minetest.get_meta(pos):set_string("scannedname", table.concat(founds, ','))
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
minetest.get_meta(pos):set_string("scanedname", "")
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -54,7 +41,7 @@ local object_detector_digiline = {
|
|||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local active_channel = meta:get_string("digiline_channel")
|
local active_channel = meta:get_string("digiline_channel")
|
||||||
if channel == active_channel then
|
if channel == active_channel then
|
||||||
meta:set_string("scanedname", msg)
|
meta:set_string("scanname", msg)
|
||||||
object_detector_make_formspec(pos)
|
object_detector_make_formspec(pos)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -102,44 +89,43 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm(
|
||||||
nodenames = {"mesecons_detector:object_detector_off"},
|
{nodenames = {"mesecons_detector:object_detector_off"},
|
||||||
interval = 1,
|
interval = 1.0,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node)
|
action = function(pos)
|
||||||
if not object_detector_scan(pos) then return end
|
if object_detector_scan(pos) then
|
||||||
|
minetest.swap_node(pos, {name = "mesecons_detector:object_detector_on"})
|
||||||
node.name = "mesecons_detector:object_detector_on"
|
mesecon.receptor_on(pos, mesecon.rules.pplate)
|
||||||
minetest.swap_node(pos, node)
|
end
|
||||||
mesecon.receptor_on(pos, mesecon.rules.pplate)
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm(
|
||||||
nodenames = {"mesecons_detector:object_detector_on"},
|
{nodenames = {"mesecons_detector:object_detector_on"},
|
||||||
interval = 1,
|
interval = 1.0,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node)
|
action = function(pos)
|
||||||
if object_detector_scan(pos) then return end
|
if not object_detector_scan(pos) then
|
||||||
|
minetest.swap_node(pos, {name = "mesecons_detector:object_detector_off"})
|
||||||
node.name = "mesecons_detector:object_detector_off"
|
mesecon.receptor_off(pos, mesecon.rules.pplate)
|
||||||
minetest.swap_node(pos, node)
|
end
|
||||||
mesecon.receptor_off(pos, mesecon.rules.pplate)
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Node detector
|
-- Node detector
|
||||||
-- Detects the node in front of it
|
-- Detects the node in front of it
|
||||||
|
|
||||||
local function node_detector_make_formspec(pos)
|
local node_detector_make_formspec = function (pos)
|
||||||
minetest.get_meta(pos):set_string("formspec", "size[9,2.5]" ..
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_string("formspec", "size[9,2.5]" ..
|
||||||
"field[0.3, 0;9,2;scanname;Name of node to scan for (empty for any):;${scanname}]"..
|
"field[0.3, 0;9,2;scanname;Name of node to scan for (empty for any):;${scanname}]"..
|
||||||
"field[0.3,1.5;4,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]"..
|
"field[0.3,1.5;4,2;digiline_channel;Digiline Channel (optional):;${digiline_channel}]"..
|
||||||
"button_exit[7,0.75;2,3;;Save]")
|
"button_exit[7,0.75;2,3;;Save]")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function node_detector_on_receive_fields(pos, _, fields)
|
local node_detector_on_receive_fields = function(pos, formname, fields)
|
||||||
if not fields.scanname or not fields.digiline_channel then return end
|
if not fields.scanname or not fields.digiline_channel then return end;
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("scanname", fields.scanname)
|
meta:set_string("scanname", fields.scanname)
|
||||||
@ -147,59 +133,37 @@ local function node_detector_on_receive_fields(pos, _, fields)
|
|||||||
node_detector_make_formspec(pos)
|
node_detector_make_formspec(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- returns true if node was found, false if not
|
-- returns true if player was found, false if not
|
||||||
local function node_detector_scan(pos)
|
local node_detector_scan = function (pos)
|
||||||
local node = minetest.get_node_or_nil(pos)
|
local node = minetest.get_node(pos)
|
||||||
if not node then return end
|
local frontpos = vector.subtract(pos, minetest.facedir_to_dir(node.param2))
|
||||||
|
local frontnode = minetest.get_node(frontpos)
|
||||||
local frontname = minetest.get_node(
|
local meta = minetest.get_meta(pos)
|
||||||
vector.subtract(pos, minetest.facedir_to_dir(node.param2))
|
return (frontnode.name == meta:get_string("scanname")) or
|
||||||
).name
|
(frontnode.name ~= "air" and frontnode.name ~= "ignore" and meta:get_string("scanname") == "")
|
||||||
local scanname = minetest.get_meta(pos):get_string("scanname")
|
|
||||||
|
|
||||||
return (frontname == scanname) or
|
|
||||||
(frontname ~= "air" and frontname ~= "ignore" and scanname == "")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set player name when receiving a digiline signal on a specific channel
|
-- set player name when receiving a digiline signal on a specific channel
|
||||||
local node_detector_digiline = {
|
local node_detector_digiline = {
|
||||||
effector = {
|
effector = {
|
||||||
action = function(pos, node, channel, msg)
|
action = function (pos, node, channel, msg)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
if channel ~= meta:get_string("digiline_channel") then return end
|
local active_channel = meta:get_string("digiline_channel")
|
||||||
|
if channel == active_channel then
|
||||||
if msg == GET_COMMAND then
|
if msg == GET_COMMAND then
|
||||||
local nodename = minetest.get_node(
|
local frontpos = vector.subtract(pos, minetest.facedir_to_dir(node.param2))
|
||||||
vector.subtract(pos, minetest.facedir_to_dir(node.param2))
|
local name = minetest.get_node(frontpos).name
|
||||||
).name
|
digiline:receptor_send(pos, digiline.rules.default, channel, name)
|
||||||
|
else
|
||||||
digiline:receptor_send(pos, digiline.rules.default, channel, nodename)
|
meta:set_string("scanname", msg)
|
||||||
else
|
node_detector_make_formspec(pos)
|
||||||
meta:set_string("scanname", msg)
|
end
|
||||||
node_detector_make_formspec(pos)
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
receptor = {}
|
receptor = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
local function after_place_node_detector(pos, placer)
|
|
||||||
local placer_pos = placer:getpos()
|
|
||||||
if not placer_pos then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
--correct for the player's height
|
|
||||||
if placer:is_player() then
|
|
||||||
placer_pos.y = placer_pos.y + 1.625
|
|
||||||
end
|
|
||||||
|
|
||||||
--correct for 6d facedir
|
|
||||||
local node = minetest.get_node(pos)
|
|
||||||
node.param2 = minetest.dir_to_facedir(vector.subtract(pos, placer_pos), true)
|
|
||||||
minetest.set_node(pos, node)
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.register_node("mesecons_detector:node_detector_off", {
|
minetest.register_node("mesecons_detector:node_detector_off", {
|
||||||
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "jeija_node_detector_off.png"},
|
tiles = {"default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "default_steel_block.png", "jeija_node_detector_off.png"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
@ -212,7 +176,25 @@ minetest.register_node("mesecons_detector:node_detector_off", {
|
|||||||
}},
|
}},
|
||||||
on_construct = node_detector_make_formspec,
|
on_construct = node_detector_make_formspec,
|
||||||
on_receive_fields = node_detector_on_receive_fields,
|
on_receive_fields = node_detector_on_receive_fields,
|
||||||
after_place_node = after_place_node_detector,
|
after_place_node = function (pos, placer)
|
||||||
|
local placer_pos = placer:getpos()
|
||||||
|
|
||||||
|
--correct for the player's height
|
||||||
|
if placer:is_player() then placer_pos.y = placer_pos.y + 1.5 end
|
||||||
|
|
||||||
|
--correct for 6d facedir
|
||||||
|
if placer_pos then
|
||||||
|
local dir = {
|
||||||
|
x = pos.x - placer_pos.x,
|
||||||
|
y = pos.y - placer_pos.y,
|
||||||
|
z = pos.z - placer_pos.z
|
||||||
|
}
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
node.param2 = minetest.dir_to_facedir(dir, true)
|
||||||
|
minetest.set_node(pos, node)
|
||||||
|
minetest.log("action", "real (6d) facedir: " .. node.param2)
|
||||||
|
end
|
||||||
|
end,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
digiline = node_detector_digiline
|
digiline = node_detector_digiline
|
||||||
})
|
})
|
||||||
@ -229,7 +211,25 @@ minetest.register_node("mesecons_detector:node_detector_on", {
|
|||||||
}},
|
}},
|
||||||
on_construct = node_detector_make_formspec,
|
on_construct = node_detector_make_formspec,
|
||||||
on_receive_fields = node_detector_on_receive_fields,
|
on_receive_fields = node_detector_on_receive_fields,
|
||||||
after_place_node = after_place_node_detector,
|
after_place_node = function (pos, placer)
|
||||||
|
local placer_pos = placer:getpos()
|
||||||
|
|
||||||
|
--correct for the player's height
|
||||||
|
if placer:is_player() then placer_pos.y = placer_pos.y + 1.5 end
|
||||||
|
|
||||||
|
--correct for 6d facedir
|
||||||
|
if placer_pos then
|
||||||
|
local dir = {
|
||||||
|
x = pos.x - placer_pos.x,
|
||||||
|
y = pos.y - placer_pos.y,
|
||||||
|
z = pos.z - placer_pos.z
|
||||||
|
}
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
node.param2 = minetest.dir_to_facedir(dir, true)
|
||||||
|
minetest.set_node(pos, node)
|
||||||
|
minetest.log("action", "real (6d) facedir: " .. node.param2)
|
||||||
|
end
|
||||||
|
end,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
digiline = node_detector_digiline
|
digiline = node_detector_digiline
|
||||||
})
|
})
|
||||||
@ -243,28 +243,26 @@ minetest.register_craft({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm(
|
||||||
nodenames = {"mesecons_detector:node_detector_off"},
|
{nodenames = {"mesecons_detector:node_detector_off"},
|
||||||
interval = 1,
|
interval = 1.0,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if not node_detector_scan(pos) then return end
|
if node_detector_scan(pos) then
|
||||||
|
minetest.swap_node(pos, {name = "mesecons_detector:node_detector_on", param2 = node.param2})
|
||||||
node.name = "mesecons_detector:node_detector_on"
|
mesecon.receptor_on(pos)
|
||||||
minetest.swap_node(pos, node)
|
end
|
||||||
mesecon.receptor_on(pos)
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm(
|
||||||
nodenames = {"mesecons_detector:node_detector_on"},
|
{nodenames = {"mesecons_detector:node_detector_on"},
|
||||||
interval = 1,
|
interval = 1.0,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if node_detector_scan(pos) then return end
|
if not node_detector_scan(pos) then
|
||||||
|
minetest.swap_node(pos, {name = "mesecons_detector:node_detector_off", param2 = node.param2})
|
||||||
node.name = "mesecons_detector:node_detector_off"
|
mesecon.receptor_off(pos)
|
||||||
minetest.swap_node(pos, node)
|
end
|
||||||
mesecon.receptor_off(pos)
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
BIN
mesecons_detector/textures/jeija_node_detector_off.png
Executable file → Normal file
Before Width: | Height: | Size: 680 B After Width: | Height: | Size: 717 B |
0
mesecons_detector/textures/jeija_node_detector_on.png
Executable file → Normal file
Before Width: | Height: | Size: 727 B After Width: | Height: | Size: 727 B |
BIN
mesecons_detector/textures/jeija_object_detector_off.png
Executable file → Normal file
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 712 B |
BIN
mesecons_detector/textures/jeija_object_detector_on.png
Executable file → Normal file
Before Width: | Height: | Size: 733 B After Width: | Height: | Size: 735 B |
0
mesecons_doors/depends.txt
Executable file → Normal file
134
mesecons_doors/init.lua
Executable file → Normal file
@ -13,60 +13,36 @@ local function on_rightclick(pos, dir, check_name, replace, replace_dir, params)
|
|||||||
minetest.swap_node(pos, {name = replace, param2 = p2})
|
minetest.swap_node(pos, {name = replace, param2 = p2})
|
||||||
|
|
||||||
if (minetest.get_meta(pos):get_int("right") ~= 0) == (params[1] ~= 3) then
|
if (minetest.get_meta(pos):get_int("right") ~= 0) == (params[1] ~= 3) then
|
||||||
minetest.sound_play("doors_door_close", {pos = pos, gain = 0.3, max_hear_distance = 10})
|
minetest.sound_play("door_close", {pos = pos, gain = 0.3, max_hear_distance = 10})
|
||||||
else
|
else
|
||||||
minetest.sound_play("doors_door_open", {pos = pos, gain = 0.3, max_hear_distance = 10})
|
minetest.sound_play("door_open", {pos = pos, gain = 0.3, max_hear_distance = 10})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function meseconify_door(name)
|
local function meseconify_door(name)
|
||||||
if minetest.registered_items[name .. "_b_1"] then
|
local function toggle_state1 (pos, node)
|
||||||
-- old style double-node doors
|
on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
|
||||||
local function toggle_state1 (pos, node)
|
|
||||||
on_rightclick(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2", {1,2,3,0})
|
|
||||||
end
|
|
||||||
|
|
||||||
local function toggle_state2 (pos, node)
|
|
||||||
on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.override_item(name.."_b_1", {
|
|
||||||
mesecons = {effector = {
|
|
||||||
action_on = toggle_state1,
|
|
||||||
action_off = toggle_state1,
|
|
||||||
rules = mesecon.rules.pplate
|
|
||||||
}}
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.override_item(name.."_b_2", {
|
|
||||||
mesecons = {effector = {
|
|
||||||
action_on = toggle_state2,
|
|
||||||
action_off = toggle_state2,
|
|
||||||
rules = mesecon.rules.pplate
|
|
||||||
}}
|
|
||||||
})
|
|
||||||
elseif minetest.registered_items[name .. "_a"] then
|
|
||||||
-- new style mesh node based doors
|
|
||||||
local override = {
|
|
||||||
mesecons = {effector = {
|
|
||||||
action_on = function(pos, node)
|
|
||||||
local door = doors.get(pos)
|
|
||||||
if door then
|
|
||||||
door:open()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
action_off = function(pos, node)
|
|
||||||
local door = doors.get(pos)
|
|
||||||
if door then
|
|
||||||
door:close()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
rules = mesecon.rules.pplate
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
minetest.override_item(name .. "_a", override)
|
|
||||||
minetest.override_item(name .. "_b", override)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function toggle_state2 (pos, node)
|
||||||
|
on_rightclick(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1", {3,0,1,2})
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.override_item(name.."_b_1", {
|
||||||
|
mesecons = {effector = {
|
||||||
|
action_on = toggle_state1,
|
||||||
|
action_off = toggle_state1,
|
||||||
|
rules = mesecon.rules.pplate
|
||||||
|
}},
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.override_item(name.."_b_2", {
|
||||||
|
mesecons = {effector = {
|
||||||
|
action_on = toggle_state2,
|
||||||
|
action_off = toggle_state2,
|
||||||
|
rules = mesecon.rules.pplate
|
||||||
|
}},
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
meseconify_door("doors:door_wood")
|
meseconify_door("doors:door_wood")
|
||||||
@ -74,19 +50,6 @@ meseconify_door("doors:door_steel")
|
|||||||
meseconify_door("doors:door_glass")
|
meseconify_door("doors:door_glass")
|
||||||
meseconify_door("doors:door_obsidian_glass")
|
meseconify_door("doors:door_obsidian_glass")
|
||||||
|
|
||||||
--MFF meseconify all doors, crabman 12/06/2016
|
|
||||||
meseconify_door("doors:door_cherry")
|
|
||||||
meseconify_door("doors:door_tin")
|
|
||||||
meseconify_door("doors:door_prison")
|
|
||||||
meseconify_door("doors:door_gardengate_white")
|
|
||||||
meseconify_door("doors:door3_wood")
|
|
||||||
meseconify_door("doors:door3_steel")
|
|
||||||
meseconify_door("doors:door3_glass")
|
|
||||||
meseconify_door("doors:door3_obsidian_glass")
|
|
||||||
meseconify_door("doors:door3_cherry")
|
|
||||||
meseconify_door("doors:door3_prison")
|
|
||||||
|
|
||||||
|
|
||||||
-- Trapdoor
|
-- Trapdoor
|
||||||
local function trapdoor_switch(pos, node)
|
local function trapdoor_switch(pos, node)
|
||||||
local state = minetest.get_meta(pos):get_int("state")
|
local state = minetest.get_meta(pos):get_int("state")
|
||||||
@ -102,41 +65,16 @@ local function trapdoor_switch(pos, node)
|
|||||||
minetest.get_meta(pos):set_int("state", state == 1 and 0 or 1)
|
minetest.get_meta(pos):set_int("state", state == 1 and 0 or 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
if doors and doors.get then
|
minetest.override_item("doors:trapdoor", {
|
||||||
local override = {
|
mesecons = {effector = {
|
||||||
mesecons = {effector = {
|
action_on = trapdoor_switch,
|
||||||
action_on = function(pos, node)
|
action_off = trapdoor_switch
|
||||||
local door = doors.get(pos)
|
}},
|
||||||
if door then
|
})
|
||||||
door:open()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
action_off = function(pos, node)
|
|
||||||
local door = doors.get(pos)
|
|
||||||
if door then
|
|
||||||
door:close()
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
}},
|
|
||||||
}
|
|
||||||
minetest.override_item("doors:trapdoor", override)
|
|
||||||
minetest.override_item("doors:trapdoor_open", override)
|
|
||||||
minetest.override_item("doors:trapdoor_steel", override)
|
|
||||||
minetest.override_item("doors:trapdoor_steel_open", override)
|
|
||||||
else
|
|
||||||
if minetest.registered_nodes["doors:trapdoor"] then
|
|
||||||
minetest.override_item("doors:trapdoor", {
|
|
||||||
mesecons = {effector = {
|
|
||||||
action_on = trapdoor_switch,
|
|
||||||
action_off = trapdoor_switch
|
|
||||||
}},
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.override_item("doors:trapdoor_open", {
|
minetest.override_item("doors:trapdoor_open", {
|
||||||
mesecons = {effector = {
|
mesecons = {effector = {
|
||||||
action_on = trapdoor_switch,
|
action_on = trapdoor_switch,
|
||||||
action_off = trapdoor_switch
|
action_off = trapdoor_switch
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
end
|
|
||||||
end
|
|
||||||
|
10
mesecons_extrawires/corner.lua
Executable file → Normal file
@ -10,7 +10,7 @@ local corner_selectionbox = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local corner_get_rules = function (node)
|
local corner_get_rules = function (node)
|
||||||
local rules =
|
local rules =
|
||||||
{{x = 1, y = 0, z = 0},
|
{{x = 1, y = 0, z = 0},
|
||||||
{x = 0, y = 0, z = -1}}
|
{x = 0, y = 0, z = -1}}
|
||||||
|
|
||||||
@ -37,9 +37,9 @@ minetest.register_node("mesecons_extrawires:corner_on", {
|
|||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
selection_box = corner_selectionbox,
|
selection_box = corner_selectionbox,
|
||||||
node_box = corner_nodebox,
|
node_box = corner_nodebox,
|
||||||
groups = {dig_immediate = 2, not_in_creative_inventory = 1}, -- MFF
|
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
||||||
drop = "mesecons_extrawires:corner_off",
|
drop = "mesecons_extrawires:corner_off",
|
||||||
mesecons = {conductor =
|
mesecons = {conductor =
|
||||||
{
|
{
|
||||||
state = mesecon.state.on,
|
state = mesecon.state.on,
|
||||||
rules = corner_get_rules,
|
rules = corner_get_rules,
|
||||||
@ -64,8 +64,8 @@ minetest.register_node("mesecons_extrawires:corner_off", {
|
|||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
selection_box = corner_selectionbox,
|
selection_box = corner_selectionbox,
|
||||||
node_box = corner_nodebox,
|
node_box = corner_nodebox,
|
||||||
groups = {dig_immediate = 2}, --MFF
|
groups = {dig_immediate = 3},
|
||||||
mesecons = {conductor =
|
mesecons = {conductor =
|
||||||
{
|
{
|
||||||
state = mesecon.state.off,
|
state = mesecon.state.off,
|
||||||
rules = corner_get_rules,
|
rules = corner_get_rules,
|
||||||
|
4
mesecons_extrawires/crossover.lua
Executable file → Normal file
@ -41,7 +41,7 @@ minetest.register_node("mesecons_extrawires:crossover_off", {
|
|||||||
{ -3/32, -17/32, 6/32, 3/32, -13/32, 16/32+0.001 },
|
{ -3/32, -17/32, 6/32, 3/32, -13/32, 16/32+0.001 },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
groups = {dig_immediate=2, mesecon=3}, --MFF
|
groups = {dig_immediate=3, mesecon=3, mesecon_conductor_craftable=1},
|
||||||
mesecons = {
|
mesecons = {
|
||||||
conductor = {
|
conductor = {
|
||||||
states = crossover_states,
|
states = crossover_states,
|
||||||
@ -77,7 +77,7 @@ minetest.register_node("mesecons_extrawires:crossover_01", {
|
|||||||
{ -3/32, -17/32, 6/32, 3/32, -13/32, 16/32+0.001 },
|
{ -3/32, -17/32, 6/32, 3/32, -13/32, 16/32+0.001 },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
groups = {dig_immediate=2, mesecon=3, not_in_creative_inventory=1}, --MFF
|
groups = {dig_immediate=3, mesecon=3, not_in_creative_inventory=1},
|
||||||
mesecons = {
|
mesecons = {
|
||||||
conductor = {
|
conductor = {
|
||||||
states = crossover_states,
|
states = crossover_states,
|
||||||
|
0
mesecons_extrawires/depends.txt
Executable file → Normal file
@ -1 +0,0 @@
|
|||||||
Insulated corners are conductors that only conduct between the inputs (also not up or down). When placing they always point to the left in direction of your vision.
|
|
Before Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 3.8 KiB |
@ -1 +0,0 @@
|
|||||||
Insulated crossing are conductors that conduct two signals between the opposing sides, the signals are insulated to each other.
|
|
Before Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 3.7 KiB |
@ -1 +0,0 @@
|
|||||||
The basic prerequesite for mesecons, can be crafted into wires and other stuff. Have a look at the <a href="http://wiki.minetest.net/Mese">Minetest Wiki</a> for more information. Mese is a conductor. It conducts in all six directions: Up/Down/Left/Right/Forward/Backward
|
|
Before Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 6.1 KiB |
@ -1 +0,0 @@
|
|||||||
Insulated T-Junctions are conductors that only conduct between the inputs (also not up or down).
|
|