Get all raw resources for item?

Place to get help with not working mods / modding interface.
Post Reply
Cryotech
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Apr 29, 2017 5:11 am
Contact:

Get all raw resources for item?

Post by Cryotech »

Is there a way to view the raw resources required for an item to be built inside an event listener?

For example, a way to find that a single "transport belt" is valued at 1.5 iron? (Note that this is because the recipe takes 3 iron, but crafts 2 belts)

Thanks!

User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: Get all raw resources for item?

Post by DedlySpyder »

There's definitely a way to do it, but it may be a bit convoluted. Which event are you trying to do this in?

I'll post this here if you want an idea of how I did something similar without any base information for each item in the game. I am assigning arbitrary values to all items (giving basic items like ores a base value). I needed to get the recipes of each item, iterate through its ingredients, and add up my values for each, then divide it by the products.

You'd probably need to look up the recipe and do something similar.

https://github.com/DedlySpyder/Proxy_Wa ... values.lua

Cryotech
Burner Inserter
Burner Inserter
Posts: 6
Joined: Sat Apr 29, 2017 5:11 am
Contact:

Re: Get all raw resources for item?

Post by Cryotech »

DedlySpyder wrote:There's definitely a way to do it, but it may be a bit convoluted. Which event are you trying to do this in?

I'll post this here if you want an idea of how I did something similar without any base information for each item in the game. I am assigning arbitrary values to all items (giving basic items like ores a base value). I needed to get the recipes of each item, iterate through its ingredients, and add up my values for each, then divide it by the products.

You'd probably need to look up the recipe and do something similar.

https://github.com/DedlySpyder/Proxy_Wa ... values.lua
I'd be doing it in the on_player_mined_entity event. I'll take a look at your work and see if I can pull off something similar, thanks!

Post Reply

Return to “Modding help”