Update Bluestone to last Mesecons version, minor cleanup
|
@ -0,0 +1,30 @@
|
||||||
|
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/
|
|
@ -20,9 +20,9 @@ OK, I want in.
|
||||||
--------------
|
--------------
|
||||||
Go get it!
|
Go get it!
|
||||||
|
|
||||||
[DOWNLOADS PAGE](http://mesecons.net/downloads.php)
|
[DOWNLOAD IT NOW](https://github.com/minetest-mods/mesecons/archive/master.zip)
|
||||||
|
|
||||||
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](https://wiki.minetest.net/Mods) over at the official Minetest Wiki. For your convenience, here's a quick summary:
|
||||||
|
|
||||||
1. If Mesecons is still in a ZIP file, extract the folder inside to somewhere on the computer.
|
1. If Mesecons is still in a ZIP file, extract the folder inside to somewhere on the computer.
|
||||||
2. Make sure that when you open the folder, you can directly find `README.md` in the listing. If you just see another folder, move that folder up one level and delete the old one.
|
2. Make sure that when you open the folder, you can directly find `README.md` in the listing. If you just see another folder, move that folder up one level and delete the old one.
|
||||||
|
@ -37,13 +37,15 @@ 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.php) is your style?
|
Or maybe a [comprehensive reference](http://mesecons.net/items.html) 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?
|
||||||
|
|
||||||
|
There is also a [wiki page](https://wiki.minetest.net/Mods/Mesecons) dedicated to this mod.
|
||||||
|
|
||||||
Want to get more into building? Why not check out the [Mesecons Laboratory](http://uberi.mesecons.net/), a website dedicated to advanced Mesecons builders?
|
Want to get more into building? Why not check out the [Mesecons Laboratory](http://uberi.mesecons.net/), a website dedicated to advanced Mesecons builders?
|
||||||
|
|
||||||
Want to contribute to Mesecons itself? Check out the [source code](https://github.com/Jeija/minetest-mod-mesecons)!
|
Want to contribute to Mesecons itself? Check out the [source code](https://github.com/minetest-mods/mesecons)!
|
||||||
|
|
||||||
Who wrote it anyways?
|
Who wrote it anyways?
|
||||||
---------------------
|
---------------------
|
||||||
|
@ -51,6 +53,7 @@ These awesome people made Mesecons possible!
|
||||||
|
|
||||||
| Contributor | Contribution |
|
| Contributor | Contribution |
|
||||||
| --------------- | -------------------------------- |
|
| --------------- | -------------------------------- |
|
||||||
|
| Hawk777 | Code for VoxelManip caching |
|
||||||
| Jat15 | Various tweaks. |
|
| Jat15 | Various tweaks. |
|
||||||
| Jeija | **Main developer! Everything.** |
|
| Jeija | **Main developer! Everything.** |
|
||||||
| Jordach | Noteblock sounds. |
|
| Jordach | Noteblock sounds. |
|
||||||
|
|
|
@ -87,7 +87,11 @@ minetest.register_globalstep(function (dtime)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function mesecon.queue:execute(action)
|
function mesecon.queue:execute(action)
|
||||||
|
-- ignore if action queue function name doesn't exist,
|
||||||
|
-- (e.g. in case the action queue savegame was written by an old mesecons version)
|
||||||
|
if mesecon.queue.funcs[action.func] then
|
||||||
mesecon.queue.funcs[action.func](action.pos, unpack(action.params))
|
mesecon.queue.funcs[action.func](action.pos, unpack(action.params))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
-- | \/ | |___ ____ |___ | | | | \ | |____
|
-- | \/ | |___ ____ |___ | | | | \ | |____
|
||||||
-- | | | | | | | | | \ | |
|
-- | | | | | | | | | \ | |
|
||||||
-- | | |___ ____| |___ |____ |____| | \| ____|
|
-- | | |___ ____| |___ |____ |____| | \| ____|
|
||||||
-- by Jeija, Uberi (Temperest), sfan5, VanessaE
|
-- by Jeija, Uberi (Temperest), sfan5, VanessaE, Hawk777 and contributors
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
-- See the documentation on the forum for additional information, especially about crafting
|
-- See the documentation on the forum for additional information, especially about crafting
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- For developer documentation see the Developers' section on mesecons.TK
|
-- For basic development resources, see http://mesecons.net/developers.html
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
|
@ -70,19 +70,11 @@ dofile(minetest.get_modpath("mesecons").."/internal.lua");
|
||||||
-- these are the only functions you need to remember
|
-- these are the only functions you need to remember
|
||||||
|
|
||||||
mesecon.queue:add_function("receptor_on", function (pos, rules)
|
mesecon.queue:add_function("receptor_on", function (pos, rules)
|
||||||
|
mesecon.vm_begin()
|
||||||
|
|
||||||
rules = rules or mesecon.rules.default
|
rules = rules or mesecon.rules.default
|
||||||
|
|
||||||
-- if area (any of the rule targets) is not loaded, keep trying and call this again later
|
-- Call turnon on all linking positions
|
||||||
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
|
||||||
local np = vector.add(pos, rule)
|
|
||||||
-- if area is not loaded, keep trying
|
|
||||||
if minetest.get_node_or_nil(np) == nil then
|
|
||||||
mesecon.queue:add_action(pos, "receptor_on", {rules}, nil, rules)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 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 = vector.add(pos, rule)
|
||||||
local rulenames = mesecon.rules_link_rule_all(pos, rule)
|
local rulenames = mesecon.rules_link_rule_all(pos, rule)
|
||||||
|
@ -90,6 +82,8 @@ end
|
||||||
mesecon.turnon(np, rulename)
|
mesecon.turnon(np, rulename)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
mesecon.vm_commit()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function mesecon.receptor_on(pos, rules)
|
function mesecon.receptor_on(pos, rules)
|
||||||
|
@ -99,23 +93,21 @@ end
|
||||||
mesecon.queue:add_function("receptor_off", function (pos, rules)
|
mesecon.queue:add_function("receptor_off", function (pos, rules)
|
||||||
rules = rules or mesecon.rules.default
|
rules = rules or mesecon.rules.default
|
||||||
|
|
||||||
-- if area (any of the rule targets) is not loaded, keep trying and call this again later
|
-- Call turnoff on all linking positions
|
||||||
for _, rule in ipairs(mesecon.flattenrules(rules)) do
|
|
||||||
local np = vector.add(pos, rule)
|
|
||||||
if minetest.get_node_or_nil(np) == nil then
|
|
||||||
mesecon.queue:add_action(pos, "receptor_off", {rules}, nil, rules)
|
|
||||||
return
|
|
||||||
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 = vector.add(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
|
mesecon.vm_begin()
|
||||||
mesecon.turnoff(np, rulename)
|
|
||||||
else
|
|
||||||
mesecon.changesignal(np, minetest.get_node(np), rulename, mesecon.state.off, 2)
|
mesecon.changesignal(np, minetest.get_node(np), rulename, mesecon.state.off, 2)
|
||||||
|
|
||||||
|
-- Turnoff returns true if turnoff process was successful, no onstate receptor
|
||||||
|
-- was found along the way. Commit changes that were made in voxelmanip. If turnoff
|
||||||
|
-- returns true, an onstate receptor was found, abort voxelmanip transaction.
|
||||||
|
if (mesecon.turnoff(np, rulename)) then
|
||||||
|
mesecon.vm_commit()
|
||||||
|
else
|
||||||
|
mesecon.vm_abort()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -125,8 +117,9 @@ function mesecon.receptor_off(pos, rules)
|
||||||
mesecon.queue:add_action(pos, "receptor_off", {rules}, nil, rules)
|
mesecon.queue:add_action(pos, "receptor_off", {rules}, nil, rules)
|
||||||
end
|
end
|
||||||
|
|
||||||
--The actual wires
|
-- Deprecated stuff
|
||||||
dofile(minetest.get_modpath("mesecons").."/wires.lua");
|
-- To be removed in future releases
|
||||||
|
dofile(minetest.get_modpath("mesecons").."/legacy.lua");
|
||||||
|
|
||||||
--Services like turnoff receptor on dignode and so on
|
--Services like turnoff receptor on dignode and so on
|
||||||
dofile(minetest.get_modpath("mesecons").."/services.lua");
|
dofile(minetest.get_modpath("mesecons").."/services.lua");
|
||||||
|
|
|
@ -37,11 +37,6 @@
|
||||||
-- HIGH-LEVEL Internals
|
-- HIGH-LEVEL Internals
|
||||||
-- mesecon.is_power_on(pos) --> Returns true if pos emits power in any way
|
-- mesecon.is_power_on(pos) --> Returns true if pos emits power in any way
|
||||||
-- mesecon.is_power_off(pos) --> Returns true if pos does not emit power in any way
|
-- mesecon.is_power_off(pos) --> Returns true if pos does not emit power in any way
|
||||||
-- mesecon.turnon(pos, link) --> link is the input rule that caused calling turnon, turns on every connected node, iterative
|
|
||||||
-- mesecon.turnoff(pos, link) --> link is the input rule that caused calling turnoff, turns off every connected node, iterative
|
|
||||||
-- mesecon.connected_to_receptor(pos, link) --> Returns true if pos is connected to a receptor directly or via conductors, iterative
|
|
||||||
-- mesecon.rules_link(output, input, dug_outputrules) --> Returns true if outputposition + outputrules = inputposition and inputposition + inputrules = outputposition (if the two positions connect)
|
|
||||||
-- mesecon.rules_link_anydir(outp., inp., d_outpr.) --> Same as rules mesecon.rules_link but also returns true if output and input are swapped
|
|
||||||
-- mesecon.is_powered(pos) --> Returns true if pos is powered by a receptor or a conductor
|
-- mesecon.is_powered(pos) --> Returns true if pos is powered by a receptor or a conductor
|
||||||
|
|
||||||
-- RULES ROTATION helpers
|
-- RULES ROTATION helpers
|
||||||
|
@ -371,38 +366,32 @@ function mesecon.is_power_off(pos, rulename)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Turn off an equipotential section starting at `pos`, which outputs in the direction of `link`.
|
||||||
|
-- Breadth-first search. Map is abstracted away in a voxelmanip.
|
||||||
|
-- Follow all all conductor paths replacing conductors that were already
|
||||||
|
-- looked at, activating / changing all effectors along the way.
|
||||||
function mesecon.turnon(pos, link)
|
function mesecon.turnon(pos, link)
|
||||||
local frontiers = {{pos = pos, link = link}}
|
local frontiers = {{pos = pos, link = link}}
|
||||||
|
|
||||||
local depth = 1
|
local depth = 1
|
||||||
while frontiers[depth] do
|
while frontiers[1] do
|
||||||
local f = frontiers[depth]
|
local f = table.remove(frontiers, 1)
|
||||||
local node = mesecon.get_node_force(f.pos)
|
local node = mesecon.get_node_force(f.pos)
|
||||||
|
|
||||||
-- area not loaded, postpone action
|
|
||||||
if not node then
|
if not node then
|
||||||
mesecon.queue:add_action(f.pos, "turnon", {link}, nil, true)
|
-- Area does not exist; do nothing
|
||||||
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)
|
||||||
|
|
||||||
minetest.swap_node(f.pos, {name = mesecon.get_conductor_on(node, f.link),
|
-- Call turnon on neighbors
|
||||||
param2 = node.param2})
|
|
||||||
|
|
||||||
-- 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 = vector.add(f.pos, r)
|
||||||
|
for _, l in ipairs(mesecon.rules_link_rule_all(f.pos, r)) do
|
||||||
-- area not loaded, postpone action
|
|
||||||
if not mesecon.get_node_force(np) then
|
|
||||||
mesecon.queue:add_action(np, "turnon", {rulename},
|
|
||||||
nil, true)
|
|
||||||
else
|
|
||||||
local links = mesecon.rules_link_rule_all(f.pos, r)
|
|
||||||
for _, l in ipairs(links) do
|
|
||||||
table.insert(frontiers, {pos = np, link = l})
|
table.insert(frontiers, {pos = np, link = l})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
mesecon.swap_node_force(f.pos, mesecon.get_conductor_on(node, f.link))
|
||||||
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)
|
||||||
if mesecon.is_effector_off(node.name) then
|
if mesecon.is_effector_off(node.name) then
|
||||||
|
@ -413,137 +402,77 @@ end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon.queue:add_function("turnon", function (pos, rulename, recdepth)
|
-- Turn on an equipotential section starting at `pos`, which outputs in the direction of `link`.
|
||||||
mesecon.turnon(pos, rulename, recdepth)
|
-- Breadth-first search. Map is abstracted away in a voxelmanip.
|
||||||
end)
|
-- Follow all all conductor paths replacing conductors that were already
|
||||||
|
-- looked at, deactivating / changing all effectors along the way.
|
||||||
|
-- In case an onstate receptor is discovered, abort the process by returning false, which will
|
||||||
|
-- cause `receptor_off` to discard all changes made in the voxelmanip.
|
||||||
|
-- Contrary to turnon, turnoff has to cache all change and deactivate signals so that they will only
|
||||||
|
-- be called in the very end when we can be sure that no conductor was found along the path.
|
||||||
|
--
|
||||||
|
-- Signal table entry structure:
|
||||||
|
-- {
|
||||||
|
-- pos = position of effector,
|
||||||
|
-- node = node descriptor (name, param1 and param2),
|
||||||
|
-- link = link the effector is connected to,
|
||||||
|
-- depth = indicates order in which signals wire fired, higher is later
|
||||||
|
-- }
|
||||||
function mesecon.turnoff(pos, link)
|
function mesecon.turnoff(pos, link)
|
||||||
local frontiers = {{pos = pos, link = link}}
|
local frontiers = {{pos = pos, link = link}}
|
||||||
|
local signals = {}
|
||||||
|
|
||||||
local depth = 1
|
local depth = 1
|
||||||
while frontiers[depth] do
|
while frontiers[1] do
|
||||||
local f = frontiers[depth]
|
local f = table.remove(frontiers, 1)
|
||||||
local node = mesecon.get_node_force(f.pos)
|
local node = mesecon.get_node_force(f.pos)
|
||||||
|
|
||||||
-- area not loaded, postpone action
|
|
||||||
if not node then
|
if not node then
|
||||||
mesecon.queue:add_action(f.pos, "turnoff", {link}, nil, true)
|
-- Area does not exist; do nothing
|
||||||
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)
|
||||||
|
|
||||||
minetest.swap_node(f.pos, {name = mesecon.get_conductor_off(node, f.link),
|
|
||||||
param2 = node.param2})
|
|
||||||
|
|
||||||
-- 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 = vector.add(f.pos, r)
|
||||||
|
|
||||||
-- area not loaded, postpone action
|
-- Check if an onstate receptor is connected. If that is the case,
|
||||||
if not mesecon.get_node_force(np) then
|
-- abort this turnoff process by returning false. `receptor_off` will
|
||||||
mesecon.queue:add_action(np, "turnoff", {rulename},
|
-- discard all the changes that we made in the voxelmanip:
|
||||||
nil, true)
|
for _, l in ipairs(mesecon.rules_link_rule_all_inverted(f.pos, r)) do
|
||||||
else
|
if mesecon.is_receptor_on(mesecon.get_node_force(np).name) then
|
||||||
local links = mesecon.rules_link_rule_all(f.pos, r)
|
return false
|
||||||
for _, l in ipairs(links) do
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Call turnoff on neighbors
|
||||||
|
for _, l in ipairs(mesecon.rules_link_rule_all(f.pos, r)) do
|
||||||
table.insert(frontiers, {pos = np, link = l})
|
table.insert(frontiers, {pos = np, link = l})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
mesecon.swap_node_force(f.pos, mesecon.get_conductor_off(node, f.link))
|
||||||
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)
|
table.insert(signals, {
|
||||||
if mesecon.is_effector_on(node.name) and not mesecon.is_powered(f.pos) then
|
pos = f.pos,
|
||||||
mesecon.deactivate(f.pos, node, f.link, depth)
|
node = node,
|
||||||
end
|
link = f.link,
|
||||||
|
depth = depth
|
||||||
|
})
|
||||||
end
|
end
|
||||||
depth = depth + 1
|
depth = depth + 1
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
mesecon.queue:add_function("turnoff", function (pos, rulename, recdepth)
|
for _, sig in ipairs(signals) do
|
||||||
mesecon.turnoff(pos, rulename, recdepth)
|
mesecon.changesignal(sig.pos, sig.node, sig.link, mesecon.state.off, sig.depth)
|
||||||
end)
|
if mesecon.is_effector_on(sig.node.name) and not mesecon.is_powered(sig.pos) then
|
||||||
|
mesecon.deactivate(sig.pos, sig.node, sig.link, sig.depth)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function mesecon.connected_to_receptor(pos, link)
|
|
||||||
local node = mesecon.get_node_force(pos)
|
|
||||||
if not node then return false end
|
|
||||||
|
|
||||||
-- Check if conductors around are connected
|
|
||||||
local rules = mesecon.get_any_inputrules(node)
|
|
||||||
if not rules then return false end
|
|
||||||
|
|
||||||
for _, rule in ipairs(mesecon.rule2meta(link, rules)) do
|
|
||||||
local links = mesecon.rules_link_rule_all_inverted(pos, rule)
|
|
||||||
for _, l in ipairs(links) do
|
|
||||||
local np = vector.add(pos, l)
|
|
||||||
if mesecon.find_receptor_on(np, mesecon.invertRule(l)) then
|
|
||||||
return true
|
return true
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
function mesecon.find_receptor_on(pos, link)
|
|
||||||
local frontiers = {{pos = pos, link = link}}
|
|
||||||
local checked = {}
|
|
||||||
|
|
||||||
-- List of positions that have been searched for onstate receptors
|
|
||||||
local depth = 1
|
|
||||||
while frontiers[depth] do
|
|
||||||
local f = frontiers[depth]
|
|
||||||
local node = mesecon.get_node_force(f.pos)
|
|
||||||
|
|
||||||
if not node then return false end
|
|
||||||
if mesecon.is_receptor_on(node.name) then return true end
|
|
||||||
if mesecon.is_conductor_on(node, f.link) then
|
|
||||||
local rules = mesecon.conductor_get_rules(node)
|
|
||||||
|
|
||||||
-- call turnoff on neighbors: normal rules
|
|
||||||
for _, r in ipairs(mesecon.rule2meta(f.link, rules)) do
|
|
||||||
local np = vector.add(f.pos, r)
|
|
||||||
|
|
||||||
local links = mesecon.rules_link_rule_all_inverted(f.pos, r)
|
|
||||||
for _, l in ipairs(links) do
|
|
||||||
local checkedstring = np.x..np.y..np.z..l.x..l.y..l.z
|
|
||||||
if not checked[checkedstring] then
|
|
||||||
table.insert(frontiers, {pos = np, link = l})
|
|
||||||
checked[checkedstring] = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
depth = depth + 1
|
|
||||||
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
|
|
||||||
local outputnode = mesecon.get_node_force(output)
|
|
||||||
local inputnode = mesecon.get_node_force(input)
|
|
||||||
|
|
||||||
local outputrules = dug_outputrules or mesecon.get_any_outputrules (outputnode)
|
|
||||||
local inputrules = mesecon.get_any_inputrules (inputnode)
|
|
||||||
if not outputrules or not inputrules then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, outputrule in ipairs(mesecon.flattenrules(outputrules)) do
|
|
||||||
-- Check if output sends to input
|
|
||||||
if vector.equals(vector.add(output, outputrule), input) then
|
|
||||||
for _, inputrule in ipairs(mesecon.flattenrules(inputrules)) do
|
|
||||||
-- Check if input accepts from output
|
|
||||||
if vector.equals(vector.add(input, inputrule), output) then
|
|
||||||
return true, inputrule
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Get all linking inputrules of inputnode (effector or conductor) that is connected to
|
||||||
|
-- outputnode (receptor or conductor) at position `output` and has an output in direction `rule`
|
||||||
function mesecon.rules_link_rule_all(output, rule)
|
function mesecon.rules_link_rule_all(output, rule)
|
||||||
local input = vector.add(output, rule)
|
local input = vector.add(output, rule)
|
||||||
local inputnode = mesecon.get_node_force(input)
|
local inputnode = mesecon.get_node_force(input)
|
||||||
|
@ -563,8 +492,9 @@ end
|
||||||
return rules
|
return rules
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Get all linking outputnodes of outputnode (receptor or conductor) that is connected to
|
||||||
|
-- inputnode (effector or conductor) at position `input` and has an input in direction `rule`
|
||||||
function mesecon.rules_link_rule_all_inverted(input, rule)
|
function mesecon.rules_link_rule_all_inverted(input, rule)
|
||||||
--local irule = mesecon.invertRule(rule)
|
|
||||||
local output = vector.add(input, rule)
|
local output = vector.add(input, rule)
|
||||||
local outputnode = mesecon.get_node_force(output)
|
local outputnode = mesecon.get_node_force(output)
|
||||||
local outputrules = mesecon.get_any_outputrules (outputnode)
|
local outputrules = mesecon.get_any_outputrules (outputnode)
|
||||||
|
@ -581,10 +511,6 @@ function mesecon.rules_link_rule_all_inverted(input, rule)
|
||||||
return rules
|
return rules
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.rules_link_anydir(pos1, pos2)
|
|
||||||
return mesecon.rules_link(pos1, pos2) or mesecon.rules_link(pos2, pos1)
|
|
||||||
end
|
|
||||||
|
|
||||||
function mesecon.is_powered(pos, rule)
|
function mesecon.is_powered(pos, rule)
|
||||||
local node = mesecon.get_node_force(pos)
|
local node = mesecon.get_node_force(pos)
|
||||||
local rules = mesecon.get_any_inputrules(node)
|
local rules = mesecon.get_any_inputrules(node)
|
||||||
|
@ -622,52 +548,3 @@ function mesecon.is_powered(pos, rule)
|
||||||
if (#sourcepos == 0) then return false
|
if (#sourcepos == 0) then return false
|
||||||
else return sourcepos end
|
else return sourcepos end
|
||||||
end
|
end
|
||||||
|
|
||||||
--Rules rotation Functions:
|
|
||||||
function mesecon.rotate_rules_right(rules)
|
|
||||||
local nr = {}
|
|
||||||
for i, rule in ipairs(rules) do
|
|
||||||
table.insert(nr, {
|
|
||||||
x = -rule.z,
|
|
||||||
y = rule.y,
|
|
||||||
z = rule.x,
|
|
||||||
name = rule.name})
|
|
||||||
end
|
|
||||||
return nr
|
|
||||||
end
|
|
||||||
|
|
||||||
function mesecon.rotate_rules_left(rules)
|
|
||||||
local nr = {}
|
|
||||||
for i, rule in ipairs(rules) do
|
|
||||||
table.insert(nr, {
|
|
||||||
x = rule.z,
|
|
||||||
y = rule.y,
|
|
||||||
z = -rule.x,
|
|
||||||
name = rule.name})
|
|
||||||
end
|
|
||||||
return nr
|
|
||||||
end
|
|
||||||
|
|
||||||
function mesecon.rotate_rules_down(rules)
|
|
||||||
local nr = {}
|
|
||||||
for i, rule in ipairs(rules) do
|
|
||||||
table.insert(nr, {
|
|
||||||
x = -rule.y,
|
|
||||||
y = rule.x,
|
|
||||||
z = rule.z,
|
|
||||||
name = rule.name})
|
|
||||||
end
|
|
||||||
return nr
|
|
||||||
end
|
|
||||||
|
|
||||||
function mesecon.rotate_rules_up(rules)
|
|
||||||
local nr = {}
|
|
||||||
for i, rule in ipairs(rules) do
|
|
||||||
table.insert(nr, {
|
|
||||||
x = rule.y,
|
|
||||||
y = -rule.x,
|
|
||||||
z = rule.z,
|
|
||||||
name = rule.name})
|
|
||||||
end
|
|
||||||
return nr
|
|
||||||
end
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
-- Un-forceload any forceloaded mapblocks from older versions of Mesecons which
|
||||||
|
-- used forceloading instead of VoxelManipulators.
|
||||||
|
local BLOCKSIZE = 16
|
||||||
|
|
||||||
|
-- convert block hash --> node position
|
||||||
|
local function unhash_blockpos(hash)
|
||||||
|
return vector.multiply(minetest.get_position_from_hash(hash), BLOCKSIZE)
|
||||||
|
end
|
||||||
|
|
||||||
|
local old_forceloaded_blocks = mesecon.file2table("mesecon_forceloaded")
|
||||||
|
for hash, _ in pairs(old_forceloaded_blocks) do
|
||||||
|
minetest.forceload_free_block(unhash_blockpos(hash))
|
||||||
|
end
|
||||||
|
os.remove(minetest.get_worldpath()..DIR_DELIM.."mesecon_forceloaded")
|
|
@ -1,8 +1,8 @@
|
||||||
mesecon.rules = {}
|
mesecon.rules = {}
|
||||||
mesecon.state = {}
|
mesecon.state = {}
|
||||||
|
|
||||||
mesecon.rules.default =
|
mesecon.rules.default = {
|
||||||
{{x=0, y=0, z=-1},
|
{x = 0, y = 0, z = -1},
|
||||||
{x=1, y=0, z=0},
|
{x=1, y=0, z=0},
|
||||||
{x=-1, y=0, z=0},
|
{x=-1, y=0, z=0},
|
||||||
{x=0, y=0, z=1},
|
{x=0, y=0, z=1},
|
||||||
|
@ -13,42 +13,73 @@ mesecon.rules.default =
|
||||||
{x=0, y=1, z=1},
|
{x=0, y=1, z=1},
|
||||||
{x=0, y=-1, z=1},
|
{x=0, y=-1, z=1},
|
||||||
{x=0, y=1, z=-1},
|
{x=0, y=1, z=-1},
|
||||||
{x=0, y=-1, z=-1}}
|
{x = 0, y = -1, z = -1},
|
||||||
|
}
|
||||||
|
|
||||||
mesecon.rules.pplate = mesecon.mergetable(mesecon.rules.default, {{x=0, y=-2, z=0}})
|
mesecon.rules.floor = mesecon.mergetable(mesecon.rules.default, {{x = 0, y = -1, z = 0}})
|
||||||
|
|
||||||
mesecon.rules.buttonlike =
|
mesecon.rules.pplate = mesecon.mergetable(mesecon.rules.floor, {{x = 0, y = -2, z = 0}})
|
||||||
{{x = 1, y = 0, z = 0},
|
|
||||||
|
mesecon.rules.buttonlike = {
|
||||||
|
{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},
|
||||||
|
}
|
||||||
|
|
||||||
mesecon.rules.flat =
|
mesecon.rules.flat = {
|
||||||
{{x = 1, y = 0, z = 0},
|
{x = 1, y = 0, z = 0},
|
||||||
{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 =
|
mesecon.rules.alldirs = {
|
||||||
{{x= 1, y= 0, z= 0},
|
{x = 1, y = 0, z = 0},
|
||||||
{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=-1, z= 0},
|
{x= 0, y=-1, 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},
|
||||||
|
}
|
||||||
|
|
||||||
|
local rules_wallmounted = {
|
||||||
|
xp = mesecon.rotate_rules_down(mesecon.rules.floor),
|
||||||
|
xn = mesecon.rotate_rules_up(mesecon.rules.floor),
|
||||||
|
yp = mesecon.rotate_rules_up(mesecon.rotate_rules_up(mesecon.rules.floor)),
|
||||||
|
yn = mesecon.rules.floor,
|
||||||
|
zp = mesecon.rotate_rules_left(mesecon.rotate_rules_up(mesecon.rules.floor)),
|
||||||
|
zn = mesecon.rotate_rules_right(mesecon.rotate_rules_up(mesecon.rules.floor)),
|
||||||
|
}
|
||||||
|
|
||||||
|
local rules_buttonlike = {
|
||||||
|
xp = mesecon.rules.buttonlike,
|
||||||
|
xn = mesecon.rotate_rules_right(mesecon.rotate_rules_right(mesecon.rules.buttonlike)),
|
||||||
|
yp = mesecon.rotate_rules_down(mesecon.rules.buttonlike),
|
||||||
|
yn = mesecon.rotate_rules_up(mesecon.rules.buttonlike),
|
||||||
|
zp = mesecon.rotate_rules_right(mesecon.rules.buttonlike),
|
||||||
|
zn = mesecon.rotate_rules_left(mesecon.rules.buttonlike),
|
||||||
|
}
|
||||||
|
|
||||||
|
local function rules_from_dir(ruleset, dir)
|
||||||
|
if dir.x == 1 then return ruleset.xp end
|
||||||
|
if dir.y == 1 then return ruleset.yp end
|
||||||
|
if dir.z == 1 then return ruleset.zp end
|
||||||
|
if dir.x == -1 then return ruleset.xn end
|
||||||
|
if dir.y == -1 then return ruleset.yn end
|
||||||
|
if dir.z == -1 then return ruleset.zn end
|
||||||
|
end
|
||||||
|
|
||||||
|
mesecon.rules.wallmounted_get = function(node)
|
||||||
|
local dir = minetest.wallmounted_to_dir(node.param2)
|
||||||
|
return rules_from_dir(rules_wallmounted, dir)
|
||||||
|
end
|
||||||
|
|
||||||
mesecon.rules.buttonlike_get = function(node)
|
mesecon.rules.buttonlike_get = function(node)
|
||||||
local rules = mesecon.rules.buttonlike
|
local dir = minetest.facedir_to_dir(node.param2)
|
||||||
if node.param2 == 2 then
|
return rules_from_dir(rules_buttonlike, dir)
|
||||||
rules=mesecon.rotate_rules_left(rules)
|
|
||||||
elseif node.param2 == 3 then
|
|
||||||
rules=mesecon.rotate_rules_right(mesecon.rotate_rules_right(rules))
|
|
||||||
elseif node.param2 == 0 then
|
|
||||||
rules=mesecon.rotate_rules_right(rules)
|
|
||||||
end
|
|
||||||
return rules
|
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon.state.on = "on"
|
mesecon.state.on = "on"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
-- Dig and place services
|
-- Dig and place services
|
||||||
|
|
||||||
mesecon.on_placenode = function (pos, node)
|
mesecon.on_placenode = function (pos, node)
|
||||||
mesecon.update_autoconnect(pos, node)
|
mesecon.execute_autoconnect_hooks_now(pos, node)
|
||||||
|
|
||||||
-- Receptors: Send on signal when active
|
-- Receptors: Send on signal when active
|
||||||
if mesecon.is_receptor_on(node.name) then
|
if mesecon.is_receptor_on(node.name) then
|
||||||
|
@ -21,7 +21,8 @@ mesecon.on_placenode = function (pos, node)
|
||||||
end
|
end
|
||||||
--mesecon.receptor_on (pos, mesecon.conductor_get_rules(node))
|
--mesecon.receptor_on (pos, mesecon.conductor_get_rules(node))
|
||||||
elseif mesecon.is_conductor_on(node) then
|
elseif mesecon.is_conductor_on(node) then
|
||||||
minetest.swap_node(pos, {name = mesecon.get_conductor_off(node)})
|
node.name = mesecon.get_conductor_off(node)
|
||||||
|
minetest.swap_node(pos, node)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -58,43 +59,78 @@ mesecon.on_dignode = function (pos, node)
|
||||||
elseif mesecon.is_receptor_on(node.name) then
|
elseif mesecon.is_receptor_on(node.name) then
|
||||||
mesecon.receptor_off(pos, mesecon.receptor_get_rules(node))
|
mesecon.receptor_off(pos, mesecon.receptor_get_rules(node))
|
||||||
end
|
end
|
||||||
mesecon.queue:add_action(pos, "update_autoconnect", {node})
|
|
||||||
|
mesecon.execute_autoconnect_hooks_queue(pos, node)
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon.queue:add_function("update_autoconnect", mesecon.update_autoconnect)
|
function mesecon.on_blastnode(pos, intensity)
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
minetest.remove_node(pos)
|
||||||
|
mesecon.on_dignode(pos, node)
|
||||||
|
return minetest.get_node_drops(node.name, "")
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_on_placenode(mesecon.on_placenode)
|
minetest.register_on_placenode(mesecon.on_placenode)
|
||||||
minetest.register_on_dignode(mesecon.on_dignode)
|
minetest.register_on_dignode(mesecon.on_dignode)
|
||||||
|
|
||||||
-- Overheating service for fast circuits
|
-- Overheating service for fast circuits
|
||||||
|
local OVERHEAT_MAX = mesecon.setting("overheat_max", 20)
|
||||||
|
local COOLDOWN_TIME = mesecon.setting("cooldown_time", 2.0)
|
||||||
|
local COOLDOWN_STEP = mesecon.setting("cooldown_granularity", 0.5)
|
||||||
|
local COOLDOWN_MULTIPLIER = OVERHEAT_MAX / COOLDOWN_TIME
|
||||||
|
local cooldown_timer = 0.0
|
||||||
|
local object_heat = {}
|
||||||
|
|
||||||
-- returns true if heat is too high
|
-- returns true if heat is too high
|
||||||
mesecon.do_overheat = function(pos)
|
function mesecon.do_overheat(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local id = minetest.hash_node_position(pos)
|
||||||
local heat = meta:get_int("heat") or 0
|
local heat = (object_heat[id] or 0) + 1
|
||||||
|
object_heat[id] = heat
|
||||||
heat = heat + 1
|
if heat >= OVERHEAT_MAX then
|
||||||
meta:set_int("heat", heat)
|
minetest.log("action", "Node overheats at " .. minetest.pos_to_string(pos))
|
||||||
|
object_heat[id] = nil
|
||||||
if heat < mesecon.setting("overheat_max", 20) then
|
|
||||||
mesecon.queue:add_action(pos, "cooldown", {}, 1, nil, 0)
|
|
||||||
else
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mesecon.do_cooldown(pos)
|
||||||
|
local id = minetest.hash_node_position(pos)
|
||||||
|
object_heat[id] = nil
|
||||||
|
end
|
||||||
|
|
||||||
mesecon.queue:add_function("cooldown", function (pos)
|
function mesecon.get_heat(pos)
|
||||||
if minetest.get_item_group(minetest.get_node(pos).name, "overheat") == 0 then
|
local id = minetest.hash_node_position(pos)
|
||||||
return -- node has been moved, this one does not use overheating - ignore
|
return object_heat[id] or 0
|
||||||
|
end
|
||||||
|
|
||||||
|
function mesecon.move_hot_nodes(moved_nodes)
|
||||||
|
local new_heat = {}
|
||||||
|
for _, n in ipairs(moved_nodes) do
|
||||||
|
local old_id = minetest.hash_node_position(n.oldpos)
|
||||||
|
local new_id = minetest.hash_node_position(n.pos)
|
||||||
|
new_heat[new_id] = object_heat[old_id]
|
||||||
|
object_heat[old_id] = nil
|
||||||
end
|
end
|
||||||
|
for id, heat in pairs(new_heat) do
|
||||||
local meta = minetest.get_meta(pos)
|
object_heat[id] = heat
|
||||||
local heat = meta:get_int("heat")
|
|
||||||
|
|
||||||
if (heat > 0) then
|
|
||||||
meta:set_int("heat", heat - 1)
|
|
||||||
end
|
end
|
||||||
end)
|
end
|
||||||
|
|
||||||
|
local function global_cooldown(dtime)
|
||||||
|
cooldown_timer = cooldown_timer + dtime
|
||||||
|
if cooldown_timer < COOLDOWN_STEP then
|
||||||
|
return -- don't overload the CPU
|
||||||
|
end
|
||||||
|
local cooldown = COOLDOWN_MULTIPLIER * cooldown_timer
|
||||||
|
cooldown_timer = 0
|
||||||
|
for id, heat in pairs(object_heat) do
|
||||||
|
heat = heat - cooldown
|
||||||
|
if heat <= 0 then
|
||||||
|
object_heat[id] = nil -- free some RAM
|
||||||
|
else
|
||||||
|
object_heat[id] = heat
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
minetest.register_globalstep(global_cooldown)
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
-- SETTINGS
|
-- SETTINGS
|
||||||
function mesecon.setting(setting, default)
|
function mesecon.setting(setting, default)
|
||||||
if type(default) == "boolean" then
|
if type(default) == "boolean" then
|
||||||
local read = minetest.setting_getbool("mesecon."..setting)
|
local read = minetest.settings:get_bool("mesecon."..setting)
|
||||||
if read == nil then
|
if read == nil then
|
||||||
return default
|
return default
|
||||||
else
|
else
|
||||||
return read
|
return read
|
||||||
end
|
end
|
||||||
elseif type(default) == "string" then
|
elseif type(default) == "string" then
|
||||||
return minetest.setting_get("mesecon."..setting) or default
|
return minetest.settings:get("mesecon."..setting) or default
|
||||||
elseif type(default) == "number" then
|
elseif type(default) == "number" then
|
||||||
return tonumber(minetest.setting_get("mesecon."..setting) or default)
|
return tonumber(minetest.settings:get("mesecon."..setting) or default)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,56 @@ function mesecon.move_node(pos, newpos)
|
||||||
minetest.get_meta(pos):from_table(meta)
|
minetest.get_meta(pos):from_table(meta)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Rules rotation Functions:
|
||||||
|
function mesecon.rotate_rules_right(rules)
|
||||||
|
local nr = {}
|
||||||
|
for i, rule in ipairs(rules) do
|
||||||
|
table.insert(nr, {
|
||||||
|
x = -rule.z,
|
||||||
|
y = rule.y,
|
||||||
|
z = rule.x,
|
||||||
|
name = rule.name})
|
||||||
|
end
|
||||||
|
return nr
|
||||||
|
end
|
||||||
|
|
||||||
|
function mesecon.rotate_rules_left(rules)
|
||||||
|
local nr = {}
|
||||||
|
for i, rule in ipairs(rules) do
|
||||||
|
table.insert(nr, {
|
||||||
|
x = rule.z,
|
||||||
|
y = rule.y,
|
||||||
|
z = -rule.x,
|
||||||
|
name = rule.name})
|
||||||
|
end
|
||||||
|
return nr
|
||||||
|
end
|
||||||
|
|
||||||
|
function mesecon.rotate_rules_down(rules)
|
||||||
|
local nr = {}
|
||||||
|
for i, rule in ipairs(rules) do
|
||||||
|
table.insert(nr, {
|
||||||
|
x = -rule.y,
|
||||||
|
y = rule.x,
|
||||||
|
z = rule.z,
|
||||||
|
name = rule.name})
|
||||||
|
end
|
||||||
|
return nr
|
||||||
|
end
|
||||||
|
|
||||||
|
function mesecon.rotate_rules_up(rules)
|
||||||
|
local nr = {}
|
||||||
|
for i, rule in ipairs(rules) do
|
||||||
|
table.insert(nr, {
|
||||||
|
x = rule.y,
|
||||||
|
y = -rule.x,
|
||||||
|
z = rule.z,
|
||||||
|
name = rule.name})
|
||||||
|
end
|
||||||
|
return nr
|
||||||
|
end
|
||||||
|
--
|
||||||
|
|
||||||
function mesecon.flattenrules(allrules)
|
function mesecon.flattenrules(allrules)
|
||||||
--[[
|
--[[
|
||||||
{
|
{
|
||||||
|
@ -178,6 +228,7 @@ end
|
||||||
|
|
||||||
function mesecon.register_node(name, spec_common, spec_off, spec_on)
|
function mesecon.register_node(name, spec_common, spec_off, spec_on)
|
||||||
spec_common.drop = spec_common.drop or name .. "_off"
|
spec_common.drop = spec_common.drop or name .. "_off"
|
||||||
|
spec_common.on_blast = spec_common.on_blast or mesecon.on_blastnode
|
||||||
spec_common.__mesecon_basename = name
|
spec_common.__mesecon_basename = name
|
||||||
spec_on.__mesecon_state = "on"
|
spec_on.__mesecon_state = "on"
|
||||||
spec_off.__mesecon_state = "off"
|
spec_off.__mesecon_state = "off"
|
||||||
|
@ -219,7 +270,7 @@ function mesecon.table2file(filename, table)
|
||||||
f:close()
|
f:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Forceloading: Force server to load area if node is nil
|
-- Block position "hashing" (convert to integer) functions for voxelmanip cache
|
||||||
local BLOCKSIZE = 16
|
local BLOCKSIZE = 16
|
||||||
|
|
||||||
-- convert node position --> block hash
|
-- convert node position --> block hash
|
||||||
|
@ -231,45 +282,160 @@ local function hash_blockpos(pos)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- convert block hash --> node position
|
-- Maps from a hashed mapblock position (as returned by hash_blockpos) to a
|
||||||
local function unhash_blockpos(hash)
|
-- table.
|
||||||
return vector.multiply(minetest.get_position_from_hash(hash), BLOCKSIZE)
|
--
|
||||||
|
-- Contents of the table are:
|
||||||
|
-- “vm” > the VoxelManipulator
|
||||||
|
-- “va” > the VoxelArea
|
||||||
|
-- “data” > the data array
|
||||||
|
-- “param1” > the param1 array
|
||||||
|
-- “param2” > the param2 array
|
||||||
|
-- “dirty” > true if data has been modified
|
||||||
|
--
|
||||||
|
-- Nil if no VM-based transaction is in progress.
|
||||||
|
local vm_cache = nil
|
||||||
|
|
||||||
|
-- Starts a VoxelManipulator-based transaction.
|
||||||
|
--
|
||||||
|
-- During a VM transaction, calls to vm_get_node and vm_swap_node operate on a
|
||||||
|
-- cached copy of the world loaded via VoxelManipulators. That cache can later
|
||||||
|
-- be committed to the real map by means of vm_commit or discarded by means of
|
||||||
|
-- vm_abort.
|
||||||
|
function mesecon.vm_begin()
|
||||||
|
vm_cache = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon.forceloaded_blocks = {}
|
-- Finishes a VoxelManipulator-based transaction, freeing the VMs and map data
|
||||||
|
-- and writing back any modified areas.
|
||||||
|
function mesecon.vm_commit()
|
||||||
|
for hash, tbl in pairs(vm_cache) do
|
||||||
|
if tbl.dirty then
|
||||||
|
local vm = tbl.vm
|
||||||
|
vm:set_data(tbl.data)
|
||||||
|
vm:write_to_map()
|
||||||
|
vm:update_map()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
vm_cache = nil
|
||||||
|
end
|
||||||
|
|
||||||
-- get node and force-load area
|
-- Finishes a VoxelManipulator-based transaction, freeing the VMs and throwing
|
||||||
function mesecon.get_node_force(pos)
|
-- away any modified areas.
|
||||||
|
function mesecon.vm_abort()
|
||||||
|
vm_cache = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Gets the cache entry covering a position, populating it if necessary.
|
||||||
|
local function vm_get_or_create_entry(pos)
|
||||||
local hash = hash_blockpos(pos)
|
local hash = hash_blockpos(pos)
|
||||||
|
local tbl = vm_cache[hash]
|
||||||
if mesecon.forceloaded_blocks[hash] == nil then
|
if not tbl then
|
||||||
-- if no more forceload spaces are available, try again next time
|
local vm = minetest.get_voxel_manip(pos, pos)
|
||||||
if minetest.forceload_block(pos) then
|
local min_pos, max_pos = vm:get_emerged_area()
|
||||||
mesecon.forceloaded_blocks[hash] = 0
|
local va = VoxelArea:new{MinEdge = min_pos, MaxEdge = max_pos}
|
||||||
|
tbl = {vm = vm, va = va, data = vm:get_data(), param1 = vm:get_light_data(), param2 = vm:get_param2_data(), dirty = false}
|
||||||
|
vm_cache[hash] = tbl
|
||||||
end
|
end
|
||||||
else
|
return tbl
|
||||||
mesecon.forceloaded_blocks[hash] = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
return minetest.get_node_or_nil(pos)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_globalstep(function (dtime)
|
-- Gets the node at a given position during a VoxelManipulator-based
|
||||||
for hash, time in pairs(mesecon.forceloaded_blocks) do
|
-- transaction.
|
||||||
-- unload forceloaded blocks after 10 minutes without usage
|
function mesecon.vm_get_node(pos)
|
||||||
if (time > mesecon.setting("forceload_timeout", 600)) then
|
local tbl = vm_get_or_create_entry(pos)
|
||||||
minetest.forceload_free_block(unhash_blockpos(hash))
|
local index = tbl.va:indexp(pos)
|
||||||
mesecon.forceloaded_blocks[hash] = nil
|
local node_value = tbl.data[index]
|
||||||
|
if node_value == core.CONTENT_IGNORE then
|
||||||
|
return nil
|
||||||
else
|
else
|
||||||
mesecon.forceloaded_blocks[hash] = time + dtime
|
local node_param1 = tbl.param1[index]
|
||||||
|
local node_param2 = tbl.param2[index]
|
||||||
|
return {name = minetest.get_name_from_content_id(node_value), param1 = node_param1, param2 = node_param2}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
|
||||||
|
|
||||||
-- Store and read the forceloaded blocks to / from a file
|
-- Sets a node’s name during a VoxelManipulator-based transaction.
|
||||||
-- so that those blocks are remembered when the game
|
--
|
||||||
-- is restarted
|
-- Existing param1, param2, and metadata are left alone.
|
||||||
mesecon.forceloaded_blocks = mesecon.file2table("mesecon_forceloaded")
|
function mesecon.vm_swap_node(pos, name)
|
||||||
minetest.register_on_shutdown(function()
|
local tbl = vm_get_or_create_entry(pos)
|
||||||
mesecon.table2file("mesecon_forceloaded", mesecon.forceloaded_blocks)
|
local index = tbl.va:indexp(pos)
|
||||||
end)
|
tbl.data[index] = minetest.get_content_id(name)
|
||||||
|
tbl.dirty = true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Gets the node at a given position, regardless of whether it is loaded or
|
||||||
|
-- not, respecting a transaction if one is in progress.
|
||||||
|
--
|
||||||
|
-- Outside a VM transaction, if the mapblock is not loaded, it is pulled into
|
||||||
|
-- the server’s main map data cache and then accessed from there.
|
||||||
|
--
|
||||||
|
-- Inside a VM transaction, the transaction’s VM cache is used.
|
||||||
|
function mesecon.get_node_force(pos)
|
||||||
|
if vm_cache then
|
||||||
|
return mesecon.vm_get_node(pos)
|
||||||
|
else
|
||||||
|
local node = minetest.get_node_or_nil(pos)
|
||||||
|
if node == nil then
|
||||||
|
-- Node is not currently loaded; use a VoxelManipulator to prime
|
||||||
|
-- the mapblock cache and try again.
|
||||||
|
minetest.get_voxel_manip(pos, pos)
|
||||||
|
node = minetest.get_node_or_nil(pos)
|
||||||
|
end
|
||||||
|
return node
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Swaps the node at a given position, regardless of whether it is loaded or
|
||||||
|
-- not, respecting a transaction if one is in progress.
|
||||||
|
--
|
||||||
|
-- Outside a VM transaction, if the mapblock is not loaded, it is pulled into
|
||||||
|
-- the server’s main map data cache and then accessed from there.
|
||||||
|
--
|
||||||
|
-- Inside a VM transaction, the transaction’s VM cache is used.
|
||||||
|
--
|
||||||
|
-- This function can only be used to change the node’s name, not its parameters
|
||||||
|
-- or metadata.
|
||||||
|
function mesecon.swap_node_force(pos, name)
|
||||||
|
if vm_cache then
|
||||||
|
return mesecon.vm_swap_node(pos, name)
|
||||||
|
else
|
||||||
|
-- This serves to both ensure the mapblock is loaded and also hand us
|
||||||
|
-- the old node table so we can preserve param2.
|
||||||
|
local node = mesecon.get_node_force(pos)
|
||||||
|
node.name = name
|
||||||
|
minetest.swap_node(pos, node)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Autoconnect Hooks
|
||||||
|
-- Nodes like conductors may change their appearance and their connection rules
|
||||||
|
-- right after being placed or after being dug, e.g. the default wires use this
|
||||||
|
-- to automatically connect to linking nodes after placement.
|
||||||
|
-- After placement, the update function will be executed immediately so that the
|
||||||
|
-- possibly changed rules can be taken into account when recalculating the circuit.
|
||||||
|
-- After digging, the update function will be queued and executed after
|
||||||
|
-- recalculating the circuit. The update function must take care of updating the
|
||||||
|
-- node at the given position itself, but also all of the other nodes the given
|
||||||
|
-- position may have (had) a linking connection to.
|
||||||
|
mesecon.autoconnect_hooks = {}
|
||||||
|
|
||||||
|
-- name: A unique name for the hook, e.g. "foowire". Used to name the actionqueue function.
|
||||||
|
-- fct: The update function with parameters function(pos, node)
|
||||||
|
function mesecon.register_autoconnect_hook(name, fct)
|
||||||
|
mesecon.autoconnect_hooks[name] = fct
|
||||||
|
mesecon.queue:add_function("autoconnect_hook_"..name, fct)
|
||||||
|
end
|
||||||
|
|
||||||
|
function mesecon.execute_autoconnect_hooks_now(pos, node)
|
||||||
|
for _, fct in pairs(mesecon.autoconnect_hooks) do
|
||||||
|
fct(pos, node)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function mesecon.execute_autoconnect_hooks_queue(pos, node)
|
||||||
|
for name in pairs(mesecon.autoconnect_hooks) do
|
||||||
|
mesecon.queue:add_action(pos, "autoconnect_hook_"..name, {node})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -4,12 +4,12 @@
|
||||||
|
|
||||||
mesecon.button_turnoff = function (pos)
|
mesecon.button_turnoff = function (pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
if node.name=="mesecons_button:button_stone_on" then --has not been dug
|
if node.name == "mesecons_button:button_stone_on" then -- has not been dug
|
||||||
minetest.swap_node(pos, {name = "mesecons_button:button_stone_off", param2=node.param2})
|
minetest.swap_node(pos, {name = "mesecons_button:button_stone_off", param2=node.param2})
|
||||||
minetest.sound_play("mesecons_button_pop", {pos=pos})
|
minetest.sound_play("mesecons_button_pop", {pos=pos})
|
||||||
local rules = mesecon.rules.buttonlike_get(node)
|
local rules = mesecon.rules.buttonlike_get(node)
|
||||||
mesecon.receptor_off(pos, rules)
|
mesecon.receptor_off(pos, rules)
|
||||||
elseif node.name=="mesecons_button:button_wood_on" then --has not been dug
|
elseif node.name == "mesecons_button:button_wood_on" then -- has not been dug
|
||||||
minetest.swap_node(pos, {name = "mesecons_button:button_wood_off", param2=node.param2})
|
minetest.swap_node(pos, {name = "mesecons_button:button_wood_off", param2=node.param2})
|
||||||
minetest.sound_play("mesecons_button_pop", {pos=pos})
|
minetest.sound_play("mesecons_button_pop", {pos=pos})
|
||||||
local rules = mesecon.rules.buttonlike_get(node)
|
local rules = mesecon.rules.buttonlike_get(node)
|
||||||
|
@ -17,38 +17,37 @@ mesecon.button_turnoff = function (pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local boxes_off = { -4/16, -2/16, 8/16, 4/16, 2/16, 6/16 } -- The button
|
local boxes_off = { -4/16, -2/16, 8/16, 4/16, 2/16, 6/16 }
|
||||||
local boxes_on = { -4/16, -2/16, 8/16, 4/16, 2/16, 7/16 } -- The button
|
local boxes_on = { -4/16, -2/16, 8/16, 4/16, 2/16, 7/16 }
|
||||||
|
|
||||||
minetest.register_node("mesecons_button:button_stone_off", {
|
minetest.register_node("mesecons_button:button_stone_off", {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
tiles = {"default_stone.png"},
|
tiles = {"default_stone.png"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
|
is_ground_content = false,
|
||||||
legacy_wallmounted = true,
|
legacy_wallmounted = true,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
|
on_rotate = mesecon.buttonlike_onrotate,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
selection_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = boxes_off
|
fixed = boxes_off
|
||||||
},
|
},
|
||||||
node_box = {
|
groups = {dig_immediate = 2},
|
||||||
type = "fixed",
|
|
||||||
fixed = boxes_off -- the button itself
|
|
||||||
},
|
|
||||||
groups = {dig_immediate=2, attached_node=1},
|
|
||||||
description = "Stone Button",
|
description = "Stone Button",
|
||||||
on_punch = function (pos, node)
|
on_punch = function (pos, node)
|
||||||
minetest.swap_node(pos, {name = "mesecons_button:button_stone_on", param2=node.param2})
|
minetest.swap_node(pos, {name = "mesecons_button:button_stone_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})
|
||||||
minetest.after(1, mesecon.button_turnoff, pos)
|
minetest.get_node_timer(pos):start(1)
|
||||||
end,
|
end,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
mesecons = {receptor = {
|
mesecons = {receptor = {
|
||||||
state = mesecon.state.off,
|
state = mesecon.state.off,
|
||||||
rules = mesecon.rules.buttonlike_get
|
rules = mesecon.rules.buttonlike_get
|
||||||
}}
|
}},
|
||||||
|
on_blast = mesecon.on_blastnode,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("mesecons_button:button_stone_on", {
|
minetest.register_node("mesecons_button:button_stone_on", {
|
||||||
|
@ -56,82 +55,25 @@ minetest.register_node("mesecons_button:button_stone_on", {
|
||||||
tiles = {"default_stone.png"},
|
tiles = {"default_stone.png"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
|
is_ground_content = false,
|
||||||
legacy_wallmounted = true,
|
legacy_wallmounted = true,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
|
on_rotate = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
selection_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = boxes_on
|
fixed = boxes_on
|
||||||
},
|
},
|
||||||
node_box = {
|
groups = {dig_immediate = 2, not_in_creative_inventory = 1},
|
||||||
type = "fixed",
|
drop = "mesecons_button:button_stone_off",
|
||||||
fixed = boxes_on -- the button itself
|
|
||||||
},
|
|
||||||
groups = {dig_immediate=2, not_in_creative_inventory=1},
|
|
||||||
drop = 'mesecons_button:button_stone_off',
|
|
||||||
description = "Stone Button",
|
description = "Stone Button",
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
mesecons = {receptor = {
|
mesecons = {receptor = {
|
||||||
state = mesecon.state.on,
|
state = mesecon.state.on,
|
||||||
rules = mesecon.rules.buttonlike_get
|
rules = mesecon.rules.buttonlike_get
|
||||||
}}
|
}},
|
||||||
})
|
on_timer = mesecon.button_turnoff,
|
||||||
|
on_blast = mesecon.on_blastnode,
|
||||||
minetest.register_node("mesecons_button:button_wood_off", {
|
|
||||||
drawtype = "nodebox",
|
|
||||||
tiles = {"default_wood.png"},
|
|
||||||
paramtype = "light",
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
legacy_wallmounted = true,
|
|
||||||
walkable = false,
|
|
||||||
sunlight_propagates = true,
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = boxes_off
|
|
||||||
},
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = boxes_off -- the button itself
|
|
||||||
},
|
|
||||||
groups = {dig_immediate=2},
|
|
||||||
description = "Wood Button",
|
|
||||||
on_punch = function (pos, node)
|
|
||||||
minetest.swap_node(pos, {name = "mesecons_button:button_wood_on", param2=node.param2})
|
|
||||||
mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
|
||||||
minetest.sound_play("mesecons_button_push", {pos=pos})
|
|
||||||
minetest.after(1, mesecon.button_turnoff, pos)
|
|
||||||
end,
|
|
||||||
sounds = default.node_sound_stone_defaults(),
|
|
||||||
mesecons = {receptor = {
|
|
||||||
state = mesecon.state.off,
|
|
||||||
rules = mesecon.rules.buttonlike_get
|
|
||||||
}}
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("mesecons_button:button_wood_on", {
|
|
||||||
drawtype = "nodebox",
|
|
||||||
tiles = {"default_wood.png"},
|
|
||||||
paramtype = "light",
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
legacy_wallmounted = true,
|
|
||||||
walkable = false,
|
|
||||||
sunlight_propagates = true,
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = boxes_on
|
|
||||||
},
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = boxes_on -- the button itself
|
|
||||||
},
|
|
||||||
groups = {dig_immediate=2, not_in_creative_inventory=1},
|
|
||||||
drop = 'mesecons_button:button_wood_off',
|
|
||||||
description = "Wood Button",
|
|
||||||
sounds = default.node_sound_stone_defaults(),
|
|
||||||
mesecons = {receptor = {
|
|
||||||
state = mesecon.state.on,
|
|
||||||
rules = mesecon.rules.buttonlike_get
|
|
||||||
}}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -141,6 +83,62 @@ minetest.register_craft({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_node("mesecons_button:button_wood_off", {
|
||||||
|
drawtype = "nodebox",
|
||||||
|
tiles = {"default_wood.png"},
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
is_ground_content = false,
|
||||||
|
legacy_wallmounted = true,
|
||||||
|
walkable = false,
|
||||||
|
on_rotate = mesecon.buttonlike_onrotate,
|
||||||
|
sunlight_propagates = true,
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = boxes_off
|
||||||
|
},
|
||||||
|
groups = {dig_immediate = 2},
|
||||||
|
description = "Wood Button",
|
||||||
|
on_punch = function (pos, node)
|
||||||
|
minetest.swap_node(pos, {name = "mesecons_button:button_wood_on", param2=node.param2})
|
||||||
|
mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||||
|
minetest.sound_play("mesecons_button_push", {pos=pos})
|
||||||
|
minetest.get_node_timer(pos):start(1)
|
||||||
|
end,
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
mesecons = {receptor = {
|
||||||
|
state = mesecon.state.off,
|
||||||
|
rules = mesecon.rules.buttonlike_get
|
||||||
|
}},
|
||||||
|
on_blast = mesecon.on_blastnode,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("mesecons_button:button_wood_on", {
|
||||||
|
drawtype = "nodebox",
|
||||||
|
tiles = {"default_wood.png"},
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
is_ground_content = false,
|
||||||
|
legacy_wallmounted = true,
|
||||||
|
walkable = false,
|
||||||
|
on_rotate = false,
|
||||||
|
sunlight_propagates = true,
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = boxes_on
|
||||||
|
},
|
||||||
|
groups = {dig_immediate = 2, not_in_creative_inventory = 1},
|
||||||
|
drop = "mesecons_button:button_wood_off",
|
||||||
|
description = "Wood Button",
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
mesecons = {receptor = {
|
||||||
|
state = mesecon.state.on,
|
||||||
|
rules = mesecon.rules.buttonlike_get
|
||||||
|
}},
|
||||||
|
on_timer = mesecon.button_turnoff,
|
||||||
|
on_blast = mesecon.on_blastnode,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mesecons_button:button_wood_off 2",
|
output = "mesecons_button:button_wood_off 2",
|
||||||
recipe = {
|
recipe = {
|
||||||
|
|
|
@ -36,9 +36,9 @@ 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}
|
||||||
end
|
end
|
||||||
|
|
||||||
local delaytime
|
local delaytime
|
||||||
|
@ -99,7 +99,7 @@ minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), {
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
is_ground_content = true,
|
is_ground_content = false,
|
||||||
drop = 'mesecons_delayer:delayer_off_1',
|
drop = 'mesecons_delayer:delayer_off_1',
|
||||||
on_punch = function (pos, node)
|
on_punch = function (pos, node)
|
||||||
if node.name=="mesecons_delayer:delayer_off_1" then
|
if node.name=="mesecons_delayer:delayer_off_1" then
|
||||||
|
@ -126,7 +126,8 @@ minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), {
|
||||||
rules = delayer_get_input_rules,
|
rules = delayer_get_input_rules,
|
||||||
action_on = delayer_activate
|
action_on = delayer_activate
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
on_blast = mesecon.on_blastnode,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
@ -154,7 +155,7 @@ minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), {
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
is_ground_content = true,
|
is_ground_content = false,
|
||||||
drop = 'mesecons_delayer:delayer_off_1',
|
drop = 'mesecons_delayer:delayer_off_1',
|
||||||
on_punch = function (pos, node)
|
on_punch = function (pos, node)
|
||||||
if node.name=="mesecons_delayer:delayer_on_1" then
|
if node.name=="mesecons_delayer:delayer_on_1" then
|
||||||
|
@ -169,6 +170,7 @@ minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), {
|
||||||
end,
|
end,
|
||||||
delayer_time = delaytime,
|
delayer_time = delaytime,
|
||||||
delayer_offstate = "mesecons_delayer:delayer_off_"..tostring(i),
|
delayer_offstate = "mesecons_delayer:delayer_off_"..tostring(i),
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
mesecons = {
|
mesecons = {
|
||||||
receptor =
|
receptor =
|
||||||
{
|
{
|
||||||
|
@ -180,7 +182,8 @@ minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), {
|
||||||
rules = delayer_get_input_rules,
|
rules = delayer_get_input_rules,
|
||||||
action_off = delayer_deactivate
|
action_off = delayer_deactivate
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
on_blast = mesecon.on_blastnode,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,49 @@
|
||||||
|
local lightstone_rules = {
|
||||||
|
{x=0, y=0, z=-1},
|
||||||
|
{x=1, y=0, z=0},
|
||||||
|
{x=-1, y=0, z=0},
|
||||||
|
{x=0, y=0, z=1},
|
||||||
|
{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=0, y=1, z=1},
|
||||||
|
{x=0, y=-1, z=1},
|
||||||
|
{x=0, y=1, z=-1},
|
||||||
|
{x=0, y=-1, z=-1},
|
||||||
|
{x=0, y=-1, z=0},
|
||||||
|
}
|
||||||
|
|
||||||
minetest.register_node("mesecons_lightstone:lightstone_off", {
|
minetest.register_node("mesecons_lightstone:lightstone_off", {
|
||||||
tiles = {"jeija_lightstone_gray_off.png"},
|
tiles = {"jeija_lightstone_gray_off.png"},
|
||||||
|
is_ground_content = false,
|
||||||
groups = {cracky=2, mesecon_effector_off = 1, mesecon = 2},
|
groups = {cracky=2, mesecon_effector_off = 1, mesecon = 2},
|
||||||
description= "Bluestone Lamp",
|
description = "Bluestone Lamp",
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
mesecons = {effector = {
|
mesecons = {effector = {
|
||||||
|
rules = lightstone_rules,
|
||||||
action_on = function (pos, node)
|
action_on = function (pos, node)
|
||||||
minetest.swap_node(pos, {name = "mesecons_lightstone:lightstone_on", param2 = node.param2})
|
minetest.swap_node(pos, {name = "mesecons_lightstone:lightstone_on", param2 = node.param2})
|
||||||
end,
|
end,
|
||||||
}}
|
}},
|
||||||
|
on_blast = mesecon.on_blastnode,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("mesecons_lightstone:lightstone_on", {
|
minetest.register_node("mesecons_lightstone:lightstone_on", {
|
||||||
tiles = {"jeija_lightstone_gray_on.png"},
|
tiles = {"jeija_lightstone_gray_on.png"},
|
||||||
|
is_ground_content = false,
|
||||||
groups = {cracky=2,not_in_creative_inventory=1, mesecon = 2},
|
groups = {cracky=2,not_in_creative_inventory=1, mesecon = 2},
|
||||||
drop = "mesecons_lightstone:lightstone_off",
|
drop = "mesecons_lightstone:lightstone_off",
|
||||||
light_source = default.LIGHT_MAX-2,
|
light_source = minetest.LIGHT_MAX - 2,
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
mesecons = {effector = {
|
mesecons = {effector = {
|
||||||
|
rules = lightstone_rules,
|
||||||
action_off = function (pos, node)
|
action_off = function (pos, node)
|
||||||
minetest.swap_node(pos, {name = "mesecons_lightstone:lightstone_off", param2 = node.param2})
|
minetest.swap_node(pos, {name = "mesecons_lightstone:lightstone_off", param2 = node.param2})
|
||||||
end,
|
end,
|
||||||
}}
|
}},
|
||||||
})
|
on_blast = mesecon.on_blastnode,
|
||||||
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
output = "mesecons_lightstone:lightstone_off",
|
output = "mesecons_lightstone:lightstone_off",
|
||||||
|
|
|
@ -55,8 +55,6 @@ end
|
||||||
|
|
||||||
-- tests if the node can be pushed into, e.g. air, water, grass
|
-- tests if the node can be pushed into, e.g. air, water, grass
|
||||||
local function node_replaceable(name)
|
local function node_replaceable(name)
|
||||||
if name == "ignore" then return true end
|
|
||||||
|
|
||||||
if minetest.registered_nodes[name] then
|
if minetest.registered_nodes[name] then
|
||||||
return minetest.registered_nodes[name].buildable_to or false
|
return minetest.registered_nodes[name].buildable_to or false
|
||||||
end
|
end
|
||||||
|
@ -165,6 +163,10 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sti
|
||||||
-- remove all nodes
|
-- remove all nodes
|
||||||
for _, n in ipairs(nodes) do
|
for _, n in ipairs(nodes) do
|
||||||
n.meta = minetest.get_meta(n.pos):to_table()
|
n.meta = minetest.get_meta(n.pos):to_table()
|
||||||
|
local node_timer = minetest.get_node_timer(n.pos)
|
||||||
|
if node_timer:is_started() then
|
||||||
|
n.node_timer = {node_timer:get_timeout(), node_timer:get_elapsed()}
|
||||||
|
end
|
||||||
minetest.remove_node(n.pos)
|
minetest.remove_node(n.pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -179,6 +181,9 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sti
|
||||||
|
|
||||||
minetest.set_node(np, n.node)
|
minetest.set_node(np, n.node)
|
||||||
minetest.get_meta(np):from_table(n.meta)
|
minetest.get_meta(np):from_table(n.meta)
|
||||||
|
if n.node_timer then
|
||||||
|
minetest.get_node_timer(np):set(unpack(n.node_timer))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local moved_nodes = {}
|
local moved_nodes = {}
|
||||||
|
@ -190,6 +195,7 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sti
|
||||||
moved_nodes[i].pos = nodes[i].pos
|
moved_nodes[i].pos = nodes[i].pos
|
||||||
moved_nodes[i].node = nodes[i].node
|
moved_nodes[i].node = nodes[i].node
|
||||||
moved_nodes[i].meta = nodes[i].meta
|
moved_nodes[i].meta = nodes[i].meta
|
||||||
|
moved_nodes[i].node_timer = nodes[i].node_timer
|
||||||
end
|
end
|
||||||
|
|
||||||
on_mvps_move(moved_nodes)
|
on_mvps_move(moved_nodes)
|
||||||
|
@ -197,53 +203,83 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sti
|
||||||
return true, nodes, oldstack
|
return true, nodes, oldstack
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon.register_on_mvps_move(function(moved_nodes)
|
function mesecon.mvps_move_objects(pos, dir, nodestack, movefactor)
|
||||||
for _, n in ipairs(moved_nodes) do
|
|
||||||
mesecon.on_placenode(n.pos, n.node)
|
|
||||||
mesecon.update_autoconnect(n.pos)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
function mesecon.mvps_move_objects(pos, dir, nodestack)
|
|
||||||
local objects_to_move = {}
|
local objects_to_move = {}
|
||||||
|
local dir_k
|
||||||
-- Move object at tip of stack, pushpos is position at tip of stack
|
local dir_l
|
||||||
local pushpos = vector.add(pos, vector.multiply(dir, #nodestack))
|
for k, v in pairs(dir) do
|
||||||
|
if v ~= 0 then
|
||||||
local objects = minetest.get_objects_inside_radius(pushpos, 1)
|
dir_k = k
|
||||||
for _, obj in ipairs(objects) do
|
dir_l = v
|
||||||
table.insert(objects_to_move, obj)
|
break
|
||||||
end
|
|
||||||
|
|
||||||
-- Move objects lying/standing on the stack (before it was pushed - oldstack)
|
|
||||||
if tonumber(minetest.setting_get("movement_gravity")) > 0 and dir.y == 0 then
|
|
||||||
-- If gravity positive and dir horizontal, push players standing on the stack
|
|
||||||
for _, n in ipairs(nodestack) do
|
|
||||||
local p_above = vector.add(n.pos, {x=0, y=1, z=0})
|
|
||||||
local objects = minetest.get_objects_inside_radius(p_above, 1)
|
|
||||||
for _, obj in ipairs(objects) do
|
|
||||||
table.insert(objects_to_move, obj)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
movefactor = movefactor or 1
|
||||||
|
dir = vector.multiply(dir, movefactor)
|
||||||
|
for id, obj in pairs(minetest.object_refs) do
|
||||||
|
local obj_pos = obj:get_pos()
|
||||||
|
local cbox = obj:get_properties().collisionbox
|
||||||
|
local min_pos = vector.add(obj_pos, vector.new(cbox[1], cbox[2], cbox[3]))
|
||||||
|
local max_pos = vector.add(obj_pos, vector.new(cbox[4], cbox[5], cbox[6]))
|
||||||
|
local ok = true
|
||||||
|
for k, v in pairs(pos) do
|
||||||
|
local edge1, edge2
|
||||||
|
if k ~= dir_k then
|
||||||
|
edge1 = v - 0.51 -- More than 0.5 to move objects near to the stack.
|
||||||
|
edge2 = v + 0.51
|
||||||
|
else
|
||||||
|
edge1 = v - 0.5 * dir_l
|
||||||
|
edge2 = v + (#nodestack + 0.5 * movefactor) * dir_l
|
||||||
|
-- Make sure, edge1 is bigger than edge2:
|
||||||
|
if edge1 > edge2 then
|
||||||
|
edge1, edge2 = edge2, edge1
|
||||||
end
|
end
|
||||||
|
end
|
||||||
for _, obj in ipairs(objects_to_move) do
|
if min_pos[k] > edge2 or max_pos[k] < edge1 then
|
||||||
local entity = obj:get_luaentity()
|
ok = false
|
||||||
if not entity or not mesecon.is_mvps_unmov(entity.name) then
|
break
|
||||||
local np = vector.add(obj:getpos(), dir)
|
end
|
||||||
|
end
|
||||||
--move only if destination is not solid
|
if ok then
|
||||||
|
local ent = obj:get_luaentity()
|
||||||
|
if obj:is_player() or (ent and not mesecon.is_mvps_unmov(ent.name)) then
|
||||||
|
local np = vector.add(obj_pos, dir)
|
||||||
|
-- Move only if destination is not solid or object is inside stack:
|
||||||
local nn = minetest.get_node(np)
|
local nn = minetest.get_node(np)
|
||||||
if not ((not minetest.registered_nodes[nn.name])
|
local node_def = minetest.registered_nodes[nn.name]
|
||||||
or minetest.registered_nodes[nn.name].walkable) then
|
local obj_offset = dir_l * (obj_pos[dir_k] - pos[dir_k])
|
||||||
obj:setpos(np)
|
if (node_def and not node_def.walkable) or
|
||||||
|
(obj_offset >= 0 and
|
||||||
|
obj_offset <= #nodestack - 0.5) then
|
||||||
|
obj:move_to(np)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Never push into unloaded blocks. Don’t try to pull from them, either.
|
||||||
|
-- TODO: load blocks instead, as with wires.
|
||||||
|
mesecon.register_mvps_stopper("ignore")
|
||||||
|
|
||||||
mesecon.register_mvps_stopper("doors:door_steel_b_1")
|
mesecon.register_mvps_stopper("doors:door_steel_b_1")
|
||||||
mesecon.register_mvps_stopper("doors:door_steel_t_1")
|
mesecon.register_mvps_stopper("doors:door_steel_t_1")
|
||||||
mesecon.register_mvps_stopper("doors:door_steel_b_2")
|
mesecon.register_mvps_stopper("doors:door_steel_b_2")
|
||||||
mesecon.register_mvps_stopper("doors:door_steel_t_2")
|
mesecon.register_mvps_stopper("doors:door_steel_t_2")
|
||||||
mesecon.register_mvps_stopper("default:furnace")
|
mesecon.register_mvps_stopper("default:furnace")
|
||||||
|
mesecon.register_on_mvps_move(mesecon.move_hot_nodes)
|
||||||
|
mesecon.register_on_mvps_move(function(moved_nodes)
|
||||||
|
for i = 1, #moved_nodes do
|
||||||
|
local moved_node = moved_nodes[i]
|
||||||
|
mesecon.on_placenode(moved_node.pos, moved_node.node)
|
||||||
|
minetest.after(0, function()
|
||||||
|
minetest.check_for_falling(moved_node.oldpos)
|
||||||
|
minetest.check_for_falling(moved_node.pos)
|
||||||
|
end)
|
||||||
|
local node_def = minetest.registered_nodes[moved_node.node.name]
|
||||||
|
if node_def and node_def.mesecon and node_def.mesecon.on_mvps_move then
|
||||||
|
node_def.mesecon.on_mvps_move(moved_node.pos, moved_node.node,
|
||||||
|
moved_node.oldpos, moved_node.meta)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
|
@ -1,25 +1,20 @@
|
||||||
minetest.register_node("mesecons_noteblock:noteblock", {
|
minetest.register_node("mesecons_noteblock:noteblock", {
|
||||||
description = "Noteblock",
|
description = "Noteblock",
|
||||||
tiles = {"mesecons_noteblock.png"},
|
tiles = {"mesecons_noteblock.png"},
|
||||||
|
is_ground_content = false,
|
||||||
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2},
|
groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2},
|
||||||
drawtype = "allfaces_optional",
|
|
||||||
visual_scale = 1.3,
|
|
||||||
paramtype="light",
|
|
||||||
after_place_node = function(pos)
|
|
||||||
minetest.add_node(pos, {name="mesecons_noteblock:noteblock", param2=0})
|
|
||||||
end,
|
|
||||||
on_punch = function (pos, node) -- change sound when punched
|
on_punch = function (pos, node) -- change sound when punched
|
||||||
local param2 = node.param2+1
|
node.param2 = (node.param2+1)%12
|
||||||
if param2==12 then param2=0 end
|
mesecon.noteblock_play(pos, node.param2)
|
||||||
minetest.add_node(pos, {name = node.name, param2 = param2})
|
minetest.set_node(pos, node)
|
||||||
mesecon.noteblock_play(pos, param2)
|
|
||||||
end,
|
end,
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
mesecons = {effector = { -- play sound when activated
|
mesecons = {effector = { -- play sound when activated
|
||||||
action_on = function (pos, node)
|
action_on = function (pos, node)
|
||||||
mesecon.noteblock_play(pos, node.param2)
|
mesecon.noteblock_play(pos, node.param2)
|
||||||
end
|
end
|
||||||
}}
|
}},
|
||||||
|
on_blast = mesecon.on_blastnode,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -31,49 +26,46 @@ minetest.register_craft({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local soundnames = {
|
||||||
|
[0] = "mesecons_noteblock_csharp",
|
||||||
|
"mesecons_noteblock_d",
|
||||||
|
"mesecons_noteblock_dsharp",
|
||||||
|
"mesecons_noteblock_e",
|
||||||
|
"mesecons_noteblock_f",
|
||||||
|
"mesecons_noteblock_fsharp",
|
||||||
|
"mesecons_noteblock_g",
|
||||||
|
"mesecons_noteblock_gsharp",
|
||||||
|
|
||||||
|
"mesecons_noteblock_a",
|
||||||
|
"mesecons_noteblock_asharp",
|
||||||
|
"mesecons_noteblock_b",
|
||||||
|
"mesecons_noteblock_c"
|
||||||
|
}
|
||||||
|
|
||||||
|
local node_sounds = {
|
||||||
|
["default:glass"] = "mesecons_noteblock_hihat",
|
||||||
|
["default:stone"] = "mesecons_noteblock_kick",
|
||||||
|
["default:lava_source"] = "fire_fire",
|
||||||
|
["default:chest"] = "mesecons_noteblock_snare",
|
||||||
|
["default:tree"] = "mesecons_noteblock_crash",
|
||||||
|
["default:wood"] = "mesecons_noteblock_litecrash",
|
||||||
|
["default:coalblock"] = "tnt_explode",
|
||||||
|
}
|
||||||
|
|
||||||
mesecon.noteblock_play = function (pos, param2)
|
mesecon.noteblock_play = function (pos, param2)
|
||||||
local soundname
|
pos.y = pos.y-1
|
||||||
if param2==8 then
|
local nodeunder = minetest.get_node(pos).name
|
||||||
soundname="mesecons_noteblock_a"
|
local soundname = node_sounds[nodeunder]
|
||||||
elseif param2==9 then
|
if not soundname then
|
||||||
soundname="mesecons_noteblock_asharp"
|
soundname = soundnames[param2]
|
||||||
elseif param2==10 then
|
if not soundname then
|
||||||
soundname="mesecons_noteblock_b"
|
minetest.log("error", "[mesecons_noteblock] No soundname found, test param2")
|
||||||
elseif param2==11 then
|
return
|
||||||
soundname="mesecons_noteblock_c"
|
|
||||||
elseif param2==0 then
|
|
||||||
soundname="mesecons_noteblock_csharp"
|
|
||||||
elseif param2==1 then
|
|
||||||
soundname="mesecons_noteblock_d"
|
|
||||||
elseif param2==2 then
|
|
||||||
soundname="mesecons_noteblock_dsharp"
|
|
||||||
elseif param2==3 then
|
|
||||||
soundname="mesecons_noteblock_e"
|
|
||||||
elseif param2==4 then
|
|
||||||
soundname="mesecons_noteblock_f"
|
|
||||||
elseif param2==5 then
|
|
||||||
soundname="mesecons_noteblock_fsharp"
|
|
||||||
elseif param2==6 then
|
|
||||||
soundname="mesecons_noteblock_g"
|
|
||||||
elseif param2==7 then
|
|
||||||
soundname="mesecons_noteblock_gsharp"
|
|
||||||
end
|
end
|
||||||
local block_below_name = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name
|
if nodeunder == "default:steelblock" then
|
||||||
if block_below_name == "default:glass" then
|
soundname = soundname.. 2
|
||||||
soundname="mesecons_noteblock_hihat"
|
|
||||||
end
|
end
|
||||||
if block_below_name == "default:stone" then
|
|
||||||
soundname="mesecons_noteblock_kick"
|
|
||||||
end
|
end
|
||||||
if block_below_name == "default:chest" then
|
pos.y = pos.y+1
|
||||||
soundname="mesecons_noteblock_snare"
|
minetest.sound_play(soundname, {pos = pos})
|
||||||
end
|
|
||||||
if block_below_name == "default:tree" then
|
|
||||||
soundname="mesecons_noteblock_crash"
|
|
||||||
end
|
|
||||||
if block_below_name == "default:wood" then
|
|
||||||
soundname="mesecons_noteblock_litecrash"
|
|
||||||
end
|
|
||||||
minetest.sound_play(soundname,
|
|
||||||
{pos = pos, gain = 1.0, max_hear_distance = 32,})
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -195,8 +195,6 @@ minetest.register_node("mesecons_pistons:piston_normal_on", {
|
||||||
"mesecons_piston_back.png",
|
"mesecons_piston_back.png",
|
||||||
"mesecons_piston_on_front.png"
|
"mesecons_piston_on_front.png"
|
||||||
},
|
},
|
||||||
inventory_image = "mesecons_piston_top.png",
|
|
||||||
wield_image = "mesecons_piston_top.png",
|
|
||||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
|
@ -276,12 +274,10 @@ minetest.register_node("mesecons_pistons:piston_sticky_on", {
|
||||||
"mesecons_piston_back.png",
|
"mesecons_piston_back.png",
|
||||||
"mesecons_piston_on_front.png"
|
"mesecons_piston_on_front.png"
|
||||||
},
|
},
|
||||||
inventory_image = "mesecons_piston_top.png",
|
|
||||||
wield_image = "mesecons_piston_top.png",
|
|
||||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
drop = "mesecons_pistons:piston_normal_off",
|
drop = "mesecons_pistons:piston_sticky_off",
|
||||||
after_dig_node = piston_remove_pusher,
|
after_dig_node = piston_remove_pusher,
|
||||||
node_box = piston_on_box,
|
node_box = piston_on_box,
|
||||||
selection_box = piston_on_box,
|
selection_box = piston_on_box,
|
||||||
|
@ -352,8 +348,6 @@ minetest.register_node("mesecons_pistons:piston_up_normal_off", {
|
||||||
"mesecons_piston_bottom.png",
|
"mesecons_piston_bottom.png",
|
||||||
"mesecons_piston_top.png^[transformR180",
|
"mesecons_piston_top.png^[transformR180",
|
||||||
},
|
},
|
||||||
inventory_image = "mesecons_piston_top.png",
|
|
||||||
wield_image = "mesecons_piston_top.png",
|
|
||||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
drop = "mesecons_pistons:piston_normal_off",
|
drop = "mesecons_pistons:piston_normal_off",
|
||||||
|
@ -375,8 +369,6 @@ minetest.register_node("mesecons_pistons:piston_up_normal_on", {
|
||||||
"mesecons_piston_bottom.png",
|
"mesecons_piston_bottom.png",
|
||||||
"mesecons_piston_top.png^[transformR180",
|
"mesecons_piston_top.png^[transformR180",
|
||||||
},
|
},
|
||||||
inventory_image = "mesecons_piston_top.png",
|
|
||||||
wield_image = "mesecons_piston_top.png",
|
|
||||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
|
@ -435,8 +427,6 @@ minetest.register_node("mesecons_pistons:piston_up_sticky_off", {
|
||||||
"mesecons_piston_top.png^[transformR180",
|
"mesecons_piston_top.png^[transformR180",
|
||||||
"mesecons_piston_tb.png"
|
"mesecons_piston_tb.png"
|
||||||
},
|
},
|
||||||
inventory_image = "mesecons_piston_top.png",
|
|
||||||
wield_image = "mesecons_piston_top.png",
|
|
||||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
drop = "mesecons_pistons:piston_sticky_off",
|
drop = "mesecons_pistons:piston_sticky_off",
|
||||||
|
@ -459,8 +449,6 @@ minetest.register_node("mesecons_pistons:piston_up_sticky_on", {
|
||||||
"mesecons_piston_bottom.png",
|
"mesecons_piston_bottom.png",
|
||||||
"mesecons_piston_top.png^[transformR180",
|
"mesecons_piston_top.png^[transformR180",
|
||||||
},
|
},
|
||||||
inventory_image = "mesecons_piston_top.png",
|
|
||||||
wield_image = "mesecons_piston_top.png",
|
|
||||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
|
@ -537,8 +525,6 @@ minetest.register_node("mesecons_pistons:piston_down_normal_off", {
|
||||||
"mesecons_piston_bottom.png^[transformR180",
|
"mesecons_piston_bottom.png^[transformR180",
|
||||||
"mesecons_piston_top.png",
|
"mesecons_piston_top.png",
|
||||||
},
|
},
|
||||||
inventory_image = "mesecons_piston_top.png",
|
|
||||||
wield_image = "mesecons_piston_top.png",
|
|
||||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
drop = "mesecons_pistons:piston_normal_off",
|
drop = "mesecons_pistons:piston_normal_off",
|
||||||
|
@ -561,8 +547,6 @@ minetest.register_node("mesecons_pistons:piston_down_normal_on", {
|
||||||
"mesecons_piston_bottom.png^[transformR180",
|
"mesecons_piston_bottom.png^[transformR180",
|
||||||
"mesecons_piston_top.png",
|
"mesecons_piston_top.png",
|
||||||
},
|
},
|
||||||
inventory_image = "mesecons_piston_top.png",
|
|
||||||
wield_image = "mesecons_piston_top.png",
|
|
||||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
|
@ -617,8 +601,6 @@ minetest.register_node("mesecons_pistons:piston_down_sticky_off", {
|
||||||
"mesecons_piston_bottom.png^[transformR180",
|
"mesecons_piston_bottom.png^[transformR180",
|
||||||
"mesecons_piston_top.png",
|
"mesecons_piston_top.png",
|
||||||
},
|
},
|
||||||
inventory_image = "mesecons_piston_top.png",
|
|
||||||
wield_image = "mesecons_piston_top.png",
|
|
||||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
drop = "mesecons_pistons:piston_sticky_off",
|
drop = "mesecons_pistons:piston_sticky_off",
|
||||||
|
@ -641,8 +623,6 @@ minetest.register_node("mesecons_pistons:piston_down_sticky_on", {
|
||||||
"mesecons_piston_bottom.png^[transformR180",
|
"mesecons_piston_bottom.png^[transformR180",
|
||||||
"mesecons_piston_top.png",
|
"mesecons_piston_top.png",
|
||||||
},
|
},
|
||||||
inventory_image = "mesecons_piston_top.png",
|
|
||||||
wield_image = "mesecons_piston_top.png",
|
|
||||||
groups = {cracky = 3, not_in_creative_inventory = 1},
|
groups = {cracky = 3, not_in_creative_inventory = 1},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
|
|
|
@ -8,7 +8,7 @@ local pp_box_on = {
|
||||||
fixed = { -7/16, -8/16, -7/16, 7/16, -7.5/16, 7/16 },
|
fixed = { -7/16, -8/16, -7/16, 7/16, -7.5/16, 7/16 },
|
||||||
}
|
}
|
||||||
|
|
||||||
pp_on_timer = function (pos, elapsed)
|
local function pp_on_timer(pos, elapsed)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local basename = minetest.registered_nodes[node.name].pressureplate_basename
|
local basename = minetest.registered_nodes[node.name].pressureplate_basename
|
||||||
|
|
||||||
|
@ -42,30 +42,42 @@ end
|
||||||
-- tiles_on: textures of the pressure plate when active
|
-- tiles_on: textures of the pressure plate when active
|
||||||
-- image: inventory and wield image of the pressure plate
|
-- image: inventory and wield image of the pressure plate
|
||||||
-- recipe: crafting recipe of the pressure plate
|
-- recipe: crafting recipe of the pressure plate
|
||||||
|
-- groups: groups
|
||||||
|
-- sounds: sound table
|
||||||
|
|
||||||
|
function mesecon.register_pressure_plate(basename, description, textures_off, textures_on, --[[image_w, image_i,]] recipe, groups, sounds)
|
||||||
|
local groups_off, groups_on
|
||||||
|
if not groups then
|
||||||
|
groups = {}
|
||||||
|
end
|
||||||
|
local groups_off = table.copy(groups)
|
||||||
|
local groups_on = table.copy(groups)
|
||||||
|
groups_on.not_in_creative_inventory = 1
|
||||||
|
|
||||||
function mesecon.register_pressure_plate(basename, description, textures_off, textures_on, --[[image_w, image_i,]] recipe)
|
|
||||||
mesecon.register_node(basename, {
|
mesecon.register_node(basename, {
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
-- inventory_image = image_i,
|
-- inventory_image = image_i,
|
||||||
-- wield_image = image_w,
|
-- wield_image = image_w,
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
|
is_ground_content = false,
|
||||||
description = description,
|
description = description,
|
||||||
pressureplate_basename = basename,
|
pressureplate_basename = basename,
|
||||||
on_timer = pp_on_timer,
|
on_timer = pp_on_timer,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
minetest.get_node_timer(pos):start(mesecon.setting("pplate_interval", 0.1))
|
minetest.get_node_timer(pos):start(mesecon.setting("pplate_interval", 0.1))
|
||||||
end,
|
end,
|
||||||
|
sounds = sounds,
|
||||||
},{
|
},{
|
||||||
mesecons = {receptor = { state = mesecon.state.off, rules = mesecon.rules.pplate }},
|
mesecons = {receptor = { state = mesecon.state.off, rules = mesecon.rules.pplate }},
|
||||||
node_box = pp_box_off,
|
node_box = pp_box_off,
|
||||||
selection_box = pp_box_off,
|
selection_box = pp_box_off,
|
||||||
groups = {snappy = 2, oddly_breakable_by_hand = 3},
|
groups = groups_off,
|
||||||
tiles = textures_off
|
tiles = textures_off
|
||||||
},{
|
},{
|
||||||
mesecons = {receptor = { state = mesecon.state.on, rules = mesecon.rules.pplate }},
|
mesecons = {receptor = { state = mesecon.state.on, rules = mesecon.rules.pplate }},
|
||||||
node_box = pp_box_on,
|
node_box = pp_box_on,
|
||||||
selection_box = pp_box_on,
|
selection_box = pp_box_on,
|
||||||
groups = {snappy = 2, oddly_breakable_by_hand = 3, not_in_creative_inventory = 1},
|
groups = groups_on,
|
||||||
tiles = textures_on
|
tiles = textures_on
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -80,11 +92,15 @@ mesecon.register_pressure_plate(
|
||||||
"Wooden Pressure Plate",
|
"Wooden Pressure Plate",
|
||||||
{"default_wood.png"},
|
{"default_wood.png"},
|
||||||
{"default_wood.png"},
|
{"default_wood.png"},
|
||||||
{{"default:wood", "default:wood"}})
|
{{"default:wood", "default:wood"}},
|
||||||
|
{ choppy = 3, oddly_breakable_by_hand = 3 },
|
||||||
|
default.node_sound_wood_defaults())
|
||||||
|
|
||||||
mesecon.register_pressure_plate(
|
mesecon.register_pressure_plate(
|
||||||
"mesecons_pressureplates:pressure_plate_stone",
|
"mesecons_pressureplates:pressure_plate_stone",
|
||||||
"Stone Pressure Plate",
|
"Stone Pressure Plate",
|
||||||
{"default_stone.png"},
|
{"default_stone.png"},
|
||||||
{"default_stone.png"},
|
{"default_stone.png"},
|
||||||
{{"default:cobble", "default:cobble"}})
|
{{"default:cobble", "default:cobble"}},
|
||||||
|
{ cracky = 3, oddly_breakable_by_hand = 3 },
|
||||||
|
default.node_sound_stone_defaults())
|
||||||
|
|
|
@ -6,7 +6,7 @@ minetest.register_node("mesecons_solarpanel:solar_panel_on", {
|
||||||
wield_image = "jeija_solar_panel.png",
|
wield_image = "jeija_solar_panel.png",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "wallmounted",
|
paramtype2 = "wallmounted",
|
||||||
is_ground_content = true,
|
is_ground_content = false,
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "wallmounted",
|
type = "wallmounted",
|
||||||
wall_bottom = { -8/16, -8/16, -8/16, 8/16, -2/16, 8/16 },
|
wall_bottom = { -8/16, -8/16, -8/16, 8/16, -2/16, 8/16 },
|
||||||
|
@ -17,8 +17,10 @@ minetest.register_node("mesecons_solarpanel:solar_panel_on", {
|
||||||
groups = {dig_immediate=3, not_in_creative_inventory = 1},
|
groups = {dig_immediate=3, not_in_creative_inventory = 1},
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
mesecons = {receptor = {
|
mesecons = {receptor = {
|
||||||
state = mesecon.state.on
|
state = mesecon.state.on,
|
||||||
}}
|
rules = mesecon.rules.wallmounted_get,
|
||||||
|
}},
|
||||||
|
on_blast = mesecon.on_blastnode,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Solar Panel
|
-- Solar Panel
|
||||||
|
@ -29,7 +31,7 @@ minetest.register_node("mesecons_solarpanel:solar_panel_off", {
|
||||||
wield_image = "jeija_solar_panel.png",
|
wield_image = "jeija_solar_panel.png",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "wallmounted",
|
paramtype2 = "wallmounted",
|
||||||
is_ground_content = true,
|
is_ground_content = false,
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "wallmounted",
|
type = "wallmounted",
|
||||||
wall_bottom = { -8/16, -8/16, -8/16, 8/16, -2/16, 8/16 },
|
wall_bottom = { -8/16, -8/16, -8/16, 8/16, -2/16, 8/16 },
|
||||||
|
@ -40,8 +42,10 @@ minetest.register_node("mesecons_solarpanel:solar_panel_off", {
|
||||||
description="Solar Panel",
|
description="Solar Panel",
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
mesecons = {receptor = {
|
mesecons = {receptor = {
|
||||||
state = mesecon.state.off
|
state = mesecon.state.off,
|
||||||
}}
|
rules = mesecon.rules.wallmounted_get,
|
||||||
|
}},
|
||||||
|
on_blast = mesecon.on_blastnode,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
@ -61,8 +65,9 @@ minetest.register_abm(
|
||||||
local light = minetest.get_node_light(pos, nil)
|
local light = minetest.get_node_light(pos, nil)
|
||||||
|
|
||||||
if light >= 10 then
|
if light >= 10 then
|
||||||
minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_on", param2=node.param2})
|
node.name = "mesecons_solarpanel:solar_panel_on"
|
||||||
mesecon.receptor_on(pos)
|
minetest.swap_node(pos, node)
|
||||||
|
mesecon.receptor_on(pos, mesecon.rules.wallmounted_get(node))
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -75,8 +80,9 @@ minetest.register_abm(
|
||||||
local light = minetest.get_node_light(pos, nil)
|
local light = minetest.get_node_light(pos, nil)
|
||||||
|
|
||||||
if light < 10 then
|
if light < 10 then
|
||||||
minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2})
|
node.name = "mesecons_solarpanel:solar_panel_off"
|
||||||
mesecon.receptor_off(pos)
|
minetest.swap_node(pos, node)
|
||||||
|
mesecon.receptor_off(pos, mesecon.rules.wallmounted_get(node))
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
|
@ -60,10 +60,12 @@ local torch_selectionbox =
|
||||||
selection_box = torch_selectionbox,
|
selection_box = torch_selectionbox,
|
||||||
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
|
||||||
drop = "mesecons_torch:mesecon_torch_on",
|
drop = "mesecons_torch:mesecon_torch_on",
|
||||||
|
sounds = default.node_sound_defaults(),
|
||||||
mesecons = {receptor = {
|
mesecons = {receptor = {
|
||||||
state = mesecon.state.off,
|
state = mesecon.state.off,
|
||||||
rules = torch_get_output_rules
|
rules = torch_get_output_rules
|
||||||
}}
|
}},
|
||||||
|
on_blast = mesecon.on_blastnode,
|
||||||
})]]
|
})]]
|
||||||
|
|
||||||
minetest.register_node("mesecons_torch:mesecon_torch_on", {
|
minetest.register_node("mesecons_torch:mesecon_torch_on", {
|
||||||
|
@ -79,44 +81,17 @@ minetest.register_node("mesecons_torch:mesecon_torch_on", {
|
||||||
paramtype2 = "wallmounted",
|
paramtype2 = "wallmounted",
|
||||||
selection_box = torch_selectionbox,
|
selection_box = torch_selectionbox,
|
||||||
groups = {dig_immediate = 3, attached_node = 1},
|
groups = {dig_immediate = 3, attached_node = 1},
|
||||||
light_source = default.LIGHT_MAX-5,
|
light_source = minetest.LIGHT_MAX - 5,
|
||||||
|
sounds = default.node_sound_defaults(),
|
||||||
mesecons = {receptor = {
|
mesecons = {receptor = {
|
||||||
state = mesecon.state.on,
|
state = mesecon.state.on,
|
||||||
rules = torch_get_output_rules
|
rules = torch_get_output_rules
|
||||||
}},
|
}},
|
||||||
|
on_blast = mesecon.on_blastnode,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_alias("mesecons_torch:mesecon_torch_off", "mesecons_torch:mesecon_torch_on")
|
minetest.register_alias("mesecons_torch:mesecon_torch_off", "mesecons_torch:mesecon_torch_on")
|
||||||
|
|
||||||
minetest.register_node("mesecons_torch:bluestoneblock", {
|
|
||||||
description = "Bluestone Block",
|
|
||||||
tiles = {"bluestone_block.png"},
|
|
||||||
paramtype = "light",
|
|
||||||
groups = {cracky = 1},
|
|
||||||
light_source = default.LIGHT_MAX-5,
|
|
||||||
sounds = default.node_sound_stone_defaults(),
|
|
||||||
mesecons = {receptor = {
|
|
||||||
state = mesecon.state.on,
|
|
||||||
rules = torch_get_output_rules
|
|
||||||
}},
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = "mesecons_torch:bluestoneblock",
|
|
||||||
recipe = {
|
|
||||||
{'mesecons:wire_00000000_off','mesecons:wire_00000000_off','mesecons:wire_00000000_off'},
|
|
||||||
{'mesecons:wire_00000000_off','mesecons:wire_00000000_off','mesecons:wire_00000000_off'},
|
|
||||||
{'mesecons:wire_00000000_off','mesecons:wire_00000000_off','mesecons:wire_00000000_off'},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_craft({
|
|
||||||
output = 'mesecons:wire_00000000_off 9',
|
|
||||||
recipe = {
|
|
||||||
{'mesecons_torch:bluestoneblock'},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
--[[minetest.register_abm({
|
--[[minetest.register_abm({
|
||||||
nodenames = {"mesecons_torch:mesecon_torch_off","mesecons_torch:mesecon_torch_on"},
|
nodenames = {"mesecons_torch:mesecon_torch_off","mesecons_torch:mesecon_torch_on"},
|
||||||
interval = 1,
|
interval = 1,
|
||||||
|
@ -142,6 +117,37 @@ minetest.register_craft({
|
||||||
end
|
end
|
||||||
})]]
|
})]]
|
||||||
|
|
||||||
|
minetest.register_node("mesecons_torch:bluestoneblock", {
|
||||||
|
description = "Bluestone Block",
|
||||||
|
tiles = {"bluestone_block.png"},
|
||||||
|
paramtype = "light",
|
||||||
|
is_ground_content = false,
|
||||||
|
groups = {cracky = 1},
|
||||||
|
light_source = minetest.LIGHT_MAX - 3,
|
||||||
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
mesecons = {receptor = {
|
||||||
|
state = mesecon.state.on,
|
||||||
|
rules = torch_get_output_rules
|
||||||
|
}},
|
||||||
|
on_blast = mesecon.on_blastnode,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "mesecons_torch:bluestoneblock",
|
||||||
|
recipe = {
|
||||||
|
{'mesecons:wire_00000000_off','mesecons:wire_00000000_off','mesecons:wire_00000000_off'},
|
||||||
|
{'mesecons:wire_00000000_off','mesecons:wire_00000000_off','mesecons:wire_00000000_off'},
|
||||||
|
{'mesecons:wire_00000000_off','mesecons:wire_00000000_off','mesecons:wire_00000000_off'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = 'mesecons:wire_00000000_off 9',
|
||||||
|
recipe = {
|
||||||
|
{'mesecons_torch:bluestoneblock'},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
-- Param2 Table (Block Attached To)
|
-- Param2 Table (Block Attached To)
|
||||||
-- 5 = z-1
|
-- 5 = z-1
|
||||||
-- 3 = x-1
|
-- 3 = x-1
|
||||||
|
|
|
@ -1,8 +1,34 @@
|
||||||
-- WALL LEVER
|
-- WALL LEVER
|
||||||
-- Basically a switch that can be attached to a wall
|
-- Basically a switch that can be attached to a wall
|
||||||
-- Powers the block 2 nodes behind (using a receiver)
|
-- Powers the block 2 nodes behind (using a receiver)
|
||||||
minetest.register_node("mesecons_walllever:wall_lever_off", {
|
mesecon.register_node("mesecons_walllever:wall_lever", {
|
||||||
|
description="Lever",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
|
inventory_image = "jeija_wall_lever.png",
|
||||||
|
wield_image = "jeija_wall_lever.png",
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
is_ground_content = false,
|
||||||
|
sunlight_propagates = true,
|
||||||
|
walkable = false,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
on_punch = function(pos, node)
|
||||||
|
if (mesecon.flipstate(pos, node) == "on") then
|
||||||
|
mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||||
|
else
|
||||||
|
mesecon.receptor_off(pos, mesecon.rules.buttonlike_get(node))
|
||||||
|
end
|
||||||
|
minetest.sound_play("mesecons_lever", {pos=pos})
|
||||||
|
end,
|
||||||
|
on_rightclick = function(pos, node)
|
||||||
|
if (mesecon.flipstate(pos, node) == "on") then
|
||||||
|
mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||||
|
else
|
||||||
|
mesecon.receptor_off(pos, mesecon.rules.buttonlike_get(node))
|
||||||
|
end
|
||||||
|
minetest.sound_play("mesecons_lever", {pos=pos})
|
||||||
|
end
|
||||||
|
},{
|
||||||
tiles = {
|
tiles = {
|
||||||
"jeija_wall_lever_tb.png",
|
"jeija_wall_lever_tb.png",
|
||||||
"jeija_wall_lever_bottom.png",
|
"jeija_wall_lever_bottom.png",
|
||||||
|
@ -11,38 +37,17 @@ minetest.register_node("mesecons_walllever:wall_lever_off", {
|
||||||
"jeija_wall_lever_back.png",
|
"jeija_wall_lever_back.png",
|
||||||
"jeija_wall_lever_off.png",
|
"jeija_wall_lever_off.png",
|
||||||
},
|
},
|
||||||
inventory_image = "jeija_wall_lever.png",
|
|
||||||
wield_image = "jeija_wall_lever.png",
|
|
||||||
paramtype = "light",
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {{ -2/16, -3/16, 8/16, 2/16, 3/16, 4/16 },
|
|
||||||
{ -1/16, -8/16, 7/16, 1/16, 0/16, 5/16 }},
|
|
||||||
},
|
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {{ -2/16, -3/16, 8/16, 2/16, 3/16, 4/16 }, -- the base
|
fixed = {{ -2/16, -3/16, 8/16, 2/16, 3/16, 4/16 }, -- the base
|
||||||
{ -1/16, -8/16, 7/16, 1/16, 0/16, 5/16 }} -- the lever itself.
|
{ -1/16, -8/16, 7/16, 1/16, 0/16, 5/16 }} -- the lever itself.
|
||||||
},
|
},
|
||||||
groups = {dig_immediate=2},
|
|
||||||
description="Lever",
|
|
||||||
on_punch = function (pos, node)
|
|
||||||
minetest.swap_node(pos, {name = "mesecons_walllever:wall_lever_on", param2 = node.param2})
|
|
||||||
mesecon.receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
|
||||||
minetest.sound_play("mesecons_lever", {pos=pos})
|
|
||||||
end,
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
mesecons = {receptor = {
|
mesecons = {receptor = {
|
||||||
rules = mesecon.rules.buttonlike_get,
|
rules = mesecon.rules.buttonlike_get,
|
||||||
state = mesecon.state.off
|
state = mesecon.state.off
|
||||||
}}
|
}},
|
||||||
})
|
groups = {dig_immediate = 2},
|
||||||
|
},{
|
||||||
minetest.register_node("mesecons_walllever:wall_lever_on", {
|
|
||||||
drawtype = "nodebox",
|
|
||||||
tiles = {
|
tiles = {
|
||||||
"jeija_wall_lever_top.png",
|
"jeija_wall_lever_top.png",
|
||||||
"jeija_wall_lever_tb.png",
|
"jeija_wall_lever_tb.png",
|
||||||
|
@ -51,34 +56,17 @@ minetest.register_node("mesecons_walllever:wall_lever_on", {
|
||||||
"jeija_wall_lever_back.png",
|
"jeija_wall_lever_back.png",
|
||||||
"jeija_wall_lever_on.png",
|
"jeija_wall_lever_on.png",
|
||||||
},
|
},
|
||||||
inventory_image = "jeija_wall_lever.png",
|
|
||||||
paramtype = "light",
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
walkable = false,
|
|
||||||
selection_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {{ -2/16, -3/16, 8/16, 2/16, 3/16, 4/16 },
|
|
||||||
{ -1/16, 0, 7/16, 1/16, 8/16, 5/16 }},
|
|
||||||
},
|
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {{ -2/16, -3/16, 8/16, 2/16, 3/16, 4/16 }, -- the base
|
fixed = {{ -2/16, -3/16, 8/16, 2/16, 3/16, 4/16 }, -- the base
|
||||||
{ -1/16, 0/16, 7/16, 1/16, 8/16, 5/16 }} -- the lever itself.
|
{ -1/16, 0/16, 7/16, 1/16, 8/16, 5/16 }} -- the lever itself.
|
||||||
},
|
},
|
||||||
groups = {dig_immediate = 2, not_in_creative_inventory = 1},
|
on_rotate = false,
|
||||||
drop = "mesecons_walllever:wall_lever_off 1",
|
|
||||||
description="Lever",
|
|
||||||
on_punch = function (pos, node)
|
|
||||||
minetest.swap_node(pos, {name = "mesecons_walllever:wall_lever_off", param2 = node.param2})
|
|
||||||
mesecon.receptor_off(pos, mesecon.rules.buttonlike_get(node))
|
|
||||||
minetest.sound_play("mesecons_lever", {pos=pos})
|
|
||||||
end,
|
|
||||||
sounds = default.node_sound_wood_defaults(),
|
|
||||||
mesecons = {receptor = {
|
mesecons = {receptor = {
|
||||||
rules = mesecon.rules.buttonlike_get,
|
rules = mesecon.rules.buttonlike_get,
|
||||||
state = mesecon.state.on
|
state = mesecon.state.on
|
||||||
}}
|
}},
|
||||||
|
groups = {dig_immediate = 2, not_in_creative_inventory = 1}
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
mesecons
|
|
@ -28,7 +28,7 @@ local wire_getconnect = function (from_pos, self_pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update this node
|
-- Update this node
|
||||||
local wire_updateconnect = function (pos)
|
local wire_updateconnect = function (pos)
|
||||||
|
@ -54,8 +54,8 @@ local wire_updateconnect = function (pos)
|
||||||
if vec.z == 1 then nid[5] = "1" end
|
if vec.z == 1 then nid[5] = "1" end
|
||||||
if vec.x == -1 then nid[6] = "1" end
|
if vec.x == -1 then nid[6] = "1" end
|
||||||
if vec.z == -1 then nid[7] = "1" end
|
if vec.z == -1 then nid[7] = "1" end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local nodeid = (nid[0] or "0")..(nid[1] or "0")..(nid[2] or "0")..(nid[3] or "0")
|
local nodeid = (nid[0] or "0")..(nid[1] or "0")..(nid[2] or "0")..(nid[3] or "0")
|
||||||
..(nid[4] or "0")..(nid[5] or "0")..(nid[6] or "0")..(nid[7] or "0")
|
..(nid[4] or "0")..(nid[5] or "0")..(nid[6] or "0")..(nid[7] or "0")
|
||||||
|
@ -70,7 +70,7 @@ local update_on_place_dig = function (pos, node)
|
||||||
if (minetest.registered_nodes[nn.name])
|
if (minetest.registered_nodes[nn.name])
|
||||||
and (minetest.registered_nodes[nn.name].mesecon_wire) then
|
and (minetest.registered_nodes[nn.name].mesecon_wire) then
|
||||||
wire_updateconnect(pos)
|
wire_updateconnect(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update nodes around it
|
-- Update nodes around it
|
||||||
local rules = {}
|
local rules = {}
|
||||||
|
@ -79,7 +79,7 @@ end
|
||||||
rules = mesecon.rules.default
|
rules = mesecon.rules.default
|
||||||
else
|
else
|
||||||
rules = mesecon.get_any_rules(node)
|
rules = mesecon.get_any_rules(node)
|
||||||
end
|
end
|
||||||
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
|
||||||
|
@ -87,14 +87,11 @@ end
|
||||||
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)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.update_autoconnect(pos, node)
|
mesecon.register_autoconnect_hook("wire", update_on_place_dig)
|
||||||
if (not node) then node = minetest.get_node(pos) end
|
|
||||||
update_on_place_dig(pos, node)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- ############################
|
-- ############################
|
||||||
-- ## Wire node registration ##
|
-- ## Wire node registration ##
|
||||||
|
@ -143,7 +140,7 @@ nid_inc = function (nid)
|
||||||
return i <= 8
|
return i <= 8
|
||||||
end
|
end
|
||||||
|
|
||||||
register_wires = function()
|
local function register_wires()
|
||||||
local nid = {}
|
local nid = {}
|
||||||
while true do
|
while true do
|
||||||
-- Create group specifiction and nodeid string (see note above for details)
|
-- Create group specifiction and nodeid string (see note above for details)
|
||||||
|
@ -202,21 +199,24 @@ register_wires = function()
|
||||||
local groups_off = {dig_immediate = 3, mesecon_conductor_craftable = 1}
|
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
|
||||||
|
|
||||||
mesecon.register_node("mesecons:wire_"..nodeid, {
|
mesecon.register_node(":mesecons:wire_"..nodeid, {
|
||||||
description = "Mesecon",
|
description = "Mesecon",
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
inventory_image = "bluestone_dust.png",
|
inventory_image = "bluestone_dust.png",
|
||||||
wield_image = "bluestone_dust.png",
|
wield_image = "bluestone_dust.png",
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
|
is_ground_content = false,
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
selection_box = selectionbox,
|
selection_box = selectionbox,
|
||||||
node_box = nodebox,
|
node_box = nodebox,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
drop = "mesecons:wire_00000000_off",
|
drop = "mesecons:wire_00000000_off",
|
||||||
mesecon_wire = true
|
mesecon_wire = true,
|
||||||
|
sounds = default.node_sound_defaults(),
|
||||||
|
on_rotate = false,
|
||||||
}, {tiles = tiles_off, mesecons = meseconspec_off, groups = groups_off},
|
}, {tiles = tiles_off, mesecons = meseconspec_off, groups = groups_off},
|
||||||
{tiles = tiles_on, mesecons = meseconspec_on, groups = groups_on})
|
{tiles = tiles_on, mesecons = meseconspec_on, groups = groups_on})
|
||||||
|
|
||||||
|
@ -234,3 +234,4 @@ minetest.register_craft({
|
||||||
output = "mesecons:wire_00000000_off 8",
|
output = "mesecons:wire_00000000_off 8",
|
||||||
recipe = "default:stone_with_bluestone",
|
recipe = "default:stone_with_bluestone",
|
||||||
})
|
})
|
||||||
|
|
Before Width: | Height: | Size: 408 B After Width: | Height: | Size: 408 B |
Before Width: | Height: | Size: 292 B After Width: | Height: | Size: 292 B |
Before Width: | Height: | Size: 300 B After Width: | Height: | Size: 300 B |
|
@ -511,6 +511,24 @@ minetest.register_abm({
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function default.can_interact_with_node(player, pos)
|
||||||
|
if player then
|
||||||
|
if minetest.check_player_privs(player, "protection_bypass") then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local owner = meta:get_string("owner")
|
||||||
|
|
||||||
|
if not owner or owner == "" or owner == player:get_player_name() then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Snowballs
|
-- Snowballs
|
||||||
--
|
--
|
||||||
|
|
|
@ -328,7 +328,7 @@ minetest.register_node("default:furnace_active", {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
light_source = default.LIGHT_MAX - 5,
|
light_source = minetest.LIGHT_MAX - 5,
|
||||||
drop = "default:furnace",
|
drop = "default:furnace",
|
||||||
groups = {cracky = 2, not_in_creative_inventory=1},
|
groups = {cracky = 2, not_in_creative_inventory=1},
|
||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
-- Definitions made by this mod that other mods can use too
|
-- Definitions made by this mod that other mods can use too
|
||||||
default = {}
|
default = {}
|
||||||
|
|
||||||
default.LIGHT_MAX = 14
|
|
||||||
|
|
||||||
default.gui_bg = "bgcolor[#08080880;true]"
|
default.gui_bg = "bgcolor[#08080880;true]"
|
||||||
default.listcolors = "listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]"
|
default.listcolors = "listcolors[#9990;#FFF7;#FFF0;#160816;#D4D2FF]"
|
||||||
|
|
||||||
|
|
|
@ -1204,7 +1204,7 @@ minetest.register_node("default:lava_source", {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
light_source = default.LIGHT_MAX - 1,
|
light_source = minetest.LIGHT_MAX - 1,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
pointable = false,
|
pointable = false,
|
||||||
diggable = false,
|
diggable = false,
|
||||||
|
@ -1257,7 +1257,7 @@ minetest.register_node("default:lava_flowing", {
|
||||||
},
|
},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "flowingliquid",
|
paramtype2 = "flowingliquid",
|
||||||
light_source = default.LIGHT_MAX - 1,
|
light_source = minetest.LIGHT_MAX - 1,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
pointable = false,
|
pointable = false,
|
||||||
diggable = false,
|
diggable = false,
|
||||||
|
@ -1482,7 +1482,7 @@ minetest.register_node("default:glowstone", {
|
||||||
{items = {'default:glowdust 2'}},
|
{items = {'default:glowdust 2'}},
|
||||||
}
|
}
|
||||||
},]]
|
},]]
|
||||||
light_source = default.LIGHT_MAX - 3,
|
light_source = minetest.LIGHT_MAX - 3,
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("default:slimeblock", {
|
minetest.register_node("default:slimeblock", {
|
||||||
|
|
|
@ -15,7 +15,7 @@ minetest.register_node("default:torch", {
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
light_source = default.LIGHT_MAX - 1,
|
light_source = minetest.LIGHT_MAX - 1,
|
||||||
groups = {choppy = 2, dig_immediate = 3, flammable = 1, attached_node = 1},
|
groups = {choppy = 2, dig_immediate = 3, flammable = 1, attached_node = 1},
|
||||||
legacy_wallmounted = true,
|
legacy_wallmounted = true,
|
||||||
sounds = default.node_sound_defaults(),
|
sounds = default.node_sound_defaults(),
|
||||||
|
|
|
@ -19,7 +19,7 @@ farming.register_plant("farming:wheat", {
|
||||||
inventory_image = "farming_wheat_seed.png",
|
inventory_image = "farming_wheat_seed.png",
|
||||||
steps = 8,
|
steps = 8,
|
||||||
minlight = 13,
|
minlight = 13,
|
||||||
maxlight = default.LIGHT_MAX,
|
maxlight = minetest.LIGHT_MAX,
|
||||||
fertility = {"grassland"},
|
fertility = {"grassland"},
|
||||||
groups = {food_wheat = 1, flammable = 4},
|
groups = {food_wheat = 1, flammable = 4},
|
||||||
place_param2 = 3,
|
place_param2 = 3,
|
||||||
|
@ -66,7 +66,7 @@ minetest.register_craftitem("farming:string",{
|
||||||
inventory_image = "farming_cotton_seed.png",
|
inventory_image = "farming_cotton_seed.png",
|
||||||
steps = 8,
|
steps = 8,
|
||||||
minlight = 13,
|
minlight = 13,
|
||||||
maxlight = default.LIGHT_MAX,
|
maxlight = minetest.LIGHT_MAX,
|
||||||
fertility = {"grassland", "desert"},
|
fertility = {"grassland", "desert"},
|
||||||
groups = {flammable = 4},
|
groups = {flammable = 4},
|
||||||
})
|
})
|
||||||
|
|
|
@ -118,8 +118,7 @@ minetest.register_node("itemframes:frame",{
|
||||||
fixed = {-0.5, -0.5, 7/16, 0.5, 0.5, 0.5}
|
fixed = {-0.5, -0.5, 7/16, 0.5, 0.5, 0.5}
|
||||||
},
|
},
|
||||||
tiles = {"itemframe_background.png"},
|
tiles = {"itemframe_background.png"},
|
||||||
inventory_image = "itemframes_frame.png",
|
inventory_image = "itemframe_background.png",
|
||||||
wield_image = "itemframes_frame.png",
|
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
|
|
Before Width: | Height: | Size: 513 B |
|
@ -78,7 +78,6 @@ minetest.register_node("vessels:glass_bottle", {
|
||||||
drawtype = "plantlike",
|
drawtype = "plantlike",
|
||||||
tiles = {"vessels_glass_bottle.png"},
|
tiles = {"vessels_glass_bottle.png"},
|
||||||
inventory_image = "vessels_glass_bottle.png",
|
inventory_image = "vessels_glass_bottle.png",
|
||||||
wield_image = "vessels_glass_bottle.png",
|
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
walkable = false,
|
walkable = false,
|
||||||
|
|
|
@ -48,7 +48,6 @@ for i,img in ipairs(images) do
|
||||||
minetest.register_tool("watch:"..(i-1), {
|
minetest.register_tool("watch:"..(i-1), {
|
||||||
description = "Watch",
|
description = "Watch",
|
||||||
inventory_image = img,
|
inventory_image = img,
|
||||||
wield_image = img,
|
|
||||||
groups = {not_in_creative_inventory=inv}
|
groups = {not_in_creative_inventory=inv}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|