Hi, im running a large sequence of triggers that all work together to accomplish one task. I have them split up into multiple triggers for neatness and organization. This long sequence of events and triggers occurs when a player presses a button. I attain certain values, who pressed the button and what button was pressed and i need ot pass these two values to each succesive trigger. The only way i can think of really doing that is by storing them in global variables, is there any way to pass by value the variables to the next trigger instead of using globals. I had noticed a problem in another set of buttons i made with this similar design that if different buttons where clicked fast enough global values would be reassigned before certain triggers (or other threads more specifically) finished running corrupting their values and producing unwanted results.
So ya what can i do about this? And is running multiple threads at the same time really a problem in terms of one thread surpassing another one and reassigning the global values, or is this (and i hope it is) not possible. I would assume threads would end in the order they where started but i know that may not be the case, and i can delay triggers from starting that are in teh same thread, but i cant seem to manage multiple threads, i cant seem to access a relationship between them to say, wait till thread one completes to start thread two.
No and yes. There is no built in method for passing sets/structs of variables. You can however, if all your triggers use the same variables, change all your triggers to actions and pass the individual variables as parameters. Alternatively I use actions with one string parameter, convert the variables data into strings, combine the strings into one string divided by ",", and pass to the actions string variable. Then I split up the information between the "," into its variables. I use this method because my variable data sets are of unknown sizes and I needed something to handle it.
As for multiple threads, that does not really exist. The game runs all triggers/thread one at a time in turn. One problem is a trigger may be stopping/waiting and while triggers are using waits other triggers can run in the meantime.
Best thing you can do is like zandose said: make the values parameters.
One way to use multi-treading and still keep the data is by making local variables in the action definition (or trigger, or etc....) and setting them = to each parameter. This way even if the value changes it will only care about the local variable's value, and not any global value that might be attached to the value you need to use.
I had the very same problem and if you want to keep track of these values this is the best you can do without assigning large array values to global variables (or using the data table).
I am largely inactive, but I am still around. Feel free to poke me if you need some help, just be warned that I only really come back if I need help and/or if I'm posting a new map/library.
Yes i highly suggest looking into learning action and function definitions and they are not very far from triggers to learn but allow you to do multitudes more. Most advanced maps will have as little trigger event as possible; some of my own system use many many thread but only use like 2 triggers for an entire city wide interestion or even just 1 trigger for a completely automated tps ai shooter.
Thanks for the reply, i assume actions are subroutines basically? Ive wanted to use subroutines but all i thought i had was triggers.
I understand and don't understand what you mean by subroutines. It depends on how its being used i guess. Anyways you have two options with event/function/action triggers.
One being is that you select no special options and the sequence is like this: Main trigger runs a Action Trigger, Action trigger runs, When Action Trigger is done go back to Main Trigger.
Two being is that you select the special option for "Create Thread" and will cause the Action Trigger to run independently from the Main Trigger. The Sequence goes like this: Main trigger runs a Action Trigger, Main Trigger continues doing its thing and at the same time the Action Trigger will do its own thing too.
You can store values in the data table instead of global variables (it's more dynamic). Also, you can have triggers turn eachother off/on if they're clashing the way it sounds. Or you could use parameters like they've said above.
Hi, im running a large sequence of triggers that all work together to accomplish one task. I have them split up into multiple triggers for neatness and organization. This long sequence of events and triggers occurs when a player presses a button. I attain certain values, who pressed the button and what button was pressed and i need ot pass these two values to each succesive trigger. The only way i can think of really doing that is by storing them in global variables, is there any way to pass by value the variables to the next trigger instead of using globals. I had noticed a problem in another set of buttons i made with this similar design that if different buttons where clicked fast enough global values would be reassigned before certain triggers (or other threads more specifically) finished running corrupting their values and producing unwanted results.
So ya what can i do about this? And is running multiple threads at the same time really a problem in terms of one thread surpassing another one and reassigning the global values, or is this (and i hope it is) not possible. I would assume threads would end in the order they where started but i know that may not be the case, and i can delay triggers from starting that are in teh same thread, but i cant seem to manage multiple threads, i cant seem to access a relationship between them to say, wait till thread one completes to start thread two.
Thanks.
No and yes. There is no built in method for passing sets/structs of variables. You can however, if all your triggers use the same variables, change all your triggers to actions and pass the individual variables as parameters. Alternatively I use actions with one string parameter, convert the variables data into strings, combine the strings into one string divided by ",", and pass to the actions string variable. Then I split up the information between the "," into its variables. I use this method because my variable data sets are of unknown sizes and I needed something to handle it.
As for multiple threads, that does not really exist. The game runs all triggers/thread one at a time in turn. One problem is a trigger may be stopping/waiting and while triggers are using waits other triggers can run in the meantime.
@zandose: Go
Thanks for the reply, i assume actions are subroutines basically? Ive wanted to use subroutines but all i thought i had was triggers.
@lemmy734: Go
Best thing you can do is like zandose said: make the values parameters.
One way to use multi-treading and still keep the data is by making local variables in the action definition (or trigger, or etc....) and setting them = to each parameter. This way even if the value changes it will only care about the local variable's value, and not any global value that might be attached to the value you need to use.
I had the very same problem and if you want to keep track of these values this is the best you can do without assigning large array values to global variables (or using the data table).
@lemmy734: Go
Yes i highly suggest looking into learning action and function definitions and they are not very far from triggers to learn but allow you to do multitudes more. Most advanced maps will have as little trigger event as possible; some of my own system use many many thread but only use like 2 triggers for an entire city wide interestion or even just 1 trigger for a completely automated tps ai shooter.
I understand and don't understand what you mean by subroutines. It depends on how its being used i guess. Anyways you have two options with event/function/action triggers.
One being is that you select no special options and the sequence is like this: Main trigger runs a Action Trigger, Action trigger runs, When Action Trigger is done go back to Main Trigger.
Two being is that you select the special option for "Create Thread" and will cause the Action Trigger to run independently from the Main Trigger. The Sequence goes like this: Main trigger runs a Action Trigger, Main Trigger continues doing its thing and at the same time the Action Trigger will do its own thing too.
You can store values in the data table instead of global variables (it's more dynamic). Also, you can have triggers turn eachother off/on if they're clashing the way it sounds. Or you could use parameters like they've said above.
Ya im using the action definitions as subroutines and its working great, thanks everyone.