Exports

Started by Dr Lecter, Mon 03/10/2005 21:05:14

Previous topic - Next topic

Dr Lecter

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'

Code: ags
      	 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.

Ishmael

I believe exports are not allowed within functions. You must define the variables outside all functions and export them outside functions.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Ashen

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.
I know what you're thinking ... Don't think that.

Dr Lecter

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!

Ashen

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:
Code: ags

        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);
}
I know what you're thinking ... Don't think that.

Dr Lecter

*Decides to just make it a global variable*

SMF spam blocked by CleanTalk