Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: En garde! on Fri 08/04/2005 06:12:50

Title: Help with inventory on hotspot
Post by: En garde! on Fri 08/04/2005 06:12:50
Right, I need a hotspot to trigger an animation on a character when an inventory item interacts with it.

This is the code I used on the hotspot:

  // script for hotspot1: Use inventory on hotspot
if (character[GetPlayerCharacter()].activeinv == 1) 
SetCharacterIdle (0, -1, -1);
SetCharacterView (0, 11);
AnimateCharacter (0, 0, 3, 0);

But it does nothing. Where's the problem? Can anybody help?
Title: Re: Help with inventory on hotspot
Post by: Scummbuddy on Fri 08/04/2005 07:06:37

Ã,  // script for hotspot1: Use inventory on hotspot
if (character[GetPlayerCharacter()].activeinv == 1)Ã, 
{
SetCharacterIdle (0, -1, -1);
SetCharacterView (0, 11);
AnimateCharacter (0, 0, 3, 0);
}
Title: Re: Help with inventory on hotspot
Post by: En garde! on Fri 08/04/2005 12:58:19
Still not working. It wouldn't accept the changes unles y erased a braket.

Now it looks like this;



#sectionstart hotspot1_a  // DO NOT EDIT OR REMOVE THIS LINE
function hotspot1_a(){
  // script for hotspot1: Use inventory on hotspot
if (character[GetPlayerCharacter()].activeinv == 1)
SetCharacterIdle (0, -1, -1);
SetCharacterView (0, 11);
AnimateCharacter (0, 0, 3, 0);
}
#sectionend hotspot1_a  // DO NOT EDIT OR REMOVE THIS LINE


And still nothing.
Title: Re: Help with inventory on hotspot
Post by: Ashen on Fri 08/04/2005 13:10:29
And it should look like:

#sectionstart hotspot1_a  // DO NOT EDIT OR REMOVE THIS LINE
function hotspot1_a(){
  // script for hotspot1: Use inventory on hotspot
if (character[GetPlayerCharacter()].activeinv == 1) { // Scummbuddy's bracket
  SetCharacterIdle (0, -1, -1);
  SetCharacterView (0, 11);
  AnimateCharacter (0, 0, 3, 0);
} // Scummbuddy's other bracket
}
#sectionend hotspot1_a  // DO NOT EDIT OR REMOVE THIS LINE
(Which, now that I've fixed the bold type, is much the same as khrismuc's.)

Other things to check (if you haven't already):
Is '1' the right item number?
Is '0' the right character? I find it easier to use their script names (EGO), rather than numbers.
Is view 11, loop 0 the right loop?
What if you use AnimateCharacterEx (0, 0, 3, 0,1, 0);, to make the animation blocking? It might be, since your script isn't blocking, something happens to 'cancel' the animation before it runs.

And, out of interest, what's the SetCharacterIdle (0, -1, -1); for? Do you need to set the delay to -1, given that you're disabling the view anyway?
Title: Re: Help with inventory on hotspot
Post by: Khris on Fri 08/04/2005 13:27:35
It should look like this:

#sectionstart hotspot1_aÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function hotspot1_a(){
Ã,  // script for hotspot1: Use inventory on hotspot
if (character[GetPlayerCharacter()].activeinv == 1)
{
SetCharacterIdle (0, -1, -1);
SetCharacterView (0, 11);
AnimateCharacter (0, 0, 3, 0);
Ã,  }
}
#sectionend hotspot1_aÃ,  // DO NOT EDIT OR REMOVE THIS LINE