mirror of
https://github.com/joe7575/techpack.git
synced 2024-08-20 13:14:12 +02:00
aging fine adjustment
This commit is contained in:
parent
539401e2fb
commit
c020615b10
@ -57,7 +57,7 @@ local P = minetest.string_to_pos
|
|||||||
local M = minetest.get_meta
|
local M = minetest.get_meta
|
||||||
|
|
||||||
|
|
||||||
local AGING_FACTOR = 3 -- defect random factor
|
local AGING_FACTOR = 4 -- defect random factor
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Local States
|
-- Local States
|
||||||
|
@ -32,7 +32,7 @@ local State = tubelib.NodeStates:new({
|
|||||||
infotext_name = "HighPerf Distributor",
|
infotext_name = "HighPerf Distributor",
|
||||||
cycle_time = CYCLE_TIME,
|
cycle_time = CYCLE_TIME,
|
||||||
standby_ticks = STANDBY_TICKS,
|
standby_ticks = STANDBY_TICKS,
|
||||||
aging_factor = 10,
|
aging_factor = 50,
|
||||||
})
|
})
|
||||||
|
|
||||||
local function formspec(pos, meta)
|
local function formspec(pos, meta)
|
||||||
@ -197,7 +197,7 @@ local function distributing(pos, meta)
|
|||||||
-- no filter configured?
|
-- no filter configured?
|
||||||
if next(kvFilterItemNames) == nil then return end
|
if next(kvFilterItemNames) == nil then return end
|
||||||
|
|
||||||
local moved_items_total = 0
|
local busy = false
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local list = inv:get_list("src")
|
local list = inv:get_list("src")
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ local function distributing(pos, meta)
|
|||||||
stack:set_count(0)
|
stack:set_count(0)
|
||||||
local color = Side2Color[side]
|
local color = Side2Color[side]
|
||||||
counter[color] = counter[color] + num
|
counter[color] = counter[color] + num
|
||||||
moved_items_total = moved_items_total + num
|
busy = true
|
||||||
else
|
else
|
||||||
second_try = true -- port blocked
|
second_try = true -- port blocked
|
||||||
end
|
end
|
||||||
@ -238,7 +238,7 @@ local function distributing(pos, meta)
|
|||||||
stack:set_count(0)
|
stack:set_count(0)
|
||||||
local color = Side2Color[side]
|
local color = Side2Color[side]
|
||||||
counter[color] = counter[color] + num
|
counter[color] = counter[color] + num
|
||||||
moved_items_total = moved_items_total + num
|
busy = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -246,8 +246,8 @@ local function distributing(pos, meta)
|
|||||||
inv:set_list("src", list)
|
inv:set_list("src", list)
|
||||||
|
|
||||||
meta:set_string("item_counter", minetest.serialize(counter))
|
meta:set_string("item_counter", minetest.serialize(counter))
|
||||||
if moved_items_total > 0 then
|
if busy then
|
||||||
State:keep_running(pos, meta, COUNTDOWN_TICKS, moved_items_total)
|
State:keep_running(pos, meta, COUNTDOWN_TICKS, 1)
|
||||||
else
|
else
|
||||||
State:idle(pos, meta)
|
State:idle(pos, meta)
|
||||||
end
|
end
|
||||||
|
@ -31,7 +31,7 @@ local State = tubelib.NodeStates:new({
|
|||||||
cycle_time = CYCLE_TIME,
|
cycle_time = CYCLE_TIME,
|
||||||
standby_ticks = STANDBY_TICKS,
|
standby_ticks = STANDBY_TICKS,
|
||||||
has_item_meter = true,
|
has_item_meter = true,
|
||||||
aging_factor = 60,
|
aging_factor = 50,
|
||||||
})
|
})
|
||||||
|
|
||||||
local function pushing(pos, meta)
|
local function pushing(pos, meta)
|
||||||
@ -44,7 +44,7 @@ local function pushing(pos, meta)
|
|||||||
State:blocked(pos, meta)
|
State:blocked(pos, meta)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
State:keep_running(pos, meta, COUNTDOWN_TICKS, items:get_count())
|
State:keep_running(pos, meta, COUNTDOWN_TICKS, 1)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
State:idle(pos, meta)
|
State:idle(pos, meta)
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
]]--
|
]]--
|
||||||
|
|
||||||
-- tubelib aging feature
|
-- tubelib aging feature
|
||||||
local AGING_LEVEL1 = 80 * tubelib.machine_aging_value
|
local AGING_LEVEL1 = 50 * tubelib.machine_aging_value
|
||||||
local AGING_LEVEL2 = 240 * tubelib.machine_aging_value
|
local AGING_LEVEL2 = 150 * tubelib.machine_aging_value
|
||||||
|
|
||||||
local Cache = {}
|
local Cache = {}
|
||||||
|
|
||||||
@ -48,10 +48,10 @@ local function allow_metadata_inventory_move(pos, from_list, from_index, to_list
|
|||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
|
|
||||||
local function aging(pos, meta, num)
|
local function aging(pos, meta)
|
||||||
local cnt = meta:get_int("tubelib_aging") + num
|
local cnt = meta:get_int("tubelib_aging") + 1
|
||||||
meta:set_int("tubelib_aging", cnt)
|
meta:set_int("tubelib_aging", cnt)
|
||||||
if cnt > AGING_LEVEL1 and math.random(AGING_LEVEL2/num) == 1 then
|
if cnt > AGING_LEVEL1 and math.random(AGING_LEVEL2) == 1 then
|
||||||
minetest.get_node_timer(pos):stop()
|
minetest.get_node_timer(pos):stop()
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
node.name = "tubelib_addons3:pushing_chest_defect"
|
node.name = "tubelib_addons3:pushing_chest_defect"
|
||||||
@ -97,7 +97,7 @@ local function shift_items(pos, elapsed)
|
|||||||
stack = inv:get_stack("shift", idx)
|
stack = inv:get_stack("shift", idx)
|
||||||
stack:take_item(num)
|
stack:take_item(num)
|
||||||
inv:set_stack("shift", idx, stack)
|
inv:set_stack("shift", idx, stack)
|
||||||
aging(pos, meta, num)
|
aging(pos, meta)
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
set_state(meta, "blocked")
|
set_state(meta, "blocked")
|
||||||
|
Loading…
Reference in New Issue
Block a user