Make production statistics graph editable

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
MrJakobLaich
Burner Inserter
Burner Inserter
Posts: 10
Joined: Fri Oct 28, 2016 8:33 pm
Contact:

Make production statistics graph editable

Post by MrJakobLaich »

I'm trying a different approach, maybe I can fix this problem without requesting anything.
I'll leave this here, maybe it's easy enough to implement and someone might need it in the future

I have the following problem:
I have a capsule that has a low cooldown, I can't change the cooldown because of other reasons that aren't important.
When the capsule gets used the player gets a buff.
When a buff is active the capsule is used without giving a buff and the player gets the same capsule put into their inventory.
This is to simulate the capsule not being used as long as there is a buff active.

This causes the following problem:
The production consumption statistic automatically counts up every time a capsule is used.
I want to subtract one from the last time a value was added up to the current point in time.
This is probably only one tick, because I have a script effect for the capsule.

set_output_count only edits the total count.
https://lua-api.factorio.com/latest/Lua ... tput_count
I a streamer, gamer, programmer!
But am I human?

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

Re: Make production statistics graph editable

Post by Klonan »

MrJakobLaich wrote:
Thu Sep 30, 2021 9:01 pm
When a buff is active the capsule is used without giving a buff and the player gets the same capsule put into their inventory.
This is to simulate the capsule not being used as long as there is a buff active.
You could set the capsule to not be consumed when used:
https://wiki.factorio.com/Types/UseOnSe ... uses_stack

And then if the capsule does activate the buff, consume from the stack using script yourself, and add it to the production GUI

User avatar
MrJakobLaich
Burner Inserter
Burner Inserter
Posts: 10
Joined: Fri Oct 28, 2016 8:33 pm
Contact:

Re: Make production statistics graph editable

Post by MrJakobLaich »

Klonan wrote:
Thu Sep 30, 2021 9:11 pm
MrJakobLaich wrote:
Thu Sep 30, 2021 9:01 pm
When a buff is active the capsule is used without giving a buff and the player gets the same capsule put into their inventory.
This is to simulate the capsule not being used as long as there is a buff active.
You could set the capsule to not be consumed when used:
https://wiki.factorio.com/Types/UseOnSe ... uses_stack

And then if the capsule does activate the buff, consume from the stack using script yourself, and add it to the production GUI
Thanks :D
Funnily enough that's exactly what we came up with after a lot of thinking and debating about possible solutions (I got some help from the discord ;) )
Still do appreciate that you replied so fast 8-)

Trying to implement that right now. ;)

EDIT:
Works 100% as intended, thanks :D

If anyone comes across this:
Is set

Code: Select all

capsule_action["uses_stack"] = false
as a value of the item.
Then in the control.lua I do

Code: Select all

player.remove_item{name=<item_name>, count=<remove_amount>}
when the item should be consumed.
Then I do

Code: Select all

game["forces"]["player"]["item_production_statistics"].on_flow(<item_name>, -1)
to increase the production statistic by one.
(-1 for the right consumption side of the prod stat)
I a streamer, gamer, programmer!
But am I human?

Post Reply

Return to “Modding interface requests”