New to modding, classes question.

Place to get help with not working mods / modding interface.
Post Reply
HakunaSomeWhiskey
Manual Inserter
Manual Inserter
Posts: 3
Joined: Wed Dec 16, 2020 5:34 pm
Contact:

New to modding, classes question.

Post 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.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: New to modding, classes question.

Post 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)

HakunaSomeWhiskey
Manual Inserter
Manual Inserter
Posts: 3
Joined: Wed Dec 16, 2020 5:34 pm
Contact:

Re: New to modding, classes question.

Post by HakunaSomeWhiskey »

Thank you, I have some learning to do clearly.

Post Reply

Return to “Modding help”