Pass info to called technic_run at which stage we are.

This lets to save cpu/lua cycles for PR/RE machines like supply converters.
This commit is contained in:
Maciej 'agaran' Pijanka
2017-02-26 20:23:40 +01:00
parent cbe97434dc
commit 2694995759
2 changed files with 9 additions and 6 deletions

View File

@ -9,9 +9,12 @@
local S = technic.getter
local run = function(pos, node)
local run = function(pos, node, run_name)
local demand = 10000
local remain = 0.9
if run_name == "RE" then return end -- do not run TWICE (it is PR-RE machine), save lua cycles
-- Machine information
local machine_name = S("Supply Converter")
local meta = minetest.get_meta(pos)

View File

@ -208,7 +208,7 @@ minetest.register_abm({
end
-- Run all the nodes
local function run_nodes(list)
local function run_nodes(list, run_name)
for _, pos2 in ipairs(list) do
technic.get_or_load_node(pos2)
local node2 = minetest.get_node(pos2)
@ -217,14 +217,14 @@ minetest.register_abm({
nodedef = minetest.registered_nodes[node2.name]
end
if nodedef and nodedef.technic_run then
nodedef.technic_run(pos2, node2)
nodedef.technic_run(pos2, node2, run_name)
end
end
end
run_nodes(PR_nodes)
run_nodes(RE_nodes)
run_nodes(BA_nodes)
run_nodes(PR_nodes, "PR")
run_nodes(RE_nodes, "RE")
run_nodes(BA_nodes, "BA")
-- Strings for the meta data
local eu_demand_str = tier.."_EU_demand"