Reworked for a new power model

This commit is contained in:
Joachim Stolberg 2019-05-21 13:15:13 +02:00
parent e1013f21db
commit 4dc7239e0a
13 changed files with 289 additions and 261 deletions

View File

@ -19,8 +19,8 @@
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
-- Techage Related Data
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
-- Consumer Related Data
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
-- Load support for intllib.
local MP = minetest.get_modpath("techage")
@ -79,13 +79,13 @@ local function get_craft(pos, inventory, hash)
return craft
end
local function autocraft(pos, trd, mem, inventory, craft)
local function autocraft(pos, crd, mem, inventory, craft)
if not craft then return false end
local output_item = craft.output.item
-- check if we have enough room in dst
if not inventory:room_for_item("dst", output_item) then
trd.State:blocked(pos, mem)
crd.State:blocked(pos, mem)
return
end
local consumption = craft.consumption
@ -93,7 +93,7 @@ local function autocraft(pos, trd, mem, inventory, craft)
-- check if we have enough material available
for itemname, number in pairs(consumption) do
if (not inv_index[itemname]) or inv_index[itemname] < number then
trd.State:idle(pos, mem)
crd.State:idle(pos, mem)
return
end
end
@ -110,30 +110,30 @@ local function autocraft(pos, trd, mem, inventory, craft)
inventory:add_item("dst", craft.decremented_input.items[i])
end
trd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
crd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
end
local function keep_running(pos, elapsed)
local mem = tubelib2.get_mem(pos)
local trd = TRD(pos)
local crd = CRD(pos)
local inv = M(pos):get_inventory()
local craft = get_craft(pos, inv)
local output_item = craft.output.item
autocraft(pos, trd, mem, inv, craft)
return trd.State:is_active(mem)
autocraft(pos, crd, mem, inv, craft)
return crd.State:is_active(mem)
end
-- note, that this function assumes allready being updated to virtual items
-- and doesn't handle recipes with stacksizes > 1
local function after_recipe_change(pos, inventory)
local mem = tubelib2.get_mem(pos)
local trd = TRD(pos)
local crd = CRD(pos)
-- if we emptied the grid, there's no point in keeping it running or cached
if inventory:is_empty("recipe") then
autocrafterCache[minetest.hash_node_position(pos)] = nil
inventory:set_stack("output", 1, "")
trd.State:stop(pos, mem)
crd.State:stop(pos, mem)
return
end
local recipe = inventory:get_list("recipe")
@ -156,7 +156,7 @@ local function after_recipe_change(pos, inventory)
craft = craft or get_craft(pos, inventory, hash)
local output_item = craft.output.item
inventory:set_stack("output", 1, output_item)
trd.State:stop(pos, mem)
crd.State:stop(pos, mem)
end
-- clean out unknown items and groups, which would be handled like unknown items in the crafting grid
@ -210,7 +210,7 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
on_output_change(pos, inv, stack)
return 0
elseif listname == "src" then
TRD(pos).State:start_if_standby(pos)
CRD(pos).State:start_if_standby(pos)
end
return stack:get_count()
end
@ -269,7 +269,7 @@ local function on_receive_fields(pos, formname, fields, player)
return
end
local mem = tubelib2.get_mem(pos)
TRD(pos).State:state_button_event(pos, mem, fields)
CRD(pos).State:state_button_event(pos, mem, fields)
end
local function can_dig(pos, player)
@ -361,7 +361,7 @@ local tubing = {
end
end,
on_recv_message = function(pos, topic, payload)
local resp = TRD(pos).State:on_receive_message(pos, topic, payload)
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
if resp then
return resp
else
@ -369,10 +369,10 @@ local tubing = {
end
end,
on_node_load = function(pos)
TRD(pos).State:on_node_load(pos)
CRD(pos).State:on_node_load(pos)
end,
on_node_repair = function(pos)
return TRD(pos).State:on_node_repair(pos)
return CRD(pos).State:on_node_repair(pos)
end,
}

View File

@ -16,8 +16,6 @@
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
-- Techage Related Data
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
-- Load support for intllib.
local MP = minetest.get_modpath("techage")

View File

@ -17,8 +17,8 @@ local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
local N = minetest.get_node
-- Techage Related Data
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
-- Consumer Related Data
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
-- Load support for intllib.
local MP = minetest.get_modpath("techage")
@ -124,7 +124,7 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
return 0
end
if listname == "src" then
TRD(pos).State:start_if_standby(pos)
CRD(pos).State:start_if_standby(pos)
return stack:get_count()
elseif stack:get_count() == 1 and
(list[index]:get_count() == 0 or stack:get_name() ~= list[index]:get_name()) then
@ -173,7 +173,7 @@ local function push_item(pos, filter, item_name, num_items, mem)
end
-- move items to output slots
local function distributing(pos, inv, trd, mem)
local function distributing(pos, inv, crd, mem)
local item_filter, open_ports = get_filter_settings(pos)
local sum_num_pushed = 0
local num_pushed = 0
@ -186,7 +186,7 @@ local function distributing(pos, inv, trd, mem)
local stack = inv:get_stack("src", idx)
local item_name = stack:get_name()
local num_items = stack:get_count()
local num_to_push = math.min(trd.num_items - sum_num_pushed, num_items)
local num_to_push = math.min(crd.num_items - sum_num_pushed, num_items)
num_pushed = 0
if item_filter[item_name] then
@ -201,16 +201,16 @@ local function distributing(pos, inv, trd, mem)
sum_num_pushed = sum_num_pushed + num_pushed
stack:take_item(num_pushed)
inv:set_stack("src", idx, stack)
if sum_num_pushed >= trd.num_items then
if sum_num_pushed >= crd.num_items then
mem.last_index = idx
break
end
end
if num_pushed == 0 then
trd.State:blocked(pos, mem)
crd.State:blocked(pos, mem)
else
trd.State:keep_running(pos, mem, COUNTDOWN_TICKS, 1)
crd.State:keep_running(pos, mem, COUNTDOWN_TICKS, 1)
end
end
@ -218,14 +218,14 @@ end
local function keep_running(pos, elapsed)
local mem = tubelib2.get_mem(pos)
mem.port_counter = mem.port_counter or {}
local trd = TRD(pos)
local crd = CRD(pos)
local inv = M(pos):get_inventory()
if not inv:is_empty("src") then
distributing(pos, inv, trd, mem)
distributing(pos, inv, crd, mem)
else
trd.State:idle(pos, mem)
crd.State:idle(pos, mem)
end
return trd.State:is_active(mem)
return crd.State:is_active(mem)
end
local function on_receive_fields(pos, formname, fields, player)
@ -233,7 +233,7 @@ local function on_receive_fields(pos, formname, fields, player)
return
end
local meta = M(pos)
local trd = TRD(pos)
local crd = CRD(pos)
local filter = minetest.deserialize(meta:get_string("filter"))
if fields.filter1 ~= nil then
filter[1] = fields.filter1 == "true"
@ -250,9 +250,9 @@ local function on_receive_fields(pos, formname, fields, player)
local mem = tubelib2.get_mem(pos)
if fields.state_button ~= nil then
trd.State:state_button_event(pos, mem, fields)
crd.State:state_button_event(pos, mem, fields)
else
meta:set_string("formspec", formspec(trd.State, pos, mem))
meta:set_string("formspec", formspec(crd.State, pos, mem))
end
end
@ -270,7 +270,7 @@ local function change_filter_settings(pos, slot, val)
filter_settings(pos)
local mem = tubelib2.get_mem(pos)
meta:set_string("formspec", formspec(TRD(pos).State, pos, mem))
meta:set_string("formspec", formspec(CRD(pos).State, pos, mem))
return true
end
@ -346,7 +346,7 @@ local tubing = {
local meta = minetest.get_meta(pos)
meta:set_string("item_counter", minetest.serialize({red=0, green=0, blue=0, yellow=0}))
else
local resp = TRD(pos).State:on_receive_message(pos, topic, payload)
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
if resp then
return resp
else
@ -356,10 +356,10 @@ local tubing = {
end,
on_node_load = function(pos)
TRD(pos).State:on_node_load(pos)
CRD(pos).State:on_node_load(pos)
end,
on_node_repair = function(pos)
return TRD(pos).State:on_node_repair(pos)
return CRD(pos).State:on_node_repair(pos)
end,
}

View File

@ -16,8 +16,8 @@
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
-- Techage Related Data
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
-- Consumer Related Data
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
-- Load support for intllib.
local MP = minetest.get_modpath("techage")
@ -61,10 +61,10 @@ local Output = {
local function formspec(self, pos, mem)
local icon
local trd = TRD(pos)
if trd.stage == 2 then
local crd = CRD(pos)
if crd.stage == 2 then
icon = "techage:vacuum_tube"
elseif trd.stage == 3 then
elseif crd.stage == 3 then
icon = "techage:wlanchip"
else
icon = ""
@ -93,9 +93,9 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
end
--local meta = minetest.get_meta(pos)
--local inv = meta:get_inventory()
local trd = TRD(pos)
if listname == "src" and ValidInput[trd.stage][stack:get_name()] then
trd.State:start_if_standby(pos)
local crd = CRD(pos)
if listname == "src" and ValidInput[crd.stage][stack:get_name()] then
crd.State:start_if_standby(pos)
return stack:get_count()
end
return 0
@ -115,32 +115,32 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
return stack:get_count()
end
local function making(pos, trd, mem, inv)
if inv:room_for_item("dst", ItemStack(Output[trd.stage])) then
for _,name in ipairs(Input[trd.stage]) do
local function making(pos, crd, mem, inv)
if inv:room_for_item("dst", ItemStack(Output[crd.stage])) then
for _,name in ipairs(Input[crd.stage]) do
if not inv:contains_item("src", ItemStack(name)) then
trd.State:idle(pos, mem)
crd.State:idle(pos, mem)
return
end
end
for _,name in ipairs(Input[trd.stage]) do
for _,name in ipairs(Input[crd.stage]) do
inv:remove_item("src", ItemStack(name))
end
inv:add_item("dst", ItemStack(Output[trd.stage]))
trd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
inv:add_item("dst", ItemStack(Output[crd.stage]))
crd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
return
end
trd.State:idle(pos, mem)
crd.State:idle(pos, mem)
end
local function keep_running(pos, elapsed)
local mem = tubelib2.get_mem(pos)
local trd = TRD(pos)
local crd = CRD(pos)
local inv = M(pos):get_inventory()
if inv then
making(pos, trd, mem, inv)
making(pos, crd, mem, inv)
end
return trd.State:is_active(mem)
return crd.State:is_active(mem)
end
local function on_receive_fields(pos, formname, fields, player)
@ -148,7 +148,7 @@ local function on_receive_fields(pos, formname, fields, player)
return
end
local mem = tubelib2.get_mem(pos)
TRD(pos).State:state_button_event(pos, mem, fields)
CRD(pos).State:state_button_event(pos, mem, fields)
end
local function can_dig(pos, player)
@ -230,7 +230,7 @@ local tubing = {
end
end,
on_recv_message = function(pos, topic, payload)
local resp = TRD(pos).State:on_receive_message(pos, topic, payload)
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
if resp then
return resp
else
@ -238,10 +238,10 @@ local tubing = {
end
end,
on_node_load = function(pos)
TRD(pos).State:on_node_load(pos)
CRD(pos).State:on_node_load(pos)
end,
on_node_repair = function(pos)
return TRD(pos).State:on_node_repair(pos)
return CRD(pos).State:on_node_repair(pos)
end,
}

View File

@ -16,8 +16,8 @@
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
-- Techage Related Data
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
-- Consumer Related Data
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
-- Load support for intllib.
local MP = minetest.get_modpath("techage")
@ -54,7 +54,7 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
return 0
end
if listname == "src" then
TRD(pos).State:start_if_standby(pos)
CRD(pos).State:start_if_standby(pos)
return stack:get_count()
elseif listname == "dst" then
return 0
@ -128,12 +128,12 @@ local function get_random_gravel_ore()
end
end
local function washing(pos, trd, mem, inv)
local function washing(pos, crd, mem, inv)
-- for testing purposes
if inv:contains_item("src", ItemStack("default:stick")) then
add_object({x=pos.x, y=pos.y+1, z=pos.z}, "default:stick")
inv:remove_item("src", ItemStack("default:stick"))
trd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
crd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
return
end
@ -145,24 +145,25 @@ local function washing(pos, trd, mem, inv)
add_object({x=pos.x, y=pos.y+1, z=pos.z}, ore)
end
else
trd.State:idle(pos, mem)
crd.State:idle(pos, mem)
return
end
if not inv:room_for_item("dst", dst) then
trd.State:idle(pos, mem)
crd.State:idle(pos, mem)
return
end
inv:add_item("dst", dst)
inv:remove_item("src", src)
trd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
crd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
end
local function keep_running(pos, elapsed)
print("keep_running")
local mem = tubelib2.get_mem(pos)
local trd = TRD(pos)
local crd = CRD(pos)
local inv = M(pos):get_inventory()
washing(pos, trd, mem, inv)
return trd.State:is_active(mem)
washing(pos, crd, mem, inv)
return crd.State:is_active(mem)
end
local function on_receive_fields(pos, formname, fields, player)
@ -170,7 +171,7 @@ local function on_receive_fields(pos, formname, fields, player)
return
end
local mem = tubelib2.get_mem(pos)
TRD(pos).State:state_button_event(pos, mem, fields)
CRD(pos).State:state_button_event(pos, mem, fields)
end
local function can_dig(pos, player)
@ -245,7 +246,7 @@ local tubing = {
end
end,
on_recv_message = function(pos, topic, payload)
local resp = TRD(pos).State:on_receive_message(pos, topic, payload)
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
if resp then
return resp
else
@ -253,10 +254,10 @@ local tubing = {
end
end,
on_node_load = function(pos)
TRD(pos).State:on_node_load(pos)
CRD(pos).State:on_node_load(pos)
end,
on_node_repair = function(pos)
return TRD(pos).State:on_node_repair(pos)
return CRD(pos).State:on_node_repair(pos)
end,
}

View File

@ -16,8 +16,8 @@
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
-- Techage Related Data
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
-- Consumer Related Data
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
-- Load support for intllib.
local MP = minetest.get_modpath("techage")
@ -56,7 +56,7 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
return 0
end
if listname == "src" then
TRD(pos).State:start_if_standby(pos)
CRD(pos).State:start_if_standby(pos)
return stack:get_count()
elseif listname == "dst" then
return 0
@ -77,31 +77,31 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
return stack:get_count()
end
local function sieving(pos, trd, mem, inv)
local function sieving(pos, crd, mem, inv)
local src, dst
if inv:contains_item("src", ItemStack("techage:basalt_gravel")) then
dst, src = get_random_basalt_ore(), ItemStack("techage:basalt_gravel")
elseif inv:contains_item("src", ItemStack("default:gravel")) then
dst, src = get_random_gravel_ore(), ItemStack("default:gravel")
else
trd.State:idle(pos, mem)
crd.State:idle(pos, mem)
return
end
if not inv:room_for_item("dst", dst) then
trd.State:idle(pos, mem)
crd.State:idle(pos, mem)
return
end
inv:add_item("dst", dst)
inv:remove_item("src", src)
trd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
crd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
end
local function keep_running(pos, elapsed)
local mem = tubelib2.get_mem(pos)
local trd = TRD(pos)
local crd = CRD(pos)
local inv = M(pos):get_inventory()
sieving(pos, trd, mem, inv)
return trd.State:is_active(mem)
sieving(pos, crd, mem, inv)
return crd.State:is_active(mem)
end
local function on_receive_fields(pos, formname, fields, player)
@ -109,7 +109,7 @@ local function on_receive_fields(pos, formname, fields, player)
return
end
local mem = tubelib2.get_mem(pos)
TRD(pos).State:state_button_event(pos, mem, fields)
CRD(pos).State:state_button_event(pos, mem, fields)
end
local function can_dig(pos, player)
@ -184,7 +184,7 @@ local tubing = {
end
end,
on_recv_message = function(pos, topic, payload)
local resp = TRD(pos).State:on_receive_message(pos, topic, payload)
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
if resp then
return resp
else
@ -192,10 +192,10 @@ local tubing = {
end
end,
on_node_load = function(pos)
TRD(pos).State:on_node_load(pos)
CRD(pos).State:on_node_load(pos)
end,
on_node_repair = function(pos)
return TRD(pos).State:on_node_repair(pos)
return CRD(pos).State:on_node_repair(pos)
end,
}

View File

@ -16,8 +16,8 @@
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
-- Techage Related Data
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
-- Consumer Related Data
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
-- Load support for intllib.
local MP = minetest.get_modpath("techage")
@ -58,7 +58,7 @@ local function allow_metadata_inventory_put(pos, listname, index, stack, player)
return 0
end
if listname == "src" then
TRD(pos).State:start_if_standby(pos)
CRD(pos).State:start_if_standby(pos)
end
return stack:get_count()
end
@ -88,32 +88,32 @@ local function src_to_dst(src_stack, idx, num_items, inv, dst_name)
return false
end
local function grinding(pos, trd, mem, inv)
local function grinding(pos, crd, mem, inv)
local num_items = 0
for idx,stack in ipairs(inv:get_list("src")) do
if not stack:is_empty() then
local name = stack:get_name()
if Recipes[name] then
if src_to_dst(stack, idx, trd.num_items, inv, Recipes[name]) then
trd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
if src_to_dst(stack, idx, crd.num_items, inv, Recipes[name]) then
crd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
else
trd.State:blocked(pos, mem)
crd.State:blocked(pos, mem)
end
else
trd.State:fault(pos, mem)
crd.State:fault(pos, mem)
end
return
end
end
trd.State:idle(pos, mem)
crd.State:idle(pos, mem)
end
local function keep_running(pos, elapsed)
local mem = tubelib2.get_mem(pos)
local trd = TRD(pos)
local crd = CRD(pos)
local inv = M(pos):get_inventory()
grinding(pos, trd, mem, inv)
return trd.State:is_active(mem)
grinding(pos, crd, mem, inv)
return crd.State:is_active(mem)
end
local function on_receive_fields(pos, formname, fields, player)
@ -121,7 +121,7 @@ local function on_receive_fields(pos, formname, fields, player)
return
end
local mem = tubelib2.get_mem(pos)
TRD(pos).State:state_button_event(pos, mem, fields)
CRD(pos).State:state_button_event(pos, mem, fields)
end
local function can_dig(pos, player)
@ -196,7 +196,7 @@ local tubing = {
end
end,
on_recv_message = function(pos, topic, payload)
local resp = TRD(pos).State:on_receive_message(pos, topic, payload)
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
if resp then
return resp
else
@ -204,10 +204,10 @@ local tubing = {
end
end,
on_node_load = function(pos)
TRD(pos).State:on_node_load(pos)
CRD(pos).State:on_node_load(pos)
end,
on_node_repair = function(pos)
return TRD(pos).State:on_node_repair(pos)
return CRD(pos).State:on_node_repair(pos)
end,
}

View File

@ -26,9 +26,9 @@
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
-- Techage Related Data
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
local TRDN = function(node) return (minetest.registered_nodes[node.name] or {}).techage end
-- Consumer Related Data
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
local CRDN = function(node) return (minetest.registered_nodes[node.name] or {}).consumer end
-- Load support for intllib.
local MP = minetest.get_modpath("techage")
local I,_ = dofile(MP.."/intllib.lua")
@ -37,44 +37,44 @@ local STANDBY_TICKS = 10
local COUNTDOWN_TICKS = 10
local CYCLE_TIME = 2
local function pushing(pos, trd, meta, mem)
local function pushing(pos, crd, meta, mem)
local pull_dir = meta:get_int("pull_dir")
local push_dir = meta:get_int("push_dir")
local items = techage.pull_items(pos, pull_dir, trd.num_items)
local items = techage.pull_items(pos, pull_dir, crd.num_items)
if items ~= nil then
if techage.push_items(pos, push_dir, items) ~= true then
-- place item back
techage.unpull_items(pos, pull_dir, items)
trd.State:blocked(pos, mem)
crd.State:blocked(pos, mem)
return
end
trd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
crd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
return
end
trd.State:idle(pos, mem)
crd.State:idle(pos, mem)
end
local function keep_running(pos, elapsed)
local mem = tubelib2.get_mem(pos)
local trd = TRD(pos)
pushing(pos, trd, M(pos), mem)
return trd.State:is_active(mem)
local crd = CRD(pos)
pushing(pos, crd, M(pos), mem)
return crd.State:is_active(mem)
end
local function on_rightclick(pos, node, clicker)
local mem = tubelib2.get_mem(pos)
if not minetest.is_protected(pos, clicker:get_player_name()) then
if TRD(pos).State:is_active(mem) then
TRD(pos).State:stop(pos, mem)
if CRD(pos).State:is_active(mem) then
CRD(pos).State:stop(pos, mem)
else
TRD(pos).State:start(pos, mem)
CRD(pos).State:start(pos, mem)
end
end
end
local function after_dig_node(pos, oldnode, oldmetadata, digger)
techage.remove_node(pos)
TRDN(oldnode).State:after_dig_node(pos, oldnode, oldmetadata, digger)
CRDN(oldnode).State:after_dig_node(pos, oldnode, oldmetadata, digger)
end
local tiles = {}
@ -129,7 +129,7 @@ local tubing = {
is_pusher = true, -- is a pulling/pushing node
on_recv_message = function(pos, topic, payload)
local resp = TRD(pos).State:on_receive_message(pos, topic, payload)
local resp = CRD(pos).State:on_receive_message(pos, topic, payload)
if resp then
return resp
else
@ -137,10 +137,10 @@ local tubing = {
end
end,
on_node_load = function(pos)
TRD(pos).State:on_node_load(pos)
CRD(pos).State:on_node_load(pos)
end,
on_node_repair = function(pos)
return TRD(pos).State:on_node_repair(pos)
return CRD(pos).State:on_node_repair(pos)
end,
}

View File

@ -24,7 +24,6 @@ local I,_ = dofile(MP.."/intllib.lua")
local TA2_Power = techage.Axle
local TA3_Power = techage.SteamPipe
local TA4_Power = techage.ElectricCable
local generator = techage.generator
local STANDBY_TICKS = 4
local COUNTDOWN_TICKS = 4
@ -36,7 +35,7 @@ local function formspec(self, pos, mem)
default.gui_bg..
default.gui_bg_img..
default.gui_slots..
"image[6,0.5;1,2;"..generator.formspec_level(mem, mem.power_result)..
"image[6,0.5;1,2;"..techage.power.formspec_power_bar(POWER_CAPACITY, mem.power_result).."]"..
"image_button[5,1;1,1;".. self:get_state_button_image(mem) ..";state_button;]"..
"button[2.5,1;1.8,1;update;"..I("Update").."]"..
"list[current_player;main;0,3;8,4;]"..
@ -44,11 +43,11 @@ local function formspec(self, pos, mem)
end
local function start_node(pos, mem, state)
generator.turn_power_on(pos, POWER_CAPACITY)
techage.power.power_distribution(pos)
end
local function stop_node(pos, mem, state)
generator.turn_power_on(pos, 0)
techage.power.power_distribution(pos)
end
local State2 = techage.NodeStates:new({
@ -80,25 +79,31 @@ local State4 = techage.NodeStates:new({
local tStates = {0, State2, State3, State4}
-- Pass1: Power balance calculation
local function on_power_pass1(pos, mem)
local state = tStates[mem.state_num or 2]
if state:is_active(mem) then
return -POWER_CAPACITY
end
return 0
end
-- Pass2: Power balance adjustment
local function on_power_pass2(pos, mem, sum)
return 0
end
-- Pass3: Power balance result
local function on_power_pass3(pos, mem, sum)
mem.power_result = sum
end
local function node_timer(pos, elapsed)
local mem = tubelib2.get_mem(pos)
local state = tStates[mem.state_num or 2]
return state:is_active(mem)
end
local function turn_power_on(pos, in_dir, sum)
local mem = tubelib2.get_mem(pos)
local state = tStates[mem.state_num or 2]
-- store result for formspec
mem.power_result = sum
if state:is_active(mem) and sum <= 0 then
state:fault(pos, mem)
-- No automatic turn on
mem.power_capacity = 0
end
M(pos):set_string("formspec", formspec(state, pos, mem))
end
local function on_receive_fields(pos, formname, fields, player)
if minetest.is_protected(pos, player:get_player_name()) then
return
@ -124,7 +129,7 @@ minetest.register_node("techage:t2_source", {
-- up, down, right, left, back, front
"techage_filling_ta2.png^techage_frame_ta2_top.png",
"techage_filling_ta2.png^techage_frame_ta2.png",
"techage_filling_ta2.png^techage_frame_ta2.png^techage_appl_source.png^techage_axle_clutch.png",
"techage_filling_ta2.png^techage_axle_clutch.png^techage_frame_ta2.png",
"techage_filling_ta2.png^techage_frame_ta2.png^techage_appl_source.png",
"techage_filling_ta2.png^techage_frame_ta2.png^techage_appl_source.png",
"techage_filling_ta2.png^techage_frame_ta2.png^techage_appl_source.png",
@ -134,16 +139,9 @@ minetest.register_node("techage:t2_source", {
on_rotate = screwdriver.disallow,
is_ground_content = false,
techage = {
turn_on = turn_power_on,
read_power_consumption = generator.read_power_consumption,
power_network = TA2_Power,
power_side = "R",
animated_power_network = true,
},
on_construct = tubelib2.init_mem,
after_place_node = function(pos, placer)
local mem = generator.after_place_node(pos)
local mem = tubelib2.get_mem(pos)
State2:node_init(pos, mem, "")
mem.state_num = 2
on_rightclick(pos)
@ -151,10 +149,8 @@ minetest.register_node("techage:t2_source", {
after_dig_node = function(pos, oldnode, oldmetadata, digger)
State2:after_dig_node(pos, oldnode, oldmetadata, digger)
generator.after_dig_node(pos, oldnode)
end,
after_tube_update = generator.after_tube_update,
on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick,
on_timer = node_timer,
@ -166,7 +162,7 @@ minetest.register_node("techage:t3_source", {
-- up, down, right, left, back, front
"techage_filling_ta3.png^techage_frame_ta3_top.png",
"techage_filling_ta3.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_source.png^techage_steam_hole.png",
"techage_filling_ta3.png^techage_steam_hole.png^techage_frame_ta3.png",
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_source.png",
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_source.png",
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_source.png",
@ -176,15 +172,9 @@ minetest.register_node("techage:t3_source", {
on_rotate = screwdriver.disallow,
is_ground_content = false,
techage = {
turn_on = turn_power_on,
read_power_consumption = generator.read_power_consumption,
power_network = TA3_Power,
power_side = "R",
},
on_construct = tubelib2.init_mem,
after_place_node = function(pos, placer)
local mem = generator.after_place_node(pos)
local mem = tubelib2.get_mem(pos)
State3:node_init(pos, mem, "")
mem.state_num = 3
on_rightclick(pos)
@ -192,10 +182,8 @@ minetest.register_node("techage:t3_source", {
after_dig_node = function(pos, oldnode, oldmetadata, digger)
State3:after_dig_node(pos, oldnode, oldmetadata, digger)
generator.after_dig_node(pos, oldnode)
end,
after_tube_update = generator.after_tube_update,
on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick,
on_timer = node_timer,
@ -207,7 +195,7 @@ minetest.register_node("techage:t4_source", {
-- up, down, right, left, back, front
"techage_filling_ta4.png^techage_frame_ta4_top.png",
"techage_filling_ta4.png^techage_frame_ta4.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_source.png^techage_appl_hole_electric.png",
"techage_filling_ta4.png^techage_appl_hole_electric.png^techage_frame_ta4.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_source.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_source.png",
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_source.png",
@ -217,15 +205,9 @@ minetest.register_node("techage:t4_source", {
on_rotate = screwdriver.disallow,
is_ground_content = false,
techage = {
turn_on = turn_power_on,
read_power_consumption = generator.read_power_consumption,
power_network = TA4_Power,
power_side = "R",
},
on_construct = tubelib2.init_mem,
after_place_node = function(pos, placer)
local mem = generator.after_place_node(pos)
local mem = tubelib2.get_mem(pos)
State4:node_init(pos, mem, "")
mem.state_num = 4
on_rightclick(pos)
@ -233,15 +215,33 @@ minetest.register_node("techage:t4_source", {
after_dig_node = function(pos, oldnode, oldmetadata, digger)
State4:after_dig_node(pos, oldnode, oldmetadata, digger)
generator.after_dig_node(pos, oldnode)
end,
after_tube_update = generator.after_tube_update,
on_receive_fields = on_receive_fields,
on_rightclick = on_rightclick,
on_timer = node_timer,
})
TA2_Power:add_secondary_node_names({"techage:t2_source"})
TA3_Power:add_secondary_node_names({"techage:t3_source"})
TA4_Power:add_secondary_node_names({"techage:t4_source"})
techage.power.register_node({"techage:t2_source"}, {
on_power_pass1 = on_power_pass1,
on_power_pass2 = on_power_pass2,
on_power_pass3 = on_power_pass3,
conn_sides = {"R"},
power_network = TA2_Power,
})
techage.power.register_node({"techage:t3_source"}, {
on_power_pass1 = on_power_pass1,
on_power_pass2 = on_power_pass2,
on_power_pass3 = on_power_pass3,
conn_sides = {"R"},
power_network = TA3_Power,
})
techage.power.register_node({"techage:t4_source"}, {
on_power_pass1 = on_power_pass1,
on_power_pass2 = on_power_pass2,
on_power_pass3 = on_power_pass3,
conn_sides = {"R"},
power_network = TA4_Power,
})

View File

@ -22,30 +22,43 @@
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
-- Techage Related Data
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
local TRDN = function(node) return (minetest.registered_nodes[node.name] or {}).techage end
-- Consumer Related Data
local CRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).consumer end
local CRDN = function(node) return (minetest.registered_nodes[node.name] or {}).consumer end
local consumer = techage.consumer
local function valid_power_dir(pos, power_dir, in_dir)
return true
end
local ValidPowerConsumingStates = {
[techage.RUNNING] = true,
[techage.BLOCKED] = true,
[techage.FAULT] = true,
}
local function start_node(pos, mem, state)
consumer.turn_power_on(pos, TRD(pos).power_consumption)
-- First finish the start process, than check power and
-- if needed, switch to "nopower"
minetest.after(0.5, techage.power.power_distribution, pos)
end
local function stop_node(pos, mem, state)
consumer.turn_power_on(pos, 0)
techage.power.power_distribution(pos)
end
local function turn_on_clbk(pos, in_dir, sum)
local mem = tubelib2.get_mem(pos)
local trd = TRD(pos)
local state = trd.State:get_state(mem)
if sum <= 0 and state == techage.RUNNING then
trd.State:fault(pos, mem)
local function on_power_pass1(pos, mem)
local crd = CRD(pos)
if ValidPowerConsumingStates[crd.State:get_state(mem)] then
return crd.power_consumption
end
return 0
end
local function on_power_pass2(pos, mem, sum)
local crd = CRD(pos)
local state = crd.State:get_state(mem)
if sum > 0 and state == techage.NOPOWER then
crd.State:start(pos, mem)
return 0
elseif sum <= 0 and ValidPowerConsumingStates[state] then
crd.State:nopower(pos, mem)
return -crd.power_consumption
end
end
@ -107,17 +120,12 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
start_node = power_used and start_node or nil,
stop_node = power_used and stop_node or nil,
})
local tTechage = {
local tConsumer = {
stage = stage,
State = tState,
num_items = tNode.num_items[stage],
turn_on = power_used and turn_on_clbk or nil,
read_power_consumption = consumer.read_power_consumption,
power_network = power_used and power_network or nil,
power_side = "F",
valid_power_dir = power_used and valid_power_dir or nil,
power_consumption = power_used and tNode.power_consumption[stage] or {0,0,0,0},
-- animated_power_network = true, TODO
}
tNode.groups.not_in_creative_inventory = 0
@ -125,19 +133,16 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
minetest.register_node(name_pas, {
description = name_inv,
tiles = prepare_tiles(tiles.pas, stage, power_png),
techage = tTechage,
consumer = tConsumer,
drawtype = tNode.drawtype,
node_box = tNode.node_box,
selection_box = tNode.selection_box,
on_construct = tubelib2.init_mem,
after_place_node = function(pos, placer, itemstack, pointed_thing)
local mem
if power_network then
mem = consumer.after_place_node(pos, placer)
else
mem = tubelib2.init_mem(pos)
end
local meta = M(pos)
local mem = tubelib2.get_mem(pos)
local node = minetest.get_node(pos)
meta:set_int("push_dir", techage.side_to_indir("L", node.param2))
meta:set_int("pull_dir", techage.side_to_indir("R", node.param2))
@ -148,7 +153,7 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
if tNode.after_place_node then
tNode.after_place_node(pos, placer, itemstack, pointed_thing)
end
TRD(pos).State:node_init(pos, mem, number)
CRD(pos).State:node_init(pos, mem, number)
end,
after_dig_node = function(pos, oldnode, oldmetadata, digger)
@ -156,13 +161,9 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
tNode.after_dig_node(pos, oldnode, oldmetadata, digger)
end
techage.remove_node(pos)
TRDN(oldnode).State:after_dig_node(pos, oldnode, oldmetadata, digger)
if power_network then
consumer.after_dig_node(pos, oldnode)
end
CRDN(oldnode).State:after_dig_node(pos, oldnode, oldmetadata, digger)
end,
after_tube_update = consumer.after_tube_update,
can_dig = tNode.can_dig,
on_rotate = screwdriver.disallow,
on_timer = tNode.node_timer,
@ -187,12 +188,11 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
minetest.register_node(name_act, {
description = name_inv,
tiles = prepare_tiles(tiles.act, stage, power_png),
techage = tTechage,
consumer = tConsumer,
drawtype = tNode.drawtype,
node_box = tNode.node_box,
selection_box = tNode.selection_box,
after_tube_update = consumer.after_tube_update,
on_rotate = screwdriver.disallow,
on_timer = tNode.node_timer,
on_receive_fields = tNode.on_receive_fields,
@ -214,14 +214,14 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
minetest.register_node(name_def, {
description = name_inv,
tiles = prepare_tiles(tiles.def, stage, power_png),
techage = tTechage,
consumer = tConsumer,
drawtype = tNode.drawtype,
node_box = tNode.node_box,
selection_box = tNode.selection_box,
after_place_node = function(pos, placer, itemstack, pointed_thing)
local mem = consumer.after_place_node(pos, placer)
local meta = M(pos)
local mem = tubelib2.get_mem(pos)
local node = minetest.get_node(pos)
meta:set_int("push_dir", techage.side_to_indir("L", node.param2))
meta:set_int("pull_dir", techage.side_to_indir("R", node.param2))
@ -232,10 +232,9 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
if tNode.after_place_node then
tNode.after_place_node(pos, placer, itemstack, pointed_thing)
end
TRD(pos).State:defect(pos, mem)
CRD(pos).State:defect(pos, mem)
end,
after_tube_update = consumer.after_tube_update,
on_rotate = screwdriver.disallow,
on_receive_fields = tNode.on_receive_fields,
on_rightclick = tNode.on_rightclick,
@ -251,7 +250,6 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
tNode.after_dig_node(pos, oldnode, oldmetadata, digger)
end
techage.remove_node(pos)
consumer.after_dig_node(pos, oldnode)
end,
paramtype2 = "facedir",
@ -260,6 +258,14 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode)
sounds = tNode.sounds,
})
if power_used then
techage.power.register_node({name_pas, name_act}, {
on_power_pass1 = on_power_pass1,
on_power_pass2 = on_power_pass2,
conn_sides = {"F", "B"},
power_network = power_network,
})
end
techage.register_node(name_pas, {name_act, name_def}, tNode.tubing)
end
return names[1], names[2], names[3]

View File

@ -36,7 +36,7 @@ Node states:
| | | | | |
| V | V V |
| +---------+ +----------+ +---------+ |
| | | | | | | |
| | | | NOPOWER/ | | | |
+---| DEFECT | | STANDBY/ | | FAULT |----------+
| | | BLOCKED | | |
+---------+ +----------+ +---------+
@ -52,10 +52,6 @@ Node mem data:
local S = function(pos) if pos then return minetest.pos_to_string(pos) end end
local P = minetest.string_to_pos
local M = minetest.get_meta
-- Techage Related Data
local TRD = function(pos) return (minetest.registered_nodes[minetest.get_node(pos).name] or {}).techage end
local TRDN = function(node) return (minetest.registered_nodes[node.name] or {}).techage end
--
-- TechAge machine states
@ -65,14 +61,16 @@ techage.STOPPED = 1 -- not operational/turned off
techage.RUNNING = 2 -- in normal operation/turned on
techage.STANDBY = 3 -- nothing to do (e.g. no input items), or blocked anyhow (output jammed),
-- or node (world) not loaded
techage.FAULT = 4 -- any fault state (e.g. no power), which can be fixed by the player
techage.BLOCKED = 5 -- a pushing node is blocked due to a full destination inventory
techage.DEFECT = 6 -- a defect (broken), which has to be repaired by the player
techage.NOPOWER = 4 -- only for power consuming nodes
techage.FAULT = 5 -- any fault state (e.g. wrong source items), which can be fixed by the player
techage.BLOCKED = 6 -- a pushing node is blocked due to a full destination inventory
techage.DEFECT = 7 -- a defect (broken), which has to be repaired by the player
techage.StatesImg = {
"techage_inv_button_off.png",
"techage_inv_button_on.png",
"techage_inv_button_standby.png",
"techage_inv_button_nopower.png",
"techage_inv_button_error.png",
"techage_inv_button_warning.png",
"techage_inv_button_off.png",
@ -96,7 +94,7 @@ function techage.get_power_image(pos, mem)
end
-- State string based on button states
techage.StateStrings = {"stopped", "running", "standby", "fault", "blocked", "defect"}
techage.StateStrings = {"stopped", "running", "standby", "nopower", "fault", "blocked", "defect"}
--
-- Local States
@ -104,6 +102,7 @@ techage.StateStrings = {"stopped", "running", "standby", "fault", "blocked", "de
local STOPPED = techage.STOPPED
local RUNNING = techage.RUNNING
local STANDBY = techage.STANDBY
local NOPOWER = techage.NOPOWER
local FAULT = techage.FAULT
local BLOCKED = techage.BLOCKED
local DEFECT = techage.DEFECT
@ -126,6 +125,7 @@ local function swap_node(pos, name)
if node.name == name then
return
end
print("swap_node", name)
node.name = name
minetest.swap_node(pos, node)
end
@ -173,7 +173,7 @@ function NodeStates:node_init(pos, mem, number)
end
function NodeStates:stop(pos, mem)
local state = mem.techage_state
local state = mem.techage_state or STOPPED
if state ~= DEFECT then
mem.techage_state = STOPPED
if self.stop_node then
@ -198,8 +198,8 @@ function NodeStates:stop(pos, mem)
end
function NodeStates:start(pos, mem, called_from_on_timer)
local state = mem.techage_state
if state == STOPPED or state == STANDBY or state == BLOCKED then
local state = mem.techage_state or STOPPED
if state == STOPPED or state == STANDBY or state == BLOCKED or state == NOPOWER then
if not self.can_start(pos, mem, state) then
self:fault(pos, mem)
return false
@ -233,6 +233,7 @@ function NodeStates:start(pos, mem, called_from_on_timer)
end
function NodeStates:standby(pos, mem)
mem.techage_state = mem.techage_state or STOPPED
if mem.techage_state == RUNNING then
mem.techage_state = STANDBY
-- timer has to be stopped once to be able to be restarted
@ -258,6 +259,7 @@ end
-- special case of standby for pushing nodes
function NodeStates:blocked(pos, mem)
mem.techage_state = mem.techage_state or STOPPED
if mem.techage_state == RUNNING then
mem.techage_state = BLOCKED
-- timer has to be stopped once to be able to be restarted
@ -281,7 +283,28 @@ function NodeStates:blocked(pos, mem)
return false
end
function NodeStates:nopower(pos, mem)
mem.techage_state = mem.techage_state or STOPPED
if mem.techage_state ~= STOPPED and mem.techage_state ~= DEFECT then
mem.techage_state = NOPOWER
if self.node_name_passive then
swap_node(pos, self.node_name_passive)
end
if self.infotext_name then
local number = M(pos):get_string("node_number")
M(pos):set_string("infotext", self.infotext_name.." "..number..": no power")
end
if self.formspec_func then
M(pos):set_string("formspec", self.formspec_func(self, pos, mem))
end
minetest.get_node_timer(pos):stop()
return true
end
return false
end
function NodeStates:fault(pos, mem)
mem.techage_state = mem.techage_state or STOPPED
if mem.techage_state == RUNNING or mem.techage_state == STOPPED then
mem.techage_state = FAULT
if self.node_name_passive then
@ -317,15 +340,15 @@ function NodeStates:defect(pos, mem)
end
function NodeStates:get_state(mem)
return mem.techage_state
return mem.techage_state or techage.STOPPED
end
function NodeStates:get_state_string(mem)
return techage.StateStrings[mem.techage_state]
return techage.StateStrings[mem.techage_state or STOPPED]
end
function NodeStates:is_active(mem)
local state = mem.techage_state
local state = mem.techage_state or STOPPED
if self.stop_timer == true then
self.stop_timer = false
return false
@ -343,7 +366,7 @@ end
-- To be called if node is idle.
-- If countdown reaches zero, the node is set to STANDBY.
function NodeStates:idle(pos, mem)
local countdown = mem.techage_countdown - 1
local countdown = (mem.techage_countdown or 0) - 1
mem.techage_countdown = countdown
if countdown <= 0 then
self:standby(pos, mem)
@ -357,7 +380,7 @@ function NodeStates:keep_running(pos, mem, val)
self:start(pos, mem, true)
mem.techage_countdown = val
if self.has_item_meter then
mem.techage_item_meter = mem.techage_item_meter + 1
mem.techage_item_meter = (mem.techage_item_meter or 999999) + 1
end
if self.aging_level1 then
local cnt = mem.techage_aging + 1
@ -373,10 +396,10 @@ end
-- if function returns false, no button was pressed
function NodeStates:state_button_event(pos, mem, fields)
if fields.state_button ~= nil then
local state = mem.techage_state
local state = mem.techage_state or STOPPED
if state == STOPPED or state == STANDBY or state == BLOCKED then
self:start(pos, mem)
elseif state == RUNNING or state == FAULT then
elseif state == RUNNING or state == FAULT or state == NOPOWER then
self:stop(pos, mem)
end
return true
@ -385,7 +408,7 @@ function NodeStates:state_button_event(pos, mem, fields)
end
function NodeStates:get_state_button_image(mem)
local state = mem.techage_state
local state = mem.techage_state or STOPPED
return techage.state_button(state)
end
@ -405,12 +428,12 @@ function NodeStates:on_receive_message(pos, topic, payload)
end
return self:get_state_string(tubelib2.get_mem(pos))
elseif self.has_item_meter and topic == "counter" then
return mem.techage_item_meter
return mem.techage_item_meter or 1
elseif self.has_item_meter and topic == "clear_counter" then
mem.techage_item_meter = 0
return true
elseif self.aging_level1 and topic == "aging" then
return mem.techage_aging
return mem.techage_aging or 1
end
end
@ -435,7 +458,7 @@ function NodeStates:on_node_load(pos, not_start_timer)
end
-- state corrupt?
local state = mem.techage_state
local state = mem.techage_state or 0
if state == 0 then
if minetest.get_node_timer(pos):is_started() then
mem.techage_state = RUNNING
@ -482,7 +505,7 @@ end
function NodeStates:after_dig_node(pos, oldnode, oldmetadata, digger)
local mem = tubelib2.get_mem(pos)
local inv = minetest.get_inventory({type="player", name=digger:get_player_name()})
local cnt = mem.techage_aging or 0
local cnt = math.max(mem.techage_aging or 1, 1)
if self.aging_level1 then
local is_defect = cnt > self.aging_level1 and math.random(self.aging_level2 / cnt) == 1
if self.node_name_defect and is_defect then

View File

@ -78,22 +78,22 @@ else
dofile(MP.."/steam_engine/gearbox.lua")
-- Basic Machines
-- dofile(MP.."/basic_machines/source.lua")
-- dofile(MP.."/basic_machines/pusher.lua")
-- dofile(MP.."/basic_machines/blackhole.lua")
-- dofile(MP.."/basic_machines/legacy_nodes.lua")
-- dofile(MP.."/basic_machines/grinder.lua")
-- dofile(MP.."/basic_machines/distributor.lua")
-- dofile(MP.."/basic_machines/gravelsieve.lua")
-- dofile(MP.."/basic_machines/gravelrinser.lua")
-- dofile(MP.."/basic_machines/chest.lua")
-- dofile(MP.."/basic_machines/autocrafter.lua")
-- dofile(MP.."/basic_machines/mark.lua")
-- dofile(MP.."/basic_machines/forceload.lua")
-- dofile(MP.."/basic_machines/electronic_fab.lua")
-- if techage.basalt_stone_enabled then
-- dofile(MP.."/basic_machines/basalt.lua")
-- end
dofile(MP.."/basic_machines/source.lua")
dofile(MP.."/basic_machines/pusher.lua")
dofile(MP.."/basic_machines/blackhole.lua")
dofile(MP.."/basic_machines/legacy_nodes.lua")
dofile(MP.."/basic_machines/grinder.lua")
dofile(MP.."/basic_machines/distributor.lua")
dofile(MP.."/basic_machines/gravelsieve.lua")
dofile(MP.."/basic_machines/gravelrinser.lua")
dofile(MP.."/basic_machines/chest.lua")
dofile(MP.."/basic_machines/autocrafter.lua")
dofile(MP.."/basic_machines/mark.lua")
dofile(MP.."/basic_machines/forceload.lua")
dofile(MP.."/basic_machines/electronic_fab.lua")
if techage.basalt_stone_enabled then
dofile(MP.."/basic_machines/basalt.lua")
end
-- Coal power station
-- dofile(MP.."/coal_power_station/help.lua")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 508 B

After

Width:  |  Height:  |  Size: 512 B