Page 1 of 1
New to modding, classes question.
Posted: Sun Sep 26, 2021 11:39 pm
by HakunaSomeWhiskey
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.
Re: New to modding, classes question.
Posted: Mon Sep 27, 2021 12:17 am
by DaveMcW
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)
Re: New to modding, classes question.
Posted: Mon Sep 27, 2021 3:42 am
by HakunaSomeWhiskey
Thank you, I have some learning to do clearly.