Jibble

Author Topic: ItemGiven  (Read 214 times)

ItemGiven
« on: 17 Apr 2020, 10:30 »
Morning Guys, I've been using tumbleweed template and i can't seem to 'Give' an item to a charater

I looked in the manual but i keep getting this error

Capture" border="0


Code: Adventure Game Studio
  1.  // GIVE TO
  2.   else if (Verbs.UsedAction(eGA_GiveTo)) {
  3.   {
  4.     if (ItemGiven == iOldMilk)
  5.     {
  6.     player.Say("Do you want this Cup?");
  7.     cJordan.Say("No, thank you.");
  8.     }
  9.     else Verbs.Unhandled();
  10.     }
  11.   }
  12.  

Re: ItemGiven
« Reply #1 on: 17 Apr 2020, 12:29 »
This was apparently changed at some point, you have to use

Code: Adventure Game Studio
  1.   if (Verbs.GetItemGiven() == iOldMilk)

Or, if you need to compare it multiple times:
Code: Adventure Game Studio
  1.   // before using ItemGiven for the first time in a function
  2.   InventoryItem* ItemGiven = Verbs.GetItemGiven();
  3.  
  4.   // this will work now
  5.   if (ItemGiven == iOldMilk)
Fail at Floaty Rog' now!  still having to deal with what games are going through

Re: ItemGiven
« Reply #2 on: 17 Apr 2020, 12:47 »
"Unresolved import" error means that variable ItemGiven is declared in script (as import), but not actually created.

What is this "ItemGiven", did you declare it yourself or it was declared by template? If latter, then it's worth reporting this to template author: https://www.adventuregamestudio.co.uk/forums/index.php?topic=54762.0
« Last Edit: 17 Apr 2020, 12:49 by Crimson Wizard »

Re: ItemGiven
« Reply #3 on: 17 Apr 2020, 13:09 »
It's declared here: https://github.com/dkrey/ags_tumbleweed/blob/master/verbgui.asc#L112
But can only be accessed using this: https://github.com/dkrey/ags_tumbleweed/blob/master/verbgui.asc#L742

I'm guessing it used to be a global variable until the code was refactored, because what Lukey tried is what it says in the official PDF that comes with the template, but apparently it wasn't also updated accordingly.
Fail at Floaty Rog' now!  still having to deal with what games are going through

Re: ItemGiven
« Reply #4 on: 17 Apr 2020, 13:26 »
It's declared here: https://github.com/dkrey/ags_tumbleweed/blob/master/verbgui.asc#L112

That's a member of a struct and hidden in asc, but my point is, in Lukey J's code it's used as a regular variable, and if that compiles this means that maybe this variable is declared again somewhere by mistake.
« Last Edit: 17 Apr 2020, 13:28 by Crimson Wizard »

Re: ItemGiven
« Reply #5 on: 17 Apr 2020, 13:39 »
If I try to use  ItemGiven  I get a compile time "undefined symbol" error, as expected.

When I try to reproduce the error by adding  import InventoryItem* ItemGiven;  to the global header, I get "Variable 'ItemGiven' is already defined"...
Fail at Floaty Rog' now!  still having to deal with what games are going through

Re: ItemGiven
« Reply #6 on: 17 Apr 2020, 13:42 »
When I try to reproduce the error by adding  import InventoryItem* ItemGiven;  to the global header, I get "Variable 'ItemGiven' is already defined"...

Ah, it is declared in GlobalScript.asc! That's the mistake. They forgot to remove this declaration.

Code: Adventure Game Studio
  1. // main global script file
  2. import InventoryItem*ItemGiven;        // Item given to a character
  3.  
  4.  
« Last Edit: 17 Apr 2020, 13:44 by Crimson Wizard »