Author Topic: (Solved) Thumbleweed: Usin Inventory items on Objects  (Read 333 times)

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: Adventure Game Studio
  1. function oCFootlocker_UseInv()
  2. {
  3.   if (player.ActiveInventory == iFranksKey) {
  4.     player.Walk(171, 119, eBlock, eWalkableAreas);
  5.     oCFootlocker.Visible = false;
  6.     oOFootlocker.Visible = true;}
  7.    
  8. //Else
  9.   else player.Say("I can't do that.");
  10. }
« Last Edit: 22 Nov 2020, 13:45 by viktor »

eri0o

Re: Thumbleweed: Usin Inventory items on Objects
« Reply #1 on: 21 Nov 2020, 13:07 »
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.

Re: Thumbleweed: Usin Inventory items on Objects
« Reply #2 on: 21 Nov 2020, 13:30 »
even 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");
« Last Edit: 21 Nov 2020, 13:34 by Crimson Wizard »

Re: Thumbleweed: Usin Inventory items on Objects
« Reply #3 on: 21 Nov 2020, 19:23 »
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.



even 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.
« Last Edit: 21 Nov 2020, 19:26 by viktor »

Re: Thumbleweed: Usin Inventory items on Objects
« Reply #4 on: 21 Nov 2020, 19:39 »
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

  • Cavefish
  • Fleeing the Cylon tyrrany...
    • Cassiebsg worked on one or more games that won an AGS Award!
    •  
    • Cassiebsg worked on one or more games that was nominated for an AGS Award!
Re: Thumbleweed: Usin Inventory items on Objects
« Reply #5 on: 21 Nov 2020, 23:20 »
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...

Re: Thumbleweed: Usin Inventory items on Objects
« Reply #6 on: 21 Nov 2020, 23:30 »
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".

Re: Thumbleweed: Usin Inventory items on Objects
« Reply #7 on: 22 Nov 2020, 07:34 »
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?
« Last Edit: 22 Nov 2020, 08:07 by viktor »

Re: Thumbleweed: Usin Inventory items on Objects
« Reply #8 on: 22 Nov 2020, 10:19 »
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").
« Last Edit: 22 Nov 2020, 10:31 by Crimson Wizard »

Re: Thumbleweed: Usin Inventory items on Objects
« Reply #9 on: 22 Nov 2020, 13:45 »
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 :)

Re: (Solved) Thumbleweed: Usin Inventory items on Objects
« Reply #10 on: 22 Nov 2020, 14:20 »
The proper way is to only use the AnyClick event and handle using inv items just like any other verb:

Code: Adventure Game Studio
  1.   else if (Verbs.UsedAction(eGA_UseInv)) {
  2.     // check player.ActiveInventory, etc.
  3.   }
Fail at Floaty Rog' now!  still having to deal with what games are going through