• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Trigger Ignoring Simple Conditions

Status
Not open for further replies.
Level 6
Joined
Sep 11, 2006
Messages
172
Please help me see why my trigger is returning 5 for my TempInteger variable.

  • Reroll Research
    • Events
    • Conditions
    • Actions
      • -------- 1-20 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Turn Less than or equal to 20
        • Then - Actions
          • Set TempInteger[1] = (Random integer number between 1 and 5)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempInteger[TempInteger[1]] Not equal to 5
            • Then - Actions
              • Game - Display to (All players) for 15.00 seconds the text: -------------------...
              • Game - Display to (All players) for 15.00 seconds the text: (String(TempInteger[2]))
              • Game - Display to (All players) for 15.00 seconds the text: (String(TempInteger[3]))
              • Game - Display to (All players) for 15.00 seconds the text: (String(TempInteger[4]))
              • Game - Display to (All players) for 15.00 seconds the text: |||||||||||
              • Game - Display to (All players) for 15.00 seconds the text: (String(TempInteger[1]))
              • Set ResearchCodes[100] = True
            • Else - Actions
              • Wait 0.10 seconds
              • Trigger - Run (This trigger) (checking conditions)
        • Else - Actions
TempInteger [1] keeps returning 5 even though the trigger is set up to exit loop when this variable is NOT 5.

Reroll Research is actually supposed to have a few extra conditions, but I noticed something was fishy.

NONE of my conditions were preventing this trigger from exiting. I simplified it down to 1 condition. The variable cannot be 5.

The text messages are for testing purposes and have proven to me on multiple occasions that this script is not working as it should.

This script works in tandem with this trigger:

  • Set Research
    • Events
    • Conditions
    • Actions
      • -------- Turns 1-20 --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Turn Less than or equal to 20
        • Then - Actions
          • -------- Section 1 --------
          • Set ChanceModifier[15] = (Random integer number between 1 and 5)
          • -------- Load Integer --------
          • Set TempInteger[5] = 15
          • Trigger - Run Load Research <gen> (ignoring conditions)
          • -------- Reroll Checks --------
          • Set TempInteger[2] = ChanceModifier[15]
          • -------- Section 2 --------
          • Trigger - Run Reroll Research <gen> (ignoring conditions)
          • Wait until (ResearchCodes[100] Equal to True), checking every 0.10 seconds
          • Set ResearchCodes[100] = False
          • Set ChanceModifier[16] = TempInteger[1]
          • -------- Load Integer --------
          • Set TempInteger[5] = 16
          • Trigger - Run Load Research <gen> (ignoring conditions)
          • -------- Reroll Checks --------
          • Set TempInteger[3] = ChanceModifier[16]
          • -------- Section 3 --------
          • Trigger - Run Reroll Research <gen> (ignoring conditions)
          • Wait until (ResearchCodes[100] Equal to True), checking every 0.10 seconds
          • Set ResearchCodes[100] = False
          • Set ChanceModifier[17] = TempInteger[1]
          • -------- Load Integer --------
          • Set TempInteger[5] = 17
          • Trigger - Run Load Research <gen> (ignoring conditions)
          • -------- Reroll Checks --------
          • Set TempInteger[4] = ChanceModifier[17]
          • -------- Section 4 --------
          • Trigger - Run Reroll Research <gen> (ignoring conditions)
          • Wait until (ResearchCodes[100] Equal to True), checking every 0.10 seconds
          • Set ResearchCodes[100] = False
          • Set ChanceModifier[18] = TempInteger[1]
          • -------- Load Integer --------
          • Set TempInteger[5] = 18
          • Trigger - Run Load Research <gen> (ignoring conditions)
          • -------- Reset Checks!!! --------
          • Set TempInteger[2] = 0
          • Set TempInteger[3] = 0
          • Set TempInteger[4] = 0
          • Skip remaining actions
        • Else - Actions
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
TempInteger [1] keeps returning 5 even though the trigger is set up to exit loop when this variable is NOT 5.
You exit "loop" when TempInteger[TempInteger[1]] != 5, which is very different from TempInteger[1]. You also display to the player String(TempInteger[1]), which again is not the same as TempInteger[TempInteger[1]]. The only time this would ever be the same is if your GetRandomInt() function returns a 1.

Also, I don't get why you didn't just use a for loop instead of this...?
 
Level 8
Joined
Jan 28, 2016
Messages
486
TempInteger [1] keeps returning 5 even though the trigger is set up to exit loop when this variable is NOT 5.

For this part, go to File > Preferences in the Editor and under the Test Map tab, uncheck the box for Use Fixed Random Seed. Now you're random integer function should give you numbers other than five.
 
Level 6
Joined
Sep 11, 2006
Messages
172
You exit "loop" when TempInteger[TempInteger[1]] != 5, which is very different from TempInteger[1]. You also display to the player String(TempInteger[1]), which again is not the same as TempInteger[TempInteger[1]]. The only time this would ever be the same is if your GetRandomInt() function returns a 1.

Also, I don't get why you didn't just use a for loop instead of this...?

That's it! That's what my brain was refusing to see. I accidentally put the Tempinteger within itself.

Why I don't use a for integer loop? The not = 5 condition isn't the real condition; I was using it to try and find my script error, because it seemed like any condition I used was returning the same integers-usually 5-.

There are actually 3 random integer conditions that are checked against TempInteger[1] to ensure that the random number is reset until it is not = to them. It was just easier for me to put that part in its own trigger loop aside from the Set Research Trigger. I'd rather have 1 loop than one giant Trigger with multiple loops.

Wow, this is so messy.

I strongly advise you to go with another solution because this is just.. weird.


Yes, it's messy, which works with my messy brain.

----------------

Anyway, thanks Killcide, for pointing that out. A second pair of eyes can be invaluable when looking through your own scripts.
 
Status
Not open for further replies.
Top