How to use item for character by script?

Place to get help with not working mods / modding interface.
Post Reply
kevinma
Inserter
Inserter
Posts: 33
Joined: Tue Jan 08, 2019 4:07 pm
Contact:

How to use item for character by script?

Post 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.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: How to use item for character by script?

Post 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

User avatar
Oceanel
Burner Inserter
Burner Inserter
Posts: 12
Joined: Tue Aug 12, 2014 9:58 am
Contact:

Re: How to use item for character by script?

Post 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 :(

Post Reply

Return to “Modding help”