It took me a moment to see the logic behind your trigger, but I figured out why it doesn't work. I mean, I know what's happening, but the logic for that is something that I will summon
@Uncle or
@Dr Super Good or anyone smarter then me for, because I honestly have no damn clue how or why it's happening. And I'm curious
---
Anyway, before we proceed - let me introduce you to
the most basic concept of debugging (i.e. looking for errors) your own code. All you need is this lovely action:
-
Game - Display to (All players) the text: <Your String> // for example: value of a real/integer variable converted to a string
The way basic debugging works is that you:
1. Select the chunk of code you want to debug.
2. Make sure that you can run that chunk of code quickly and easily (for instance by copying it to another trigger that fires periodically or when the user presses a key).
3. Use the action above to print out (i.e. display on screen) the desired info.
In the case of your trigger, you might want to print out the values of Marksman and Marksman 2 see a) if the trigger even gets through the initial set of conditions and b) what happens with these values and how they are converted between each other, because that's what's going to affect your second condition.
To summarize - using text messages allows you to track the values of your variables, detect where the execution of the trigger gets stuck (e.g. which conditions aren't being passed successfully) or what actions aren't working as intended. And probably more.
Anywho, that way you can easily identify which part of your code is causing issues and work on solutions.
---
So, my first instinct was that your issue occured due to something happening with the way reals are converted to variables in the WE, so I've made this little debug trigger:
-
Set RealVariable = (RealVariable + 0.10)
-
Set IntegerVariable = (Integer(RealVariable))
-
Game - Display to (All players) the text: ((Real = + (String(RealVariable))) + (; Integer = + (String(IntegerVariable))))
P.S. Don't worry about the "string math" I've used - it's just to make the results look pretty. A simpler version of that trigger using two text message actions, where the first one would be (String(RealVariable)) and the second (String(IntegerVariable)) would work just as well.
I've expected the numbers to get truncated, i.e. the decimal part of the real variable to be cut, for example 1.2 -> 1; 1.7 -> 1; 2.0 -> 2, but... this is what I got:
Here's where I ask the guru's how is this possible? (because I honestly have no idea)
---
Anyway, that's the reason why your trigger didn't work - your logic was obviously to reach a point where when the real variable reaches for example 1.0 then it would get converted to a 1 integer value and thus the condition would be met. Unfortunately, that only happened when the real variable had the value of for instance 1.1 and thus it wasn't equal to 1 when you thought it was going to be.
How to solve this? Well, you can simply counter this behavior by using math inside the condition to have things go your way:
-
Marksman Equal to ((Real(Marksman2)) + 0.1)
OR
-
(Marksman - 0.1) Equal to (Real(Marksman2))
But my question to you is... why? You chose a fairly awkward way of doing this trigger - a much simpler option would be to use a single integer variable and do this:
-
Set IntegerVariable = (IntegerVariable + 1)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-

If - Conditions
-


IntegerVariable Equal to 10
-

Then - Actions
-


Set IntegerVariable = 0
-


//Your other actions//
-

Else - Actions
That's just as effective, but simpler, cleaner and a tiny bit more efficient (I think)
