(Solved) Thumbleweed: Usin Inventory items on Objects

Started by viktor, Sat 21/11/2020 12:57:42

Previous topic - Next topic

viktor

I'm having some trouble understanding how to make this work. I'm trying to make my character open a footlocker. For the most part it works but even though the action is successful my player character still says "That won't do any good". I've looked through the manual and simply can't find any example of an item being used on an object.

Code: ags
function oCFootlocker_UseInv()
{
  if (player.ActiveInventory == iFranksKey) {
    player.Walk(171, 119, eBlock, eWalkableAreas);
    oCFootlocker.Visible = false;
    oOFootlocker.Visible = true;}
    
//Else
  else player.Say("I can't do that.");
}
signature" border="0
<a target='_blank' href='https://imgbb.com/'>resurrection pictures for facebook</a>

eri0o

Are you sure your oCFootlocker_UseInv is linked in the Editor? See  https://adventuregamestudio.github.io/ags-manual/FAQ.html

You need to open the events (lighting bolt icon) in the oCFootlocker object in the Editor, find the Use Inventory event and link from there.

Crimson Wizard

#2
Quote from: viktor on Sat 21/11/2020 12:57:42even though the action is successful my player character still says "That won't do any good".

BTW, is this "That won't do any good" message shown for unhandled interactions if everything else failed?

EDIT: oh yes, it is in Thumbleweed template, so apparently the oCFootlocker_UseInv is not run at all.

The good way to test if the function is run is to place a break point there (F9) or display some message, like Display("it runs");

viktor

#3
Quote from: eri0o on Sat 21/11/2020 13:07:28
Are you sure your oCFootlocker_UseInv is linked in the Editor? See  https://adventuregamestudio.github.io/ags-manual/FAQ.html

You need to open the events (lighting bolt icon) in the oCFootlocker object in the Editor, find the Use Inventory event and link from there.

The object is linkedin the Editor.



Quote from: Crimson Wizard on Sat 21/11/2020 13:30:08
Quote from: viktor on Sat 21/11/2020 12:57:42even though the action is successful my player character still says "That won't do any good".

BTW, is this "That won't do any good" message shown for unhandled interactions if everything else failed?

EDIT: oh yes, it is in Thumbleweed template, so apparently the oCFootlocker_UseInv is not run at all.

The good way to test if the function is run is to place a break point there (F9) or display some message, like Display("it runs");

The function runs. oCFootlocker dissaperars and oOFootlocker appears. So apparently the script runs. I'm doing something wrong regarding the else and if's probably, since the action is performed and the character still says the unhandled text.
signature" border="0
<a target='_blank' href='https://imgbb.com/'>resurrection pictures for facebook</a>

Crimson Wizard

Ah! it does the job, but prints unhandled text, looks like I misunderstood.

I am not an expert in that template, but from the quick look, you have to call Verbs.Unhandled(); to receive such response. You could maybe try placing a break point inside Verbs::Unhandled() function and when game gets there check the Call Stack panel and see which way did it come there.

Cassiebsg

Uhm, I'm not familiar with the tumbleweed template, but doesn't it handle all the "verbs" using any_click? Can it be that it's actually running both scripts? And thus you get your successful action AND the unhandled via the any click? Try deleting the any_click from the event (you can always add it again afterwards) and see if it fixes the problem.  (wtf)
There are those who believe that life here began out there...

Crimson Wizard

Quote from: Cassiebsg on Sat 21/11/2020 23:20:03
Uhm, I'm not familiar with the tumbleweed template, but doesn't it handle all the "verbs" using any_click? Can it be that it's actually running both scripts?

Yes, this is actually the case, AGS calls "use inv" event first, and then "any click".

viktor

#7
Quote from: Crimson Wizard on Sat 21/11/2020 23:30:59
Quote from: Cassiebsg on Sat 21/11/2020 23:20:03
Uhm, I'm not familiar with the tumbleweed template, but doesn't it handle all the "verbs" using any_click? Can it be that it's actually running both scripts?

Yes, this is actually the case, AGS calls "use inv" event first, and then "any click".

Yes that was the issue.

But how can I make the character interact with the object if I remove that function? How can I make him look at the footlocker, door or anything for that matter?
signature" border="0
<a target='_blank' href='https://imgbb.com/'>resurrection pictures for facebook</a>

Crimson Wizard

#8
Quote from: viktor on Sun 22/11/2020 07:34:33
But how can I make the character interact with the object if I remove that function? How can I make him look at the footlocker, door or anything for that matter?

Don't remove any click, remove use inv from events instead, and just call oCFootlocker_UseInv from oCFootlocker_AnyClick (in case action was "use inv").

viktor

Quote from: Crimson Wizard on Sun 22/11/2020 10:19:35
Quote from: viktor on Sun 22/11/2020 07:34:33
But how can I make the character interact with the object if I remove that function? How can I make him look at the footlocker, door or anything for that matter?

Don't remove any click, remove use inv from events instead, and just call oCFootlocker_UseInv from oCFootlocker_AnyClick (in case action was "use inv").

That did it :). Thank's guys :)
signature" border="0
<a target='_blank' href='https://imgbb.com/'>resurrection pictures for facebook</a>

Khris

The proper way is to only use the AnyClick event and handle using inv items just like any other verb:

Code: ags
  else if (Verbs.UsedAction(eGA_UseInv)) {
    // check player.ActiveInventory, etc.
  }

SMF spam blocked by CleanTalk