Thanks everyone who clarified certain aspects of the editor.
Sorry for the lack of response, I had many tests during the past week, still have more to come but nevertheless here is my post...
@s3rius
Again, thanks for all the help. It cleared up my misunderstandings and I'll definitely be utilizing the dynamic trigger creation since my project is quite large-scale.
@X-Pilot
Thanks for the advice! I'll try to pick one up at a local bookstore if I can find it.
Luckily, Stanford publicly uploads their lectures and assignments on their computer science course page so I just downloaded all the handouts and assignments (in Java). After finishing all of Stanford's work, I'll also do MIT's tasks in Python. In conjunction to learning from reading scripts, writing in Andromeda, writing in Java, writing in Python and getting that Java book (maybe even a C book if I can find one), hopefully I can build a solid foundation for programming.
@Anyone
Since I'm not yet in university, no one in my family does programming and my school doesn't provide computer science (besides renaming thumb-drives or doing Excel), if anyone with a good programming background could give me their MSN or just e-mail via PM, that'll be great. Sometimes I have an odd question or two, but no one to ask. :P
Thanks AzothHyjal and fernsauce, I recognize them from Java! Now I know what they are called... :s
@XPilot: Go
Hello XPilot! Haha, thank you. My school doesn't provide computer science and I'm not in university yet so I never got the chance to learn it properly... When I started programming I just wrote programs by deducing how it works from examples, so my understanding and vocabulary are down in the pits.
I'm currently watching lectures from Stanford and MIT to improve my foundation.
By the way, I tried searching online and researching, but what exactly are enrichments and what are they used for?
Is it something like allocating some attributes/properties to a class?
You can't, however, change any of these functions by hand. You can
set-up an initializer function in each of your custom script sections.
These initializers will then automatically be called in InitTriggers().
So in there you could, for example, start some of your triggers or
functions to spawn units, or do whatever.
How would I include the initializer function if I'm coding outside of SC2? Currently my setup is coding in Notepadplusplus with Andromeda syntax and then compiling with Andromeda which also injects my code into a specific map as an import.
Or is it reverse psychology for the sake of user-friendliness?
What I mean is, that we write a initializer function that includes the functions or things done instead of the other way around. So we write a function that starts with "Init", it gets marked and included in InitTriggers() which will then be ran during map initialization (Is that right?). I think this is what the includer does in the GUI instead of having some marker within the function to tell it to be included by "InitXYZ" which is then generated during compilation as it suggests in the GUI.
Our functions are stored in the computer's memory, but only when we start playing the map (=loading it) and not when we're compiling (=saving) it. But just because they're loaded into memory doesn't mean they're set in store, by the way. You can very conveniently add events on the run:
voidCreateUnit2(intplayer,stringunittype,pointposition){//We call a native to create a unit. No idea if the parameters are correct^^UnitCreate(1,unittype,0,player,point,270);//Now we add our unit's death as an event to some triggerTriggerAddEventUnitDied(gt_SomeDeathTrigger,UnitLastCreated());}
Thats pretty neat, I'll be using this quite a lot.
Concerning gt_SomeDeathTrigger, is the parameter limited to global triggers? If not, does everything else gets automatically included when I use function TriggerAddEventXYZ for any function I write? (In other words do I need to write anything else after adding the event within a function, other than the actual function that is ran when the event is triggered?)
What exactly do you mean by that? Of course you can run a function just
like normal and make it check for conditions, but keep in mind that you
can't use event responses (EventUnit(), EventPlayer(), etc) since there
was no event starting the function. So you have to supply parameters for
the function another way.
Haha, sorry for the confusion. You already answered this by in the next paragraph by clearing up one of my misunderstandings of the how it worked. Thanks!
And FuzzyD, you've been a great help too. Thanks a bunch! :)
Thanks for clearing up most of the aspects of how it works.
Considering only the functions...
Concerning the actual conditions for Function A, B and C. Wouldn't the program have to run whatever is inside the curly braces for every single function every time any action is done to check for any conditions that matches with the action?
For example:
Function A - When I type "-test"
Function B - When I type "-test2"
Funciton C - When I move unit X
Be it a similar or completely different function, each function must be ran first to check for the conditions... because condition checks are within curly braces.
And what if you have a void function which checks for these conditions but you don't want it to be ran when triggered, only when you call on it (while conditions are true)? How does it differentiate? I think my questions are now deviating from SC2 and more into actual Galaxy or just programming as a whole, sorry about that.
Considering "Whenever an event fires and triggers a function"...
This is exactly what I'm confused about... if you need a function that checks for a condition to run a function... and another function to run that previous function... its sort of like a endless loop of logic. That "event" is ultimately another function right? Just like how in GUI many of the presets or special data types are actually just strings.
When compiled all constants in your code should automatically be swapped with their respective values. I'm not sure whether the Galaxy Editor does so, but at least it should.
That makes it the best since read times are great and write times barely exist. Also you don't have to do the string additions like in 2).
Thanks!
But if all the constants in the code are swapped with their respective values during compilation, would I still be able to dynamically call on them?
E.g. DURING the game, something happens and the game sets player's first skill with an ID of 3. This means when he uses his first skill, constant variables involved would be attackName[3], attackDamage[3] and attackRange[3], where attackName[ID] is the call to this constant with array of "ID".
"void" from my understanding means there is no return type? So the code runs from top to bottom and sees the code in your post...
Let's say when it ran through the conditions are not met and it skips out of the function... what if the conditions are met after running the function? I understand when we actually script this that it will run when the conditions are met, but I can't comprehend how it works! If the entire code file is only ran once from top to bottom, how does it check the condition when it is indeed true?
Hmm... I think my phrasing has displaced my actual meaning.
I only referred to trigger events as a reference to support what I was asking for. Like how triggers are just functions in galaxy, I don't intend to mimic creating a function and its respective events.
To clear any misunderstandings, what I'm asking for is how to write a function such that if certain conditions are true, that function will run its contents. Again, this is due to my lack of understanding of how programming works... I just don't understand how it runs through the code... does programs run through the compiled code every 0.01 seconds? If that is true, I can just place a if-then statement to run functions... but I don't see how that is effective for CPU usage... so I disregarded that thought.
Thanks a bunch for the guidance. Although it does answer my question in a way, I'm afraid that wasn't really what I was looking for...
After looking at some of s3rius scripts over the forums you don't really need the "testConds" and "runActions"... I was wondering how script events without following the trigger format. Sorry for the lack of clarification.
Hello, recently I have started learning Andromeda (a language extension for galaxy) but my programming experience is just preliminary with Java, C and other various languages. Although I know quite a variety of languages, I only coded small things and fixed bugs in other scripts so I never really started any grand project.
One problem I encountered in my attempt at a grand project, was how to script functions that ran based on conditions?
I'm fine with all the scripting within functions, but say I want a certain function to run when unit has entered region "x"... how would one do so?
I think its mainly because of my lack of understanding how scripts are read by the computer...
I understand how it is read from top to bottom, therefore you need to define/declare certain things before you use them. I also understand how you write functions and call them within other functions/etc. But how would you... uh, not sure if this is the right word, dynamically call the functions?
In the GUI, all you need to do was create a trigger, set the event, then do whatever in the actions. So basically my question concerns how to script events (not about creating new events) so that it will run function "doSomething()" when the specified event occurs.
0
Perhaps this is due with the fact that I'm coding in Andromeda, but here is the problem anyway.
class foo {
int x;
}
foo[2][2] a;
... and then somewhere...
a[1][1].x = 1;
UIDisplayMessage(PlayerGroupAll(), c_messageAreaChat, IntToString(a[1][1]));
a[1][2].x = 2;
UIDisplayMessage(PlayerGroupAll(), c_messageAreaChat, IntToString(a[1][1]));
It should say: 1 and then 1... right? Why does it show me 1, 2? or do they share the same x?
0
Thanks everyone who clarified certain aspects of the editor.
Sorry for the lack of response, I had many tests during the past week, still have more to come but nevertheless here is my post...
@s3rius Again, thanks for all the help. It cleared up my misunderstandings and I'll definitely be utilizing the dynamic trigger creation since my project is quite large-scale.
@X-Pilot Thanks for the advice! I'll try to pick one up at a local bookstore if I can find it. Luckily, Stanford publicly uploads their lectures and assignments on their computer science course page so I just downloaded all the handouts and assignments (in Java). After finishing all of Stanford's work, I'll also do MIT's tasks in Python. In conjunction to learning from reading scripts, writing in Andromeda, writing in Java, writing in Python and getting that Java book (maybe even a C book if I can find one), hopefully I can build a solid foundation for programming.
@Anyone Since I'm not yet in university, no one in my family does programming and my school doesn't provide computer science (besides renaming thumb-drives or doing Excel), if anyone with a good programming background could give me their MSN or just e-mail via PM, that'll be great. Sometimes I have an odd question or two, but no one to ask. :P
0
Thanks AzothHyjal and fernsauce, I recognize them from Java! Now I know what they are called... :s
@XPilot: Go Hello XPilot! Haha, thank you. My school doesn't provide computer science and I'm not in university yet so I never got the chance to learn it properly... When I started programming I just wrote programs by deducing how it works from examples, so my understanding and vocabulary are down in the pits. I'm currently watching lectures from Stanford and MIT to improve my foundation.
0
@AzothHyjal: Go
Thanks AzothHyjal!
By the way, I tried searching online and researching, but what exactly are enrichments and what are they used for? Is it something like allocating some attributes/properties to a class?
0
@s3rius: Go
Thanks once again Professor.
0
s3rius, thanks! You answered my questions exactly as well as some extra nifty stuff.
How would I include the initializer function if I'm coding outside of SC2? Currently my setup is coding in Notepadplusplus with Andromeda syntax and then compiling with Andromeda which also injects my code into a specific map as an import.
Or is it reverse psychology for the sake of user-friendliness? What I mean is, that we write a initializer function that includes the functions or things done instead of the other way around. So we write a function that starts with "Init", it gets marked and included in InitTriggers() which will then be ran during map initialization (Is that right?). I think this is what the includer does in the GUI instead of having some marker within the function to tell it to be included by "InitXYZ" which is then generated during compilation as it suggests in the GUI.
Thats pretty neat, I'll be using this quite a lot. Concerning gt_SomeDeathTrigger, is the parameter limited to global triggers? If not, does everything else gets automatically included when I use function TriggerAddEventXYZ for any function I write? (In other words do I need to write anything else after adding the event within a function, other than the actual function that is ran when the event is triggered?)
Haha, sorry for the confusion. You already answered this by in the next paragraph by clearing up one of my misunderstandings of the how it worked. Thanks!
And FuzzyD, you've been a great help too. Thanks a bunch! :)
0
Thanks for clearing up most of the aspects of how it works.
Considering only the functions... Concerning the actual conditions for Function A, B and C. Wouldn't the program have to run whatever is inside the curly braces for every single function every time any action is done to check for any conditions that matches with the action?
For example: Function A - When I type "-test" Function B - When I type "-test2" Funciton C - When I move unit X
Be it a similar or completely different function, each function must be ran first to check for the conditions... because condition checks are within curly braces.
And what if you have a void function which checks for these conditions but you don't want it to be ran when triggered, only when you call on it (while conditions are true)? How does it differentiate? I think my questions are now deviating from SC2 and more into actual Galaxy or just programming as a whole, sorry about that.
Considering "Whenever an event fires and triggers a function"... This is exactly what I'm confused about... if you need a function that checks for a condition to run a function... and another function to run that previous function... its sort of like a endless loop of logic. That "event" is ultimately another function right? Just like how in GUI many of the presets or special data types are actually just strings.
0
Thanks! But if all the constants in the code are swapped with their respective values during compilation, would I still be able to dynamically call on them? E.g. DURING the game, something happens and the game sets player's first skill with an ID of 3. This means when he uses his first skill, constant variables involved would be attackName[3], attackDamage[3] and attackRange[3], where attackName[ID] is the call to this constant with array of "ID".
0
No problem FuzzYD. I'm still quite new to programming so pardon my lack of knowledge within this field.
Exactly what I'm confused about!
"void" from my understanding means there is no return type? So the code runs from top to bottom and sees the code in your post... Let's say when it ran through the conditions are not met and it skips out of the function... what if the conditions are met after running the function? I understand when we actually script this that it will run when the conditions are met, but I can't comprehend how it works! If the entire code file is only ran once from top to bottom, how does it check the condition when it is indeed true?
Thanks for the continuous support.
0
Hmm... I think my phrasing has displaced my actual meaning.
I only referred to trigger events as a reference to support what I was asking for. Like how triggers are just functions in galaxy, I don't intend to mimic creating a function and its respective events.
To clear any misunderstandings, what I'm asking for is how to write a function such that if certain conditions are true, that function will run its contents. Again, this is due to my lack of understanding of how programming works... I just don't understand how it runs through the code... does programs run through the compiled code every 0.01 seconds? If that is true, I can just place a if-then statement to run functions... but I don't see how that is effective for CPU usage... so I disregarded that thought.
0
Structs are called records in the GUI.
BTW, this is the Galaxy Scripting section.
0
For my current map, I have heaps of constant information (A LOT) I want to store, which I will then use throughout the game.
Please note:
Thanks.
Best Regards, Vermore
0
Thanks a bunch for the guidance. Although it does answer my question in a way, I'm afraid that wasn't really what I was looking for...
After looking at some of s3rius scripts over the forums you don't really need the "testConds" and "runActions"... I was wondering how script events without following the trigger format. Sorry for the lack of clarification.
0
Hello, recently I have started learning Andromeda (a language extension for galaxy) but my programming experience is just preliminary with Java, C and other various languages. Although I know quite a variety of languages, I only coded small things and fixed bugs in other scripts so I never really started any grand project.
One problem I encountered in my attempt at a grand project, was how to script functions that ran based on conditions? I'm fine with all the scripting within functions, but say I want a certain function to run when unit has entered region "x"... how would one do so?
I think its mainly because of my lack of understanding how scripts are read by the computer... I understand how it is read from top to bottom, therefore you need to define/declare certain things before you use them. I also understand how you write functions and call them within other functions/etc. But how would you... uh, not sure if this is the right word, dynamically call the functions?
In the GUI, all you need to do was create a trigger, set the event, then do whatever in the actions. So basically my question concerns how to script events (not about creating new events) so that it will run function "doSomething()" when the specified event occurs.
Thanks.
Best Regards, Vermore