I figured we could use a thread to start documenting strange things about Galaxy that are undocumented by Blizzard. Some things I've noticed are below:
Galaxy scripts must end in a newline or else error line numbers will be significantly off or not work at all. This is a known issue by Blizzard, as their comments in the AI code confirm.
Bitwise operations cannot take place in a return statement. The safest way to perform these in Galaxy is in an if statement surrounded by parenthesis with a comparison to 0 outside of them.
Typedefs totally work! These work quite similar to how they would in Cxx, and let you make some 'custom' types which ultimately aid in readability, but don't affect how the compiler treats them.
Structs also work! They're great for organizing related blocks of data without having to duplicate arrays. These also work almost exactly like their Cxx counterparts.
New In Patch 1.5
All calls to StringTo<X> conversion native functions will result in exceptions if the input string is not already in the expected format. In the past you could rely on these returning the conversion type's default value, for example, 0 for int.
Past Behavior: StringToInt("marine") == 0
New Behavior: StringToInt("marine") throws a Galaxy runtime exception.
There are no documented methods of checking input prior to running the conversion natively.
I have to ask: does the exception cause any big problems, or can you handle it with a simple If/Then function? I mean if I do
if(StringToInt("marine")!=0)
followed by some code, will it "recover" from the exception, or does it cause the game to have problems?
Weird Quirks
I have noticed that, if you test without saving, all strings used in triggers are replaced by "Param/Value/". Triggers which use strings to load things, such as Environment - Set Lighting fail to work.
Water levels do not get set properly when testing, but they do after publishing. If set in GUI, the problem persists, but setting it in Galaxy script appears to fix the problem. It seems Blizzard forgot to update some code ;)
Regarding StringToInt("marine"), test it. If it throws an error, code following it can still be executed; it it's a galaxy runtime exception, that probably entails a thread crash at the very least, or a full stop to the galaxy environment at most.
That's a GUI issue, not a galaxy script issue.
There are other differences and bugs specific to the editor, such as game variants locking race attribute to a default value getting the wrong value in game yet working properly on bnet.
I figured we could use a thread to start documenting strange things about Galaxy that are undocumented by Blizzard. Some things I've noticed are below:
New In Patch 1.5
Past Behavior: StringToInt("marine") == 0
New Behavior: StringToInt("marine") throws a Galaxy runtime exception.
There are no documented methods of checking input prior to running the conversion natively.
@MotiveMe
I have to ask: does the exception cause any big problems, or can you handle it with a simple If/Then function? I mean if I do
followed by some code, will it "recover" from the exception, or does it cause the game to have problems?
Weird Quirks
StringToInt("marine")
, test it. If it throws an error, code following it can still be executed; it it's a galaxy runtime exception, that probably entails a thread crash at the very least, or a full stop to the galaxy environment at most.Don't dredge up old topics.