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.
I believe exports are not allowed within functions. You must define the variables outside all functions and export them outside functions.
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.
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!
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);
}
*Decides to just make it a global variable*