Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: lilinuyasha on Thu 23/12/2010 05:23:38

Title: inventory specific hotspot usage?
Post by: lilinuyasha on Thu 23/12/2010 05:23:38
well, i'm trying to get the well in my game to only respond to the use of the cheeseburger. (it's a drug game, so don't question it.) but everytime i use any inventory command on it, even just the plain old "UseInv()" function, it tells me :
"Error: prepare_script: error-18 (no such function in script) trying to run 'hHotspot3_UseInv' (room 6)"
i have tried rearranging the command to every possible thing i can think of, have searched the tutorials to no personal avail, and cannot seem to figure out a way to get it to work. would this have something to do with the inventory item itself or is it more a problem with the hotspot? i even tried writing " hHotspot3_iCheeseburger_Interact()" like a genius, since it compiled, but wound up falling flat on my face again. if anyone can provide hints, or even better, the bit of code i need, it would be much appreciated.

Title: Re: inventory specific hotspot usage?
Post by: barefoot on Thu 23/12/2010 05:55:40
Hi

Did you script through the Events panel for the WELL or did you just write the script straight into the room script? It has to be done through the events panel! (I suspect you just typed it into the room script).

Here is an example using an inventory item on a Hotsot done through the Events panel (You could just as easily use the 'Use inventory on this item' in the Events panel for the Well:


function hHotspot1_UseInv()
{


if(player.ActiveInventory==ihair)
  {
    cleech.Walk(149, 302, eBlock);
    cleech.FaceLocation(149, 189);
     cleech.LoseInventory(ihair);
      Display("You place the hair into the DNA test machine");
       Display("A while later the test comes up. It loads onto a floppy. You need to run a profile on it now");
        cleech.AddInventory(idisk);
         hHotspot1.Enabled=false;
  }
    else
  {

    cleech.Say("That's not what we want to test!");
  }
}


You could always put a copy of your script here for us to look at..

barefoot


Title: Re: inventory specific hotspot usage?
Post by: lilinuyasha on Thu 23/12/2010 08:07:19
I copied it exactly and used some minor modification to fix it to what i wanted. i'm not the best programmer but yes, i did just use it to the room script. i'll remember that setup for future reference, in case i want to make a RON game after i'm done with this first-ditch practice exercise. Thank you SO much for assiting a noob. it worked fine! you'll be my go to guy for everything now, i suppose ;)
Title: Re: inventory specific hotspot usage?
Post by: barefoot on Thu 23/12/2010 10:21:36
Pleased I could help you..

barefoot
Title: Re: inventory specific hotspot usage?
Post by: Khris on Thu 23/12/2010 11:41:13
lilinuyasha:
it seems you used the proper way to generate the function itself and the link to it in the events pane, then renamed or deleted the function, thus leaving AGS looking for "hHotspot3_UseInv", which was still entered in the link field.
Like barefoot explained (more or less in passing), only inside the one function is then distinguished between different inv items; there isn't supposed to be a function for every inv item/hotspot combination.
Title: Re: inventory specific hotspot usage?
Post by: lilinuyasha on Fri 24/12/2010 02:28:58
I'm not sure exactly what went wrong, but i think you're right. i also had a previous "UseInv" function in the events pane, and once i deleted it from that, the problem went away.