Page 1 of 1

How to use item for character by script?

Posted: Tue Jan 08, 2019 4:11 pm
by kevinma
I want to make a feature that auto using raw-fish if character's health is low.

for raw-fish, i can use LuaItemStack::count to decrease the raw-fish in inventory, and heal the character by LuaEntity::damage.

But If i want to use grenade by script, it can't implement in the same way.

Re: How to use item for character by script?

Posted: Wed Jan 09, 2019 8:09 am
by darkfrei
Find item prototype, get projectile, place projectile, delete one item if successful.

https://lua-api.factorio.com/latest/Lua ... otype.html

I think it must be https://lua-api.factorio.com/latest/Lua ... ace_result

Re: How to use item for character by script?

Posted: Fri Jan 11, 2019 11:52 am
by Oceanel
Something similar is implemented in EatOrDie mod https://mods.factorio.com/mod/EatOrDie by dankirpan how was built up on MoSurvival by ludsoe
And I trying understand how to add to FI mod :(