Solarus-Games English Forum

Solarus => Development => Topic started by: lefthandedhero on December 15, 2023, 03:13:11 AM

Title: How to Receive an Item From an NPC
Post by: lefthandedhero on December 15, 2023, 03:13:11 AM
I watched the tutorial videos on equipment items and I understand how to have an item be found in a chest or dropped when enemy is defeated. However, I was wondering how to have an item be obtained by interacting with NPC.
Title: Re: How to Receive an Item From an NPC
Post by: PeterB on December 18, 2023, 07:51:48 AM
You have to do that with the map lua script.

npc:on_interaction() then do the dialog and finally give the item to the hero with hero:start_treasure(treasure_name, [treasure_variant, [treasure_savegame_variable, [callback]]])

You can have a look in the Manual for further help on these :)
Title: Re: How to Receive an Item From an NPC
Post by: lefthandedhero on December 19, 2023, 11:10:41 PM
Quote from: PeterB on December 18, 2023, 07:51:48 AM
You have to do that with the map lua script.

npc:on_interaction() then do the dialog and finally give the item to the hero with hero:start_treasure(treasure_name, [treasure_variant, [treasure_savegame_variable, [callback]]])

You can have a look in the Manual for further help on these :)

Thank you; that helps a lot.

What are you referring to by the manual? Are you referring to the Lua API reference? If so, I have been reading through it.