Page 1 of 1

How to use a dynamic item value?

Posted: Sat May 12, 2018 5:37 pm
by seomaster99
I need to read the current number of things in the inventory and use it in my code.

An example is this:
In the player's inventory, a stack of 28 items.

I will call it this:

Code: Select all

local factor = ("item name"). value (how much is in the stack)

And I need to do the following in code:

Code: Select all

mining_speed = 2 * 0.05 * factor,
mining_power = 6 * 0.05 * factor,
The value is dynamic, as it decreases and increases the number of stacks in the inventory, it changes.

Tell me pls - how I can implement this in my code.

Sorry for my English :)

Re: How to use a dynamic item value?

Posted: Sun May 13, 2018 1:27 am
by eradicator
http://lua-api.factorio.com/latest/LuaInventory.html

LuaInventory.get_item_count('itemname')

So in your case

LuaPlayerObject.get_inventory(defines.inventory.player_main).get_item_count('your-item-name')

Re: How to use a dynamic item value?

Posted: Sun May 13, 2018 5:30 pm
by seomaster99
Thank you!

/close