Best way to use inventory on something, from script?

Started by fratello Manu, Fri 12/02/2021 22:43:59

Previous topic - Next topic

fratello Manu

Hi everyone!

I can't find a working way , from script (no mouse clicks anywhere, things will happen by typing commands, parser-style) , to do something like:

- use iKey (which is in my inventory) on Hotspot1, or
- use iKey on Object1, or
- use iKey on Character1, or
- use iKey on iOtherInventoryWhichIOwn.

I know I have to deal with RunInteraction and eModeUseWith, but I can't understand in which event, with which syntax.... etc

Thanks!!! :wink:

Crimson Wizard

#1
The two ways from the top of my head are:

1.  All these objects have "Use inventory on..." event. Create event functions for them. Then when reacting to the player's command do this:
Code: ags

SomeObject.RunInteraction(eModeUseinv);

this will run "use inventory on" event, if there's a connected function.

To pass what item is used you can set player.ActiveInventory. Or your own global variable of type InventoryItem*.

2. You can keep using one "interact" function for all events, but then set active inventory item before calling it and setting it to null after calling it. Then inside this event function you just check whether active inventory is set, and that would mean that item is used.


fratello Manu

I was already doing like that... so I found out that the error was somewhere else!!!
thanks!

SMF spam blocked by CleanTalk