For my mod I’ll be giving “tokens” or an item every time a set goal is achieved. I think I can award one with rocket launches, but id also like to award a (for example) 500 science packs once every hour that your factory produces 10k green circuits within that hour.
I’m not seeing where on the API which call or class I would use. Might be missing it. New to scripting/coding.
New to modding, classes question.
-
- Manual Inserter
- Posts: 3
- Joined: Wed Dec 16, 2020 5:34 pm
- Contact:
Re: New to modding, classes question.
Code: Select all
script.on_nth_tick(216000, function()
local surface = game.surfaces[1]
for _, force in pairs(game.forces) do
local green_circuits = force.item_production_statistics.get_flow_count{
name = "electronic-circuit",
input = false,
precision_index = defines.flow_precision_index.one_hour,
count = true,
}
local reward_chest = surface.find_entities_filtered{name="steel-chest", force=force, limit=1}[1]
if green_circuits >= 10000 then
reward_chest.insert{name="automation-science-pack", count=500}
end
end
end)
-
- Manual Inserter
- Posts: 3
- Joined: Wed Dec 16, 2020 5:34 pm
- Contact:
Re: New to modding, classes question.
Thank you, I have some learning to do clearly.