inventory specific hotspot usage?

Started by lilinuyasha, Thu 23/12/2010 05:23:38

Previous topic - Next topic

lilinuyasha

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.

I can Fluently speak Braille. I obtained a swiss army knife...From the Turkish Navy. My hands feel like rich brown suede. My blood smells like cologne. I AM Trey Love, The most Interesting Man in the World.

barefoot

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:

Code: ags

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


I May Not Be Perfect but I Have A Big Heart ..

lilinuyasha

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 ;)
I can Fluently speak Braille. I obtained a swiss army knife...From the Turkish Navy. My hands feel like rich brown suede. My blood smells like cologne. I AM Trey Love, The most Interesting Man in the World.

barefoot

Pleased I could help you..

barefoot
I May Not Be Perfect but I Have A Big Heart ..

Khris

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.

lilinuyasha

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.
I can Fluently speak Braille. I obtained a swiss army knife...From the Turkish Navy. My hands feel like rich brown suede. My blood smells like cologne. I AM Trey Love, The most Interesting Man in the World.

SMF spam blocked by CleanTalk