[2.1.8] How do you read research pack in the lab with new behavior ?
Posted: Tue Jun 30, 2026 9:23 am
This mod draws the number into the entity to show how long the machine last.
In 2.0, I can read the durability of research pack to calculate the time, but in 2.1.7, I cannot do that
So how do I read the progression of active science pack ?
In 2.0, I can read the durability of research pack to calculate the time, but in 2.1.7, I cannot do that
I search new property added to lab, item, etc but found nothing (maybe I'm blind)TechnologyPrototype and LabPrototype now accept any item type as research ingredients. Changed all science packs to be plain items
So how do I read the progression of active science pack ?
Code: Select all
local inventory = entity.get_inventory(defines.inventory.lab_input)
if inventory == nil or research == nil then return end
local count = 9999
for i = 1, #research_ingredients do
local research_ingredients_name = research_ingredients[i].name
local stack = inventory[research_stack_names[research_ingredients_name]]--inventory.find_item_stack(research_ingredients_name)
if stack and stack.valid_for_read then
local new_count = (stack.count - 1 + stack.durability) / research_ingredients[i].amount
count = new_count < count and new_count or count
end
if count == 0 then break end
end
if count == 9999 then count = 0 end
if not researching_speed then researching_speed = entity.prototype.get_researching_speed() end
local time = count * research_unit_energy / researching_speed
local text = time <= storage.settings.lab_yellow_swap and math.floor(time) or math.floor(time/60)
local color = time > storage.settings.lab_yellow_swap and WHITE or time <= storage.settings.lab_red_swap and RED or YELLOW
if not node.bottom_left then
node.bottom_left = {
text = text,
color = color,
id = rendering.draw_text{
text = text,
surface = entity.surface,
target = {x = entity.bounding_box.left_top.x, y = entity.bounding_box.right_bottom.y -0.5}, --left bottom
color = color,
},
}
else
set_text(node.bottom_left, text)
set_color(node.bottom_left, color)
end