Honestly I just keep doing it to don't lose the habit of not doing something like:I know why you wrote it that way, it's just entirely unnecessary in the vast majority of situations and makes the trigger look annoyingly convoluted. It's a thing I see novice mapmakers do all the time and it bothers me because it removes clarity in an attempt to optimize something that doesn't need to be optimized.
Some thousands of conditions could be checked every 0.5 seconds and you'd never notice. If those conditions require other code (like creating points to check a distance, other handle operations, etc.) then it may be prudent to skip them depending on context. Trying to hyper-optimize in GUI is a fool's errand; you're fighting waaaaaay bigger fish in the form of GUI's nested condition bullshit, wrappers that literally double or triple your function-call count, etc..
Actually is like this:
For 2 possibilities:
For more than 2 posibilities:
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- (Random integer number between 1 and 2) Equal to 1
- Then - Actions
- -------- Actions 1 --------
- Else - Actions
- -------- Actions 2 --------
What you posted is a "For loop" which is for iterate some actions while an integer is increasing its value from a minimum to maximum after each iteration.
- Set VariableSet RandomNumber = (Random integer number between 1 and 3)
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- RandomNumber Equal to 1
- Then - Actions
- -------- Actions 1 --------
- Else - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- RandomNumber Equal to 2
- Then - Actions
- -------- Actions 2 --------
- Else - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- RandomNumber Equal to 3
- Then - Actions
- -------- Actions 3 --------
- Else - Actions
Thank you guysJust to note: Herly showed all of those if-blocks being nested inside each other (block 2 is in the “else” of block 1, 3 is in else of 2, etc.) but that’s not necessary. They can all be sequential after each other. Since your randomly chosen number is only one number it will only match with one condition block and the rest will be ignored.
Depending on how different the random things are, another viable solution is to put information about those actions into some array(s) on map init. Then pick a random number and do whatever you should do to YourDataArrays[YourRandomNumber].