summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeija <norrepli@gmail.com>2016-08-30 19:32:11 +0200
committerJeija <norrepli@gmail.com>2016-08-30 19:37:43 +0200
commit6dacdaee1f942e1ba662ef017b9bde3a238f1732 (patch)
tree5509303b55fdd3d86a17ef3cb772c9274b9cc7e2
parente561be7fa36b6de90a759c13d745f8e54359ce3d (diff)
downloadmesecons-6dacdaee1f942e1ba662ef017b9bde3a238f1732.tar
mesecons-6dacdaee1f942e1ba662ef017b9bde3a238f1732.tar.gz
mesecons-6dacdaee1f942e1ba662ef017b9bde3a238f1732.tar.bz2
mesecons-6dacdaee1f942e1ba662ef017b9bde3a238f1732.tar.xz
mesecons-6dacdaee1f942e1ba662ef017b9bde3a238f1732.zip
Small cleanups in `internal.lua`, move forceloading reversal to legacy
-rw-r--r--mesecons/internal.lua9
-rw-r--r--mesecons/legacy.lua7
-rw-r--r--mesecons/util.lua10
3 files changed, 12 insertions, 14 deletions
diff --git a/mesecons/internal.lua b/mesecons/internal.lua
index 2a352f3..e5ba91e 100644
--- a/mesecons/internal.lua
+++ b/mesecons/internal.lua
@@ -37,10 +37,6 @@
-- HIGH-LEVEL Internals
-- 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.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.is_powered(pos) --> Returns true if pos is powered by a receptor or a conductor
-- RULES ROTATION helpers
@@ -475,6 +471,8 @@ function mesecon.turnoff(pos, link)
return true
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)
local input = vector.add(output, rule)
local inputnode = mesecon.get_node_force(input)
@@ -494,8 +492,9 @@ function mesecon.rules_link_rule_all(output, rule)
return rules
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)
- --local irule = mesecon.invertRule(rule)
local output = vector.add(input, rule)
local outputnode = mesecon.get_node_force(output)
local outputrules = mesecon.get_any_outputrules(outputnode)
diff --git a/mesecons/legacy.lua b/mesecons/legacy.lua
index 6d8ccca..ca496f1 100644
--- a/mesecons/legacy.lua
+++ b/mesecons/legacy.lua
@@ -28,3 +28,10 @@ function mesecon.receptor_off(self, pos, rules)
mesecon.queue:add_action(pos, "receptor_off", {rules}, nil, rules)
end
+-- Un-forceload any forceloaded mapblocks from older versions of Mesecons which
+-- used forceloading instead of VoxelManipulators.
+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")
diff --git a/mesecons/util.lua b/mesecons/util.lua
index a4960a9..c9ba7fc 100644
--- a/mesecons/util.lua
+++ b/mesecons/util.lua
@@ -219,7 +219,7 @@ function mesecon.table2file(filename, table)
f:close()
end
--- Forceloading: Force server to load area if node is nil
+-- Block position "hashing" (convert to integer) functions for voxelmanip cache
local BLOCKSIZE = 16
-- convert node position --> block hash
@@ -363,14 +363,6 @@ function mesecon.swap_node_force(pos, name)
end
end
--- Un-forceload any forceloaded mapblocks from older versions of Mesecons which
--- used forceloading instead of VoxelManipulators.
-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(wpath..DIR_DELIM.."mesecon_forceloaded")
-
-- 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