With regards to TriggerDestroy(t), I suppose its good practice to destroy all trigger variables after they are used? Or is galaxy smart enough to help us collect and dump garbage. I know this is a little off topic here but i'm wondering if there are any variable types that can potentially leak. In JASS it was points and units i believe, always had to null them after usage.
That's like saying you create a dummy unit for some purpose and after you don't need it anymore you expect the game to automatically remove it.
How's the game supposed to know you don't need the unit anymore? How's it supposed to know you don't use the trigger anymore?
Think of a trigger not as just a variable, but as a real entity just like a unit or a doodad. It exists in the map until you destroy it.
And even if it's just a local variable the trigger will still behave normally even after the function has finished.
The reason why all triggers usually get assigned to globals is so that you can do stuff with them like disabling.
A local variable trigger that isn't destroyed cannot easily be stopped, since you can't reference it.
(That's how it worked in Wc3 and I'm certain it's like that in Sc2, too. I haven't tested it however.)
By the way:
// -- Complex types and automatic deletion --// // Many native types represent "complex" objects (i.e. larger than 4 bytes). The script language// automatically keeps track of these objects and deletes them from memory when they are no longer// used (that is, when nothing in the script references them any longer). The types which benefit// from automatic deletion are://// abilcmd, bank, camerainfo, marker, order, playergroup, point,// region, soundlink, string, text, timer, transmissionsource, unitfilter, unitgroup, unitref,// waveinfo, wavetarget//// Other object types must be explicitly destroyed with the appropriate native function when you// are done using them.
So everything else needs to be destroyed properly.
Vermore, from my experience the best way to learn a programming language is to get a book on the subject. For example, I taught myself Java using the book called "The Java Programming Language" by the same people who created Java. To get a better understanding of Galaxy, I would recommend learning C, since Galaxy is just a reduced version of C. I actually learned it by porting a C program into Java, since once you know one language well, you can easily pick up others. Andromeda is just way to get Java/C++ object-oriented functionality on top of Galaxy. The syntax is pretty much identical to Java, although it really works more like C++ (since it is implemented on top of C--).
// -- Complex types and automatic deletion --// // Many native types represent "complex" objects (i.e. larger than 4 bytes). The script language// automatically keeps track of these objects and deletes them from memory when they are no longer// used (that is, when nothing in the script references them any longer). The types which benefit// from automatic deletion are://// abilcmd, bank, camerainfo, marker, order, playergroup, point,// region, soundlink, string, text, timer, transmissionsource, unitfilter, unitgroup, unitref,// waveinfo, wavetarget//// Other object types must be explicitly destroyed with the appropriate native function when you// are done using them.
Thanks for verifying this. Are there any tutorials that cover the list of types that do need to be destroyed? I can only think of trigger and unit off the top of my head after looking at this list =/.
I'd just like to mention some differences between TriggerDestroy and TriggerEnable.
using TriggerEnable( some_trigger, false ) will cause all of the events for your trigger to fire, but the runActions (second argument) parameter will be false, allowing your trigger to check this condition and do nothing (assuming you have coded for this).
TriggerDestroy, on the other hand, will completely get rid of your trigger - any events related to it will be unregistered.
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
That's like saying you create a dummy unit for some purpose and after you don't need it anymore you expect the game to automatically remove it.
How's the game supposed to know you don't need the unit anymore? How's it supposed to know you don't use the trigger anymore?
Think of a trigger not as just a variable, but as a real entity just like a unit or a doodad. It exists in the map until you destroy it.
And even if it's just a local variable the trigger will still behave normally even after the function has finished.
The reason why all triggers usually get assigned to globals is so that you can do stuff with them like disabling.
A local variable trigger that isn't destroyed cannot easily be stopped, since you can't reference it.
(That's how it worked in Wc3 and I'm certain it's like that in Sc2, too. I haven't tested it however.)
By the way:
So everything else needs to be destroyed properly.
Vermore, from my experience the best way to learn a programming language is to get a book on the subject. For example, I taught myself Java using the book called "The Java Programming Language" by the same people who created Java. To get a better understanding of Galaxy, I would recommend learning C, since Galaxy is just a reduced version of C. I actually learned it by porting a C program into Java, since once you know one language well, you can easily pick up others. Andromeda is just way to get Java/C++ object-oriented functionality on top of Galaxy. The syntax is pretty much identical to Java, although it really works more like C++ (since it is implemented on top of C--).
Thanks for verifying this. Are there any tutorials that cover the list of types that do need to be destroyed? I can only think of trigger and unit off the top of my head after looking at this list =/.
@FuzzYD: Go
All complex native types that are not in that list need to be destroyed.
That means all except of int, bool, fixed, byte, char and all of those in the list.
I'd just like to mention some differences between TriggerDestroy and TriggerEnable.
using TriggerEnable( some_trigger, false ) will cause all of the events for your trigger to fire, but the runActions (second argument) parameter will be false, allowing your trigger to check this condition and do nothing (assuming you have coded for this).
TriggerDestroy, on the other hand, will completely get rid of your trigger - any events related to it will be unregistered.
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