Skip to content

Commit

Permalink
Small cleanups in internal.lua, move forceloading reversal to legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeija committed Aug 30, 2016
1 parent e561be7 commit 6dacdae
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
9 changes: 4 additions & 5 deletions mesecons/internal.lua
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions mesecons/legacy.lua
Expand Up @@ -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")
10 changes: 1 addition & 9 deletions mesecons/util.lua
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6dacdae

Please sign in to comment.