Functions not working (SOLVED)

Started by NiksterG, Thu 14/12/2006 22:55:47

Previous topic - Next topic

NiksterG

I'm making my own functions in the global script. However, they are not working at all whenever i call them in other rooms. I've made one other function before, and that one worked (and still is), but all the new functions I'm making don't do anything. And I'm not getting any errors, either, unless I call the functions in room scripts.

This is my code for one of the functions that don't work:

Code: ags
function transtohuman() {
        GUIOff(6);
        PlaySound(9);
          if (character[PLAYER].view == 10) { //from dragon monster view
            SetCharacterView(PLAYER,  10);
            AnimateCharacterEx(PLAYER, 3, 5, 0, 1, 1);
          }
          else if (character[PLAYER].view == 8) { //from Tree Dweller view
            SetCharacterView(PLAYER, 10);
            AnimateCharacterEx(PLAYER, 0, 5, 0, 1, 1);
          }
          else if (cPlayer.View == 14) { //from bird
            cPlayer.LockView(10);
            cPlayer.Animate(4, 5, eOnce, eBlock, eBackwards);
          }
          else if (cPlayer.View == 16) { //from dragon
             cPlayer.LockView(10);
             cPlayer.Animate(5, 5, eOnce, eBlock, eBackwards);
          }
          else if (cPlayer.View == 22) { //from seer
            EnableCursorMode(eModeInteract);
            cPlayer.LockView(10);
            cPlayer.Animate(6, 5, eOnce, eBlock, eBackwards);
          }
        SetCharacterView(PLAYER, 10);
        if (GetGlobalInt(2) == 1) {
          AnimateCharacterEx(PLAYER, 2, 5, 0, 0, 1);
          SetCharacterViewEx(PLAYER, 6, 0, ALIGN_CENTRE);
          cPlayer.SetWalkSpeed(5, 5);
          SetCursorMode(0);
        }
        else{
          AnimateCharacterEx(PLAYER, 1, 5, 0, 0, 1);
          SetCharacterViewEx(PLAYER, 1, 0, ALIGN_CENTRE);
          cPlayer.SetWalkSpeed(5, 5);
          SetCursorMode(0);
        }
}


It's supposed to be an animation sequence that shows transformation into a human from various other forms... yes, i realize some of the script is AGS 2.62 and some is AGS 2.72... but that shouldn't make a difference. Does it? That's the last thing I have to try yet, and then I'm lost.

Any help is appreciated!

And a side question which is not as important... my .chm help file (the manual) doesn't work anymore. Is this because I have IE7 now instead of IE6? Thanks again.
Check out my games! (Not all made with AGS)

Khris

Next time, please post the exact error message you're getting.
But even without, I'm pretty sure that you forgot to import the functions.

In this case, add
Code: ags
import function transtohuman();
to the script header.

A quick check if that happens again:
As soon as you've typed "tra" in one of the room scripts, AGS should auto-complete that to "transhuman". If it doesn't, the functions is unknown to the room script i.e. not imported.

Ashen

If 'Enforce object-based scripting' isn't checked, then no, mixing old and new script commands shouldn't cause problems. It's not particularly good practice, and you should really update your code ASAP, whatever the problem is.

What errors DO you get, when you call it from room scripts? Have you definitely imported the function (in the Script Header), so it'll work in rooms? (As KhrisMUC said, this is the most common problem here.)
And when you call it from the Global Script, it just does nothing - Not the wrong thing, or an error message, or even WORK, just ... nothing? You could try adding a few Display commands to see how much of the function is actually run.

And to answer your side question: Possibly. Installing a new version of IE might've reset your security settings (which is usually why people can't open the manual). Try the suggestions in this thread (number 3 is the most common, I think) - they should be OK for IE7, too.
I know what you're thinking ... Don't think that.

NiksterG

This is really weird... I'm only 16, but apparently I've the memory of an old grandpa. I actually did forget to import the function in the script header. That's the reason that one function was working and the others weren't; it was in the script header. However, i completely forgot to put the other functions there. I suppose this is what happens when I lose access to the sacred AGS manual... :P

By the way, Ashen, that link worked, I can now read the .chm file. All I had to do was uncheck the "Always ask when opening this file" box. Heh, I feel like a dork now... ;D

Thanks for the help!
Check out my games! (Not all made with AGS)

SMF spam blocked by CleanTalk