How to use item for character by script?

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

How to use item for character by script?

Post by kevinma » Tue Jan 08, 2019 4:11 pm

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: 2015
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: How to use item for character by script?

Post by darkfrei » Wed Jan 09, 2019 8:09 am

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 » Fri Jan 11, 2019 11:52 am

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”

Who is online

Users browsing this forum: mat1k