hello,I have encountered several problems while using the GA++ editor.
Can anyone help me with defining the local variables?
such as how to do it and how the script looks legit
Trigger test
{
events{}
actions{}
int a=0;//error,
how to define a local variable in GA++ editor
}
You are referring to Galaxy++, I believe? You define a local like in default galaxy, however the Trigger construct defines separate functions for event and action, so if you need a local variable, you need to define it either in the events or in the actions part, not somewhere in between:
Triggertest{events{inta=0;}actions{intb=0;}}
Also, Beier has stopped updating the Galaxy++ editor, it does not have support for new patch 1.5 natives, so it is probably not the best idea to start using it now.
Its actually not that hard once you familiarize yourself with the Native functions. For starters, make a hello world function.
1. Open your trigger editor, and create a new custom script.
2. Specify the Initilization function at the bottom of the custom script. This function will be called when the map loads. Lets call it Hello
3. Write your custom script. Start with the 'initialization function'.
The return type of the Initilization function is usually void.
The initialization function should have no parameters
const string constant ="Constant";//Global constant
string global ="Global";//This is a global variable
//Example function, returns integer, takes boolean as a parameter if integer is 1.
bool Derpinus(int i){return i ==1;}//This is the standard template for a trigger function. Trigger functions are always run in their own thread.
//It doesnt matter where you declare them in your script, you will still be able to reference them.
//Usually we will assign triggers to a variable, and use the holding variable to add events.
bool TriggerTest(bool tc, bool ra){//Vars
int i =0;
int key = EventKey();//Retrieves the ID of the key that was pressed
//Conditions - This condition allows only the 0 numpad to work
//c_keyNumPad0 (sp?) here is a Native constant
if( key != c_keyNumPad0){return true;}//Actions
while(i <10){//Do your print output functions here
i+=1;}return true;}
void Hello(){//Variables
string s ="Hello World";//<-- This is how you declare your locals
trigger t = TriggerCreate("TriggerTest");//Conditions
if( Derpinus(1)){
s ="Hello World Pass";}//Actions
//Use the print function, I can't remember the native off the top of my head, //but i think it's something like-
UIDisplayDebugMsg(etc etc etc);//This is how you add events - I may have the wrong parameters here, im recalling from my head
//What this should do is attach the event where any key is pressed to the Test Trigger above.
TriggerAddEventKeyPressed(t, c_playerGroupAll, c_anyKey, false, false);}
This is a very simple example, you have to really play around with the Natives to get the hang of it. You can find documentation for most of them in the Wiki. Just need to dig a bit.
Your example isn't necessarily wrong, it's just that galaxy script is (so) bad that you have to declare all local function variables at the top of the function before you attempt to execute any statements.
hello,I have encountered several problems while using the GA++ editor.
Can anyone help me with defining the local variables?
such as how to do it and how the script looks legit
Trigger test
{
events{}
actions{}
int a=0;//error,
how to define a local variable in GA++ editor
}
You are referring to Galaxy
++
, I believe? You define a local like in default galaxy, however the Trigger construct defines separate functions for event and action, so if you need a local variable, you need to define it either in the events or in the actions part, not somewhere in between:Also, Beier has stopped updating the Galaxy
++
editor, it does not have support for new patch 1.5 natives, so it is probably not the best idea to start using it now.thank you KueKen,We hope Beier can continue to update
Because sc2editor too complex
Do you have a better option or substitution
@zhaobn: Go
Its actually not that hard once you familiarize yourself with the Native functions. For starters, make a hello world function.
1. Open your trigger editor, and create a new custom script.
2. Specify the Initilization function at the bottom of the custom script. This function will be called when the map loads. Lets call it Hello
3. Write your custom script. Start with the 'initialization function'.
This is a very simple example, you have to really play around with the Natives to get the hang of it. You can find documentation for most of them in the Wiki. Just need to dig a bit.
Your example isn't necessarily wrong, it's just that galaxy script is (so) bad that you have to declare all local function variables at the top of the function before you attempt to execute any statements.
So, instead of:
Just do: