[Done] Death Log Values

Place to get help with not working mods / modding interface.
Post Reply
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1350
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

[Done] Death Log Values

Post by TheSAguy » Mon Dec 17, 2018 5:44 pm

I was thinking of adding some Achievements to my mod for the number of biter types you killed.
The game already captures every name of biters killed, and displays that when you die or finish the game.

Image

How can I read these values?

Ideally I'd like to sum the values of type of biter vs type and level.
In the log above there are 114 Fire biteres lvl 1 and 13 fire biters lvl 7. I'd like to just capture the value of 127 fire biters.

Could someone please help me in the correct direction here please?

Thanks.
Last edited by TheSAguy on Mon Dec 17, 2018 7:37 pm, edited 1 time in total.

Bilka
Factorio Staff
Factorio Staff
Posts: 1735
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Death Log Values

Post by Bilka » Mon Dec 17, 2018 5:51 pm

https://lua-api.factorio.com/latest/Lua ... statistics on the force of the player. Input count should give you the kills if I am guessing correctly. Summing is just scripting once you have the values :P
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

TheSAguy
Smart Inserter
Smart Inserter
Posts: 1350
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Death Log Values

Post by TheSAguy » Mon Dec 17, 2018 7:31 pm

Could you possibly tell me how I access/read from this table?
I can't find any examples of how to do this.

Thanks.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 3592
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Death Log Values

Post by Klonan » Mon Dec 17, 2018 7:34 pm

TheSAguy wrote:
Mon Dec 17, 2018 7:31 pm
Could you possibly tell me how I access/read from this table?
I can't find any examples of how to do this.

Thanks.
This is from production score, but the statistic objects are the same:

Code: Select all

  local production_statistics = game.player.item_production_statistics
  local produced = production_statistics.input_counts
  local consumed = production_statistics.output_counts
  for name, value in pairs (consumed) do
    if produced[name] then
      produced[name] = produced[name] - value
    else
      produced[name] = -value
    end
  end
  return produced

TheSAguy
Smart Inserter
Smart Inserter
Posts: 1350
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Death Log Values

Post by TheSAguy » Mon Dec 17, 2018 7:37 pm

Thanks guys, I found one more example. I'll be able to figure it out now.

Code: Select all

    for entity_name, kill_count in pairs(player.force.kill_count_statistics.input_counts) do
        if is_biter(entity_name) then
            biter_count = biter_count + kill_count
        elseif is_spawner(entity_name) then
            spawner_count = spawner_count + kill_count
        else
            other_count = other_count + kill_count
        end
    end
Thanks again!!

Post Reply

Return to “Modding help”

Who is online

Users browsing this forum: No registered users