i have an array of triggers that i want to be to have something happen at that index of the array but if i do
Code Snippet
Plaintext
trig [i] waittill("trigger");
the code stops at the first iteration until the first trigger has been triggered and so on. how would i go about iterating through each trigger and having it wait until it it has been triggered before calling the next line of code?
sorry if that doesnt make sense, i was trying to think of the best way to word it.
Thread each trigger another function where that new function will waittill the trigger of each trigger separately. "Threading" makings the game not wait for the function. Then if u want something to occur that would happen when any one of the triggers occur, you can have a waittill function in the original function that waits for a notify from any of the triggers (this notify can also end the other functions as well).
threadedFunction() { level endon("custom_trigger"); // optional if you want these functions to end if one trigger is triggered self waittill("trigger"); level notify("custom_trigger"); }
Last Edit: February 03, 2015, 04:41:23 pm by JBird632
If you want scripts / features made for you, then contact me by PM or email / skype etc it will cost you tho so if you have no intention of reciprocating don't even waste my time
trigger_init() { trig = getEntArray( "trigger_targetname", "targetname" ); // Get array of the triggers using this targetname - This will allow for more than one trigger with the same targetname array_thread( trig,::trig_watch ); // Thread the second function on each of those triggers }
trig_watch() { while (1) // Need a loop to keep checking { player = undefined; // Undeclare this just in case self waittill( "trigger", player ); // assigns whoever is found touching this trigger to the variable "player"
iPrintLn( "Trigger touched by" + player ); // Print text to the screen to say who touched the trigger
wait 1; // Need to have a wait to prevent engine crashes, something to do with using loops I believe } }
trigger_init() { trig = getEntArray( "trigger_targetname", "targetname" ); // Get array of the triggers using this targetname - This will allow for more than one trigger with the same targetname array_thread( trig,::trig_watch ); // Thread the second function on each of those triggers }
trig_watch() { while (1) // Need a loop to keep checking { player = undefined; // Undeclare this just in case self waittill( "trigger", player ); // assigns whoever is found touching this trigger to the variable "player"
iPrintLn( "Trigger touched by" + player ); // Print text to the screen to say who touched the trigger
wait 1; // Need to have a wait to prevent engine crashes, something to do with using loops I believe } }
because of the waittill you dont need the wait 1;........ just sayin