How to acces "Total Raw"?

Place to get help with not working mods / modding interface.
DibiZibi
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Oct 17, 2015 6:19 pm
Contact:

How to acces "Total Raw"?

Post by DibiZibi »

Hello.

There is a nice element of the UI that shows total amount of raw materials required to craft an item.
Is there a way to access this data with a script?
It can be read only - I want to be able to count how many components are needed to construct an item.
Counting it all by hand and having a lot of it-thens in my code isn't something that I want.

Thanks for help.
SirRichie
Fast Inserter
Fast Inserter
Posts: 244
Joined: Wed Feb 25, 2015 4:50 pm
Contact:

Re: How to acces "Total Raw"?

Post by SirRichie »

Hi,

if the data.raw table in the wiki is up to date (it is not completely up to date, but it should be up-to-date-enough), then there is no property for what you want to get.

However, it can be implemented with a simple recursive function. You would take an item and look up its recipe. For any item in the recipe that is not part of the raw components (which will have to be defined), you call the function again and add the results.
This may actually be a helpful library for others as well. If I find the time, I may even implement it myself.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3749
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: How to acces "Total Raw"?

Post by DaveMcW »

I wrote a recursive function to do that a while ago.

https://forums.factorio.com/forum/vie ... 789#p34789
DibiZibi
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sat Oct 17, 2015 6:19 pm
Contact:

Re: How to acces "Total Raw"?

Post by DibiZibi »

Thanks for help.
Post Reply

Return to “Modding help”