I just started scripting in the Galaxy language and I'm having some trouble with importing the files with the script inside it.
I followed this tutorial to try and start, but I also made my own trigger for a spell I had in mind (just a Blink spell with some AoE damage) and I used Galaxy + + to check the syntax of the code, and there were none. And then I imported the files, and renamed it MapScript.galaxy (and then after I saved it dissapeared from the Import palette) and then I start the game, and red text appears in the bottom left saying "Script load failed: Syntax error"... ( And of course noting happens with the spell :( )
//==================================================================================================////<YourMap>SetupGame////Name:<YourMap>//Author:<YourName>////==================================================================================================include"TriggerLibs/NativeLib"include"Globals.galaxy"voidMapInit(){UIDisplayMessage(PlayerGroupAll(),c_messageAreaSubtitle,StringToText("I Has Init!"));}
I suspect it may be because you are including Global.galaxy multiple times. Since your Global.galaxy file appears to declare some triggers, by including it multiple times, the compiler attempts to declare those trigger variables multiple times. In C, if two variables in the same scope (Global with global or local with local) have the same name it will cause a syntax error.
The syntax error says nothing... It only says "Script load failed: Syntax error", that's it.
But I'll try out that solution, and that means taking away the "include Globals.galaxy" line in those other files, except in the "MainScript.galaxy file, or what?
First, thanks, didn't see that... And I now convert it from string to text, but now nothing in the triggers happen when I start the game, not the "I has init" string or anything. (Not that it did so before, but now there isn't the "Syntax error" text at least).
Looks through your code, It appears you call a function Main(); in InitMap, but I don't see that function in any of your other files. Guessing from context the Main() file here would have been the one to invoke the functions in every other included .galaxy you have. Could you post the script for your Main(); For us to take a look?
Ignore that, overlooked it.
I noticed the triggers you created do not follow the basic trigger format. Trigger functions typically have the following structure. This might be the root cause of the problem.
Your MapInit function for example is of type void. Try changing it to bool MapInit( bool tc, bool ra){ return true;} and see if it works? If it does then it confirms the theory posted above. So try the same with the other triggers you initialized.
Other things to note:
There appears to be redundancy in including the NativeLib library in your files, you could probably do without it.
MapInit() could also be invoked as a function call rather than a trigger. By using it as a function call you won't need these lines:
The pro of this is you don't need the extra trigger variable. In large scale projects, having too many triggers that are created and just left in the memory might significantly reduce the amount of memory you have to work with from the 2MB limit.
The con is, your script executes sequentially. So if you have a lot of stuff at initialization without triggers, is going to increase your map load time. The reason you see Blizzards generated script using triggers for map initialization is that they create a thread whenever their event fires. So it all executes in parallel.
There is a galaxy function somewhere out there from s3rius that allows you to do a one time function run without the need for a useless trigger variable sitting in memory. How it works is that you call the function by it's string name, The trigger is created, run, then destroyed.
voidtRun(strings);triggert=TriggerCreate(s);//Run the trigger here, Don't wait for execution to completeTriggerDestroy(t);}
I've worked quite alot with triggers (JASS/vJASS) in WC3 before, so I know alot of the mechanics in triggers and such, but thanks anyway :D
But in WC3 you could include (requires/uses/needs were the commands then IIRC) the same script as many times as you wanted, in different triggers of course. But here you only need to include them in the first file then, MapScript, since they all en up in the same file anyway, right?
And for the bool MyTrigger instead of void MyTrigger, I got errors in Galaxy+ + when I did the bool thing, which is weird since I know it should work that way, but I decided that I would just go with void instead. But I'll try bool again ;)
I've worked quite alot with triggers (JASS/vJASS) in WC3 before, so I know alot of the mechanics in triggers and such, but thanks anyway :D But in WC3 you could include (requires/uses/needs were the commands then IIRC) the same script as many times as you wanted, in different triggers of course. But here you only need to include them in the first file then, MapScript, since they all en up in the same file anyway, right?
Using include multiple times is not required, but shouldn't cause any errors, either
Quote:
And for the bool MyTrigger instead of void MyTrigger, I got errors in Galaxy+ + when I did the bool thing, which is weird since I know it should work that way, but I decided that I would just go with void instead. But I'll try bool again ;)
Plain galaxy requires a function with 2 boolean parameters and a boolean return type to work as a trigger function. Galaxy++ supports void as well and adds the specifications internally. It shouldn't cause errors for valid plain Galaxy syntax, though.
Ok, well I still removed all requires from all other triggers except MapScript and MainScript, but still no results...
And I made all trigger-methods/functions bool, and added two bool parametres to them also :S
Is it just me, or is the MainScript.galaxy file missing in the map?
You need to import the file into your map, either with the import manager or with an MPQ editor; it cannot include files in some folder of your computer.
Had to add a custom script into the triggers to get this working. Modified a few of your galaxy scripts as well because the compiler was spewing errors.
(Mostly unexpected return value). I commented the changes made in the attached .galaxy files.
Reason why it wasn't working was that MainScript.galaxy was never being included. If you go to triggers and press Ctrl+F11, the only thing there was include TriggerLibs/natives and a generated InitMap() function. Thus the problem was fixed by manually including MainScript.galaxy in a custom script, then setting the start point by defining Main as the initializer function (See the bottom of the custom script).
Take a good look at the changes made, It'll help you understand what went wrong. Normally I would just guide you to solve the problem, but in this case its quite hard for me to explain it without fixing it. @_@
Ok, thank you soo much :D But it's still a bit weird that you had to go to such lengths to make this work :S
It shouldn't be like this, right ?
And what compiler spewed out errors? The default Galaxy compiler? What were the unexpected return values?
Those questions are just to make me understand the whole process more :D You don't have to answer them :P
Anyways, thank you all so much for helping me with this ;)
If you press Ctrl + F11, you always see the generated script by the triggers in the trigger editor. However, he imported a custom MapScript.galaxy, which included the MainScript.galaxy and used a custom InitMap function calling the Main function. You can have a look at this imported mapscript in the import-manager, if you check show reserved files.
I cannot check the map right now, but did you include the NativeLib? By default only the natives is included, NativeLib contains some other functions, which also need to be included; however it is only done automatically, if you use at least 1 Gui trigger.
And what compiler spewed out errors? The default Galaxy compiler?
Yeah, the Galaxy compiler, or syntax checker? I've heard somewhere galaxy compiles at run time so it might be the syntax checker here.
What were the unexpected return values?
Oops, made a mistake here, I meant "Expected return values"
You had some functions of boolean type (Triggers) that did not have a "return true;" statement at the end of it. So the syntax checker spit out an errors that said expected return value.
But it's still a bit weird that you had to go to such lengths to make this work :S It shouldn't be like this, right ?
Not to worry, always happy to spread the love to those who wish to learn galaxy <3 lol
Hmmm.. didn't notice this, theoretically, that should have worked. Not sure why it didn't.
I cannot check the map right now, but did you include the NativeLib?
I'm recalling from memory that I didn't see it. But then again, I didn't notice the MapScript.galaxy override. Will try take a look at it again tomorrow out of curiosity.
Sorry I couldn't respond yesterday. Net was down. Will take a look when I'm able. Strange.. when I tried it the other day It was working fine. There were little explosions wherever I targeted the spell.
Btw, please attach files to your post next time, it can be done through the edit feature. File sharing websites tend to have all sorts of junk all over these days so I find it rather cumbersome to use them =/
Oh right XD I haven't told you what the spell is suppoed to do yet, haha :P
It's like Blink, you teleport to the target, and deal some damage :D Simple spell, which I know can be done in the Data Editor, but I feel more comfortable with triggers, and I can't seem to understand the Data Editor much so it's simpler like this ;)
And also, I have the MapInit function which is supposed to output a message at map initialization, which it still doesn't... :(
But thank you so much for all your help so far :) Just need a little more and then I'll have a working map to start coding a bit more with.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Hello!
I just started scripting in the Galaxy language and I'm having some trouble with importing the files with the script inside it. I followed this tutorial to try and start, but I also made my own trigger for a spell I had in mind (just a Blink spell with some AoE damage) and I used Galaxy + + to check the syntax of the code, and there were none. And then I imported the files, and renamed it MapScript.galaxy (and then after I saved it dissapeared from the Import palette) and then I start the game, and red text appears in the bottom left saying "Script load failed: Syntax error"... ( And of course noting happens with the spell :( )
Those are all my triggers atm and I'm really sorry to ask this question but, what inside those could cause trouble ? :S
What does the syntax error message say?
I suspect it may be because you are including Global.galaxy multiple times. Since your Global.galaxy file appears to declare some triggers, by including it multiple times, the compiler attempts to declare those trigger variables multiple times. In C, if two variables in the same scope (Global with global or local with local) have the same name it will cause a syntax error.
The syntax error says nothing... It only says "Script load failed: Syntax error", that's it.
But I'll try out that solution, and that means taking away the "include Globals.galaxy" line in those other files, except in the "MainScript.galaxy file, or what?
In your last file, you have an if without parenthesis.. that wouldn't be valid in galaxy
++
either.Also, in same file, you use UIDisplayMessage with something of type string passed in last argument. In galaxy, you would have to convert it to a text.
First, thanks, didn't see that... And I now convert it from string to text, but now nothing in the triggers happen when I start the game, not the "I has init" string or anything. (Not that it did so before, but now there isn't the "Syntax error" text at least).
@Komaqtion: Go
Looks through your code, It appears you call a function Main(); in InitMap, but I don't see that function in any of your other files. Guessing from context the Main() file here would have been the one to invoke the functions in every other included .galaxy you have. Could you post the script for your Main(); For us to take a look?Ignore that, overlooked it.
I noticed the triggers you created do not follow the basic trigger format. Trigger functions typically have the following structure. This might be the root cause of the problem.
Your MapInit function for example is of type void. Try changing it to bool MapInit( bool tc, bool ra){ return true;} and see if it works? If it does then it confirms the theory posted above. So try the same with the other triggers you initialized.
Other things to note:
MapInit() could also be invoked as a function call rather than a trigger. By using it as a function call you won't need these lines:
Just directly invoke it in your Main()
The pro of this is you don't need the extra trigger variable. In large scale projects, having too many triggers that are created and just left in the memory might significantly reduce the amount of memory you have to work with from the 2MB limit.
The con is, your script executes sequentially. So if you have a lot of stuff at initialization without triggers, is going to increase your map load time. The reason you see Blizzards generated script using triggers for map initialization is that they create a thread whenever their event fires. So it all executes in parallel.
There is a galaxy function somewhere out there from s3rius that allows you to do a one time function run without the need for a useless trigger variable sitting in memory. How it works is that you call the function by it's string name, The trigger is created, run, then destroyed.
I've worked quite alot with triggers (JASS/vJASS) in WC3 before, so I know alot of the mechanics in triggers and such, but thanks anyway :D But in WC3 you could include (requires/uses/needs were the commands then IIRC) the same script as many times as you wanted, in different triggers of course. But here you only need to include them in the first file then, MapScript, since they all en up in the same file anyway, right?
And for the bool MyTrigger instead of void MyTrigger, I got errors in Galaxy+ + when I did the bool thing, which is weird since I know it should work that way, but I decided that I would just go with void instead. But I'll try bool again ;)
Using include multiple times is not required, but shouldn't cause any errors, either
Plain galaxy requires a function with 2 boolean parameters and a boolean return type to work as a trigger function. Galaxy
++
supports void as well and adds the specifications internally. It shouldn't cause errors for valid plain Galaxy syntax, though.Ok, well I still removed all requires from all other triggers except MapScript and MainScript, but still no results... And I made all trigger-methods/functions bool, and added two bool parametres to them also :S
Dunno what else it could be...
@Komaqtion: Go
are you open to the idea of attaching your map here so we can take a look? this is truly a wierd one.
Sure :D No problems, since it's just a test map :D
Here it is ;)
Is it just me, or is the MainScript.galaxy file missing in the map?
You need to import the file into your map, either with the import manager or with an MPQ editor; it cannot include files in some folder of your computer.
Hmm, now that I opened the map myself, there were no files imported at all :S I'll upload it again XD (Still doesn't work btw :S)
https://rapidshare.com/files/2449216894/Testing.SC2Map
@Komaqtion: Go
Had to add a custom script into the triggers to get this working. Modified a few of your galaxy scripts as well because the compiler was spewing errors. (Mostly unexpected return value). I commented the changes made in the attached .galaxy files.
Reason why it wasn't working was that MainScript.galaxy was never being included. If you go to triggers and press Ctrl+F11, the only thing there was include TriggerLibs/natives and a generated InitMap() function. Thus the problem was fixed by manually including MainScript.galaxy in a custom script, then setting the start point by defining Main as the initializer function (See the bottom of the custom script).
Take a good look at the changes made, It'll help you understand what went wrong. Normally I would just guide you to solve the problem, but in this case its quite hard for me to explain it without fixing it. @_@
@Kueken531: Go
Nice teamwork, we pretty much took turns on this one :P
Ok, thank you soo much :D But it's still a bit weird that you had to go to such lengths to make this work :S It shouldn't be like this, right ?
And what compiler spewed out errors? The default Galaxy compiler? What were the unexpected return values? Those questions are just to make me understand the whole process more :D You don't have to answer them :P
Anyways, thank you all so much for helping me with this ;)
If you press Ctrl + F11, you always see the generated script by the triggers in the trigger editor. However, he imported a custom MapScript.galaxy, which included the MainScript.galaxy and used a custom InitMap function calling the Main function. You can have a look at this imported mapscript in the import-manager, if you check show reserved files.
I cannot check the map right now, but did you include the NativeLib? By default only the natives is included, NativeLib contains some other functions, which also need to be included; however it is only done automatically, if you use at least 1 Gui trigger.
@Komaqtion: Go
And what compiler spewed out errors? The default Galaxy compiler?
Yeah, the Galaxy compiler, or syntax checker? I've heard somewhere galaxy compiles at run time so it might be the syntax checker here.
What were the unexpected return values?
Oops, made a mistake here, I meant "Expected return values"
You had some functions of boolean type (Triggers) that did not have a "return true;" statement at the end of it. So the syntax checker spit out an errors that said expected return value.
But it's still a bit weird that you had to go to such lengths to make this work :S It shouldn't be like this, right ?
Not to worry, always happy to spread the love to those who wish to learn galaxy <3 lol
@Kueken531: Go
However, he imported a custom MapScript.galaxy
Hmmm.. didn't notice this, theoretically, that should have worked. Not sure why it didn't.
I cannot check the map right now, but did you include the NativeLib?
I'm recalling from memory that I didn't see it. But then again, I didn't notice the MapScript.galaxy override. Will try take a look at it again tomorrow out of curiosity.
Ok, so your map doesn't work for me :( Or at least the spell doesn't work, and the MapInit message isn't showing either...
I'll upload all my files with the galaxy script in them here, and also your map (with some changes by me).
https://rapidshare.com/files/3736379486/Testing_-_Helped.SC2Map
https://rapidshare.com/files/4059450669/BurningStep.galaxy
https://rapidshare.com/files/1902007730/Debug.galaxy
https://rapidshare.com/files/877631424/First_script.galaxy
https://rapidshare.com/files/3697056212/Globals.galaxy
https://rapidshare.com/files/3478523590/MainScript.galaxy
https://rapidshare.com/files/563003663/MapInit.galaxy
The file "First script" is the one I later rename to MapScript.galaxy after I've imported it ;)
@Komaqtion: Go
Sorry I couldn't respond yesterday. Net was down. Will take a look when I'm able. Strange.. when I tried it the other day It was working fine. There were little explosions wherever I targeted the spell.
Btw, please attach files to your post next time, it can be done through the edit feature. File sharing websites tend to have all sorts of junk all over these days so I find it rather cumbersome to use them =/
Oh right XD I haven't told you what the spell is suppoed to do yet, haha :P
It's like Blink, you teleport to the target, and deal some damage :D Simple spell, which I know can be done in the Data Editor, but I feel more comfortable with triggers, and I can't seem to understand the Data Editor much so it's simpler like this ;)
And also, I have the MapInit function which is supposed to output a message at map initialization, which it still doesn't... :(
But thank you so much for all your help so far :) Just need a little more and then I'll have a working map to start coding a bit more with.