Hello, I've been using the GUI exclusively so far and ran into some limitations passing data around using basic types.
So I tried switching to using structs. However 2 problems I'm having:
Tried using this code for saving the result of a Vector struct operation and it throws me a Syntax error on the function declaration.. same thing when I try to use the Monkey example from the website's Wiki.
Problem2:
Function aside, if I just leave the Vector struct there, compile and import to my MapScript.galaxy again. Then try to initialize a Vector from a Custom Script action in the GUI, I get a Syntax error, Script view pops up showing my original mapscript. I remove the code and save and boom, my imported mapscript gets overwritten by the original.
So I'm a bit at a loss here on writing galaxy code and how to combine it with coding in the GUI. If someone could point me in the right direction that would be much appreciated.
And since this is my first topic here and I don't like taking without giving, here's the code to :
Link Removed: http://www.mediafire.com/download.php?rw02wll3jk2
It seems that Blizz removed support for pointers. So there's basically no way to pass structs.
For writing Galaxy I'd suggest you do it like this -> http://forums.sc2mapster.com/development/tutorials/551-trigger-how-to-not-use-gui/#p4
It's combining GUI and custom script in a clever way to enable you to write your own functions / globals / structs without having to import mapscript.galaxy.
Haha that's clever, thanks! Can anyone verify this method still works though? I'm getting a syntax error when using the struct in any other custom script outside of the Trigger:
As far as passing structs goes, I guess I could serialize them to a string if they only contain primite types & other structs. But that's.. very messy and would probably slow things down a lot
Lol it took me a while to figure that one out:
bool gt_VectorUse_Func (bool testConds, bool runActions) {
// Actions
if (!runActions) {
return true;
}
Vector myVector;
return true;
}
The variable declaration is wrong.
Local variables MUST be decleared at the top of the function. In GUI-made functions there's always the if(!runActions)... before you can write your locals.
So you have to use the same trick you used to declare the struct to actually use it in functions.
PS for passing structs you can use a work-a-round:
Create a global array:
Vector[1000] allMyVectors;
Then pass the index instead of the actual vector. Should work I think.
Ah I see, many thanks. I think I'll use the array trick for my return values as well, using the index for the # of return value. That should cut down on the need for structs a lot already
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hello, I've been using the GUI exclusively so far and ran into some limitations passing data around using basic types. So I tried switching to using structs. However 2 problems I'm having:
Problem1:
Tried using this code for saving the result of a Vector struct operation and it throws me a Syntax error on the function declaration.. same thing when I try to use the Monkey example from the website's Wiki.
Problem2:
Function aside, if I just leave the Vector struct there, compile and import to my MapScript.galaxy again. Then try to initialize a Vector from a Custom Script action in the GUI, I get a Syntax error, Script view pops up showing my original mapscript. I remove the code and save and boom, my imported mapscript gets overwritten by the original.
So I'm a bit at a loss here on writing galaxy code and how to combine it with coding in the GUI. If someone could point me in the right direction that would be much appreciated. And since this is my first topic here and I don't like taking without giving, here's the code to : Link Removed: http://www.mediafire.com/download.php?rw02wll3jk2
Haha that's clever, thanks! Can anyone verify this method still works though? I'm getting a syntax error when using the struct in any other custom script outside of the Trigger:
As far as passing structs goes, I guess I could serialize them to a string if they only contain primite types & other structs. But that's.. very messy and would probably slow things down a lot
@s3rius: Go
Ah I see, many thanks. I think I'll use the array trick for my return values as well, using the index for the # of return value. That should cut down on the need for structs a lot already