I just started coding in galaxy, and decided to view script of a basic gui trigger (Map init event, display message TEST1).
However, I don't know which part of the code actually executes the event.
bool gt_MeleeInitialization_Func (bool testConds, bool runActions) {
// Actions
if (!runActions) {
return true;
}
UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringExternal("Param/Value/D5973442"));
return true;
}
//--------------------------------------------------------------------------------------------------
void gt_MeleeInitialization_Init () {
gt_MeleeInitialization = TriggerCreate("gt_MeleeInitialization_Func");
TriggerAddEventMapInit(gt_MeleeInitialization);
}
Pasting that into a custom script page gives me a syntax error for the below part of the trigger.
//--------------------------------------------------------------------------------------------------
void gt_MeleeInitialization_Init () {
gt_MeleeInitialization = TriggerCreate("gt_MeleeInitialization_Func");
TriggerAddEventMapInit(gt_MeleeInitialization);
If i remove that, however, the script does not execute.
I know this is noobish, but i'm familiar with almost every other aspect of galaxy code other then getting the damn trigger to run.
Any help appreciated; thanks!
I guess you've copied that from the Custom Script View and then deleted the GUI trigger resembling that. In this case you have to watch out for two things.
First, the GUI trigger automatically creates a trigger variable (it should be somewhat at the top of the custom script) which you have to copy too:
triggergtMeleeInit;//Declare a new triggerboolgt_MeleeInitialization_Func(booltestConds,boolrunActions){// Actionsif(!runActions){returntrue;}UIDisplayMessage(PlayerGroupAll(),c_messageAreaSubtitle,StringExternal("Param/Value/D5973442"));returntrue;}//--------------------------------------------------------------------------------------------------voidgt_MeleeInitialization_Init(){//Here you have to insert the trigger variable. The name that was there before is the name of the automatically//generated trigger variable, which got deleted after you deleted the GUI trigger.gtMeleeInit=TriggerCreate("gt_MeleeInitialization_Func");TriggerAddEventMapInit(gtMeleeInit);//Also gotta add it here, to add the map init event to the right trigger.}
A second way to create the trigger is to make it local. You can use this if you know that you won't have to disable/enable/destroy the trigger externally anymore.
voidgt_MeleeInitialization_Init(){//Same idea like before, but instead of using a global variable we just make a local one.triggert;t=TriggerCreate("gt_MeleeInitialization_Func");TriggerAddEventMapInit(t);}
And then there is a second thing to watch out for. gt_MeleeInitialization_Init() creates the trigger. So as long as this function doesn't execute, the trigger will not work. So you have to execute this function at map init.
How to do that? You can use the initializer. Every Custom Script has a small frame at the bottom which says Initializer Function. If you write the name of a function there it'll be automatically executed at map start, even before Map Initialization triggers are run. Just paste "gt_MeleeInitialization_Init" into this line and it should work (I don't think you need the brackets).
One limitation though - initializer functions must not contain any Waits or similar things. So don't use them as a substitution for a Map Init trigger.
PS: Custom Scripts can not only have events, but with it you can use events even better than with GUI. In Custom Script you can add new events to a trigger whenever you like, whereas GUI triggers must have all their events declared from the beginning on.
Thanks a ton guys! Was gonna give up on .galaxy because i thought events were disabled.
Last question, how do i use the code syntax on this website? Eg: The color syntax that people use when they post galaxy code.
When you reply to a topic, check out what kind of markup type you're using (right under the reply window).
If you have WikiCreole selected then you can just click the Code-tag button right above the reply window. A new dialog appears that asks you for the type of code. Just enter Galaxy then.
If you're not using the retarded WikiCreole you can write it yourself. The tag is:
< <code galaxy> >
bla bla
< </code galaxy> >
Just without the spaces between the angled brackets.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
bool gt_MeleeInitialization_Func (bool testConds, bool runActions) { // Actions if (!runActions) { return true; } UIDisplayMessage(PlayerGroupAll(), c_messageAreaSubtitle, StringExternal("Param/Value/D5973442")); return true; } //-------------------------------------------------------------------------------------------------- void gt_MeleeInitialization_Init () { gt_MeleeInitialization = TriggerCreate("gt_MeleeInitialization_Func"); TriggerAddEventMapInit(gt_MeleeInitialization); }
Pasting that into a custom script page gives me a syntax error for the below part of the trigger.//-------------------------------------------------------------------------------------------------- void gt_MeleeInitialization_Init () { gt_MeleeInitialization = TriggerCreate("gt_MeleeInitialization_Func"); TriggerAddEventMapInit(gt_MeleeInitialization);
If i remove that, however, the script does not execute. I know this is noobish, but i'm familiar with almost every other aspect of galaxy code other then getting the damn trigger to run. Any help appreciated; thanks!Nevermind, finally figured out that custom script can't have events.. great
Well, that's flat out wrong.
executes the event. Sort of. It tells the game to call that function when map initialization happens.
I guess you've copied that from the Custom Script View and then deleted the GUI trigger resembling that. In this case you have to watch out for two things.
First, the GUI trigger automatically creates a trigger variable (it should be somewhat at the top of the custom script) which you have to copy too:
A second way to create the trigger is to make it local. You can use this if you know that you won't have to disable/enable/destroy the trigger externally anymore.
And then there is a second thing to watch out for. gt_MeleeInitialization_Init() creates the trigger. So as long as this function doesn't execute, the trigger will not work. So you have to execute this function at map init.
How to do that? You can use the initializer. Every Custom Script has a small frame at the bottom which says Initializer Function. If you write the name of a function there it'll be automatically executed at map start, even before Map Initialization triggers are run. Just paste "gt_MeleeInitialization_Init" into this line and it should work (I don't think you need the brackets).
One limitation though - initializer functions must not contain any Waits or similar things. So don't use them as a substitution for a Map Init trigger.
PS: Custom Scripts can not only have events, but with it you can use events even better than with GUI. In Custom Script you can add new events to a trigger whenever you like, whereas GUI triggers must have all their events declared from the beginning on.
@obliviron: Go
When you reply to a topic, check out what kind of markup type you're using (right under the reply window).
If you have WikiCreole selected then you can just click the Code-tag button right above the reply window. A new dialog appears that asks you for the type of code. Just enter Galaxy then.
If you're not using the retarded WikiCreole you can write it yourself. The tag is:
< <code galaxy> >
bla bla
< </code galaxy> >
Just without the spaces between the angled brackets.