diff options
Diffstat (limited to 'internal.lua')
-rw-r--r-- | internal.lua | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/internal.lua b/internal.lua index e189130..2528f35 100644 --- a/internal.lua +++ b/internal.lua @@ -1,9 +1,9 @@ -function digilines:getspec(node) +function digilines.getspec(node) if not minetest.registered_nodes[node.name] then return false end return minetest.registered_nodes[node.name].digiline end -function digilines:importrules(spec, node) +function digilines.importrules(spec, node) if type(spec) == 'function' then return spec(node) elseif spec then @@ -13,43 +13,43 @@ function digilines:importrules(spec, node) end end -function digiline:getAnyInputRules(pos) - local node = digiline:get_node_force(pos) - local spec = digiline:getspec(node) +function digilines.getAnyInputRules(pos) + local node = digilines.get_node_force(pos) + local spec = digilines.getspec(node) if not spec then return end if spec.wire then - return digilines:importrules(spec.wire.rules, node) + return digilines.importrules(spec.wire.rules, node) end if spec.effector then - return digilines:importrules(spec.effector.rules, node) + return digilines.importrules(spec.effector.rules, node) end end -function digiline:getAnyOutputRules(pos) - local node = digiline:get_node_force(pos) - local spec = digiline:getspec(node) +function digilines.getAnyOutputRules(pos) + local node = digilines.get_node_force(pos) + local spec = digilines.getspec(node) if not spec then return end if spec.wire then - return digilines:importrules(spec.wire.rules, node) + return digilines.importrules(spec.wire.rules, node) end if spec.receptor then - return digilines:importrules(spec.receptor.rules, node) + return digilines.importrules(spec.receptor.rules, node) end end -function digilines:rules_link(output, input) - local outputrules = digilines:getAnyOutputRules(output) - local inputrules = digilines:getAnyInputRules (input) +function digilines.rules_link(output, input) + local outputrules = digilines.getAnyOutputRules(output) + local inputrules = digilines.getAnyInputRules (input) if not outputrules or not inputrules then return false end for _, orule in ipairs(outputrules) do - if digilines:cmpPos(digilines:addPosRule(output, orule), input) then + if digilines.cmpPos(digilines.addPosRule(output, orule), input) then for _, irule in ipairs(inputrules) do - if digilines:cmpPos(digilines:addPosRule(input, irule), output) then + if digilines.cmpPos(digilines.addPosRule(input, irule), output) then return true end end @@ -58,9 +58,9 @@ function digilines:rules_link(output, input) return false end -function digilines:rules_link_anydir(output, input) - return digilines:rules_link(output, input) - or digilines:rules_link(input, output) +function digilines.rules_link_anydir(output, input) + return digilines.rules_link(output, input) + or digilines.rules_link(input, output) end local function queue_new() @@ -85,14 +85,14 @@ local function queue_dequeue(queue) return object end -function digiline:transmit(pos, channel, msg, checked) - digiline:vm_begin() +function digilines.transmit(pos, channel, msg, checked) + digilines.vm_begin() local queue = queue_new() queue_enqueue(queue, pos) while not queue_empty(queue) do local curPos = queue_dequeue(queue) - local node = digiline:get_node_force(curPos) - local spec = digiline:getspec(node) + local node = digilines.get_node_force(curPos) + local spec = digilines.getspec(node) if spec then -- Effector actions --> Receive if spec.effector then @@ -101,10 +101,10 @@ function digiline:transmit(pos, channel, msg, checked) -- Cable actions --> Transmit if spec.wire then - local rules = digiline:importrules(spec.wire.rules, node) + local rules = digilines.importrules(spec.wire.rules, node) for _, rule in ipairs(rules) do - local nextPos = digiline:addPosRule(curPos, rule) - if digiline:rules_link(curPos, nextPos) then + local nextPos = digilines.addPosRule(curPos, rule) + if digilines.rules_link(curPos, nextPos) then local checkedID = minetest.hash_node_position(nextPos) if not checked[checkedID] then checked[checkedID] = true @@ -115,5 +115,5 @@ function digiline:transmit(pos, channel, msg, checked) end end end - digiline:vm_end() + digilines.vm_end() end |