Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Dr Lecter on Mon 03/10/2005 21:05:14

Title: Exports
Post by: Dr Lecter on Mon 03/10/2005 21:05:14
I've searched the forum but none of them seem to explain it, and the manual doesn't work for me either. When I try to export some variables, I get this:

---------------------------
Compile Error
---------------------------
There was an error compiling your script. The problem was:
In: 'Global script'
Error (line 136): invalid export symbol 'somethingelse'

      if (IsInteractionAvailable (mouse.x,  mouse.y, eModeShoot) == 1) {
           int left = Random(5);
           int right = Random(5);
           int up = Random(5);
           int down = Random(5);
           int somethingelse = mouse.x +left -right;
           int somethingelse2 = mouse.y +up -down;
ProcessClick (somethingelse, somethingelse2,  eModeShoot);
export somethingelse;
export somethingelse2;
}

I also tried putting the export at the end of the global script but it said the variable wasn't defined.
Title: Re: Exports
Post by: Ishmael on Mon 03/10/2005 21:09:46
I believe exports are not allowed within functions. You must define the variables outside all functions and export them outside functions.
Title: Re: Exports
Post by: Ashen on Mon 03/10/2005 21:13:13
Do you even need to export those?
As Ishmael said, global variables have to be created and exported outside of any functions but, unless you use somethingelse and somethingelse2 somewhere else, you don't actually need to bother.
Title: Re: Exports
Post by: Dr Lecter on Mon 03/10/2005 21:28:50
Alas, I do rather need them outside. Its for my shooting engine, I'm adding bullet holes, and the like, to it. I suppose I could use a really REALLY long if statement, but it would easier if I could. Ah well, if statement here I come!
Title: Re: Exports
Post by: Ashen on Mon 03/10/2005 21:31:45
Why do you need an if statement? Just declare them at the top of your global script, and export them from there, then change the code to:

        if (IsInteractionAvailable (mouse.x,  mouse.y, eModeShoot) == 1) {
           int left = Random(5);
           int right = Random(5);
           int up = Random(5);
           int down = Random(5);
           somethingelse = mouse.x +left -right;
           somethingelse2 = mouse.y +up -down;
ProcessClick (somethingelse, somethingelse2,  eModeShoot);
}
Title: Re: Exports
Post by: Dr Lecter on Tue 04/10/2005 00:10:13
*Decides to just make it a global variable*