Right now as I have it setup I have a specific real number variable that I do not want to drop below 0 and go above 100. There are certain conditions in game that will allow the variable to either decrease or increase. As I have it setup right now:
If Realvariable>=100
Then Set Realvariable==100
If Realvariable<=0
Then Set Realvariable==0
This worked until I did some testing and realized that for my triggers the Realvariable absolutely CANNOT go below 0 or above 100 (in some situations it would go up to 101 and 1 second later drop down to 100 with my current setup).
I need a setup that will make it so that it can never surpass 100. There must be a way besides my current crappy setup. Is there a way to set boundries when creating the variable?
FYI: I'm not very educated when it comes to variables or editing their characteristics so please describe it to me like you would to someone who had no idea what you were talking about. It will help me out tremendously. Thank you so much! You guys are so awesome keep up the good work!
They're just for example, they have no meaning. He's just showing you the idea of what you have to do, not exactly what you need to do to your variable.
To address the problem: it doesn't matter if you do the check before or after you set your variable to a value, but make sure you do it immediately before/after. Ex:
// Check after assigning value to variableSetRealVariable=ValueIfRealVariable<0ThenSetRealVariable=0ElseIfRealVariable>100ThenSetRealVariable=100EndIf// -or -// Check before assigning value to the variableIfValue<0ThenSetRealVariable=0ElseIfValue>100ThenSetRealVariable=100ElseSetRealVariable=ValueEndIf
I was able to get it to trigger the boolean everytime with this setup. However, the boolean activates between 1-3 times each second and I'm not sure why. Let me show you what I have got setup:
For reference "Team1PointA" is the Real# variable I'm trying to keep within 0-100 boundaries.
"Team1Msg1" is the boolean variable that is initially false
UnitGroup-Pickeachunitin((Unittypeof(Triggeringunit))unitsinRegionAownedbyplayercmatchingExcluded:Light,Armored,Biological,Robotic,Mechanical,Massive,Structure,Worker,Missile,Buried,Cloaked,UnderConstruction,Dead,Hidden,Hallucination,Detector,withanddo(Actions)ActionsVariable-ModifyTeam1pointA:+2.0General-If(Conditions)thendo(Actions)elsedo(Actions)IfTeam1pointA<100.0ThenVariable-SetTeam1MSG1=trueElseGeneral-If(Conditions)thendo(Actions)elsedo(Actions)If(Team1pointA+4.0)>=100.0ThenVariable-SetTeam1pointA=100.0ElseGeneral-If(Conditions)thendo(Actions)elsedo(Actions)IfAndConditionsTeam1MSG1==trueTeam1pointA==100.0ThenUI-Display"Team 1 has captured TIER 3!"forTeam2toSubtitleareaUI-Display"Your team has captured TIER 1!"forTeam1toSubtitleareaPing-PingtheminimapatPointAfor(Allplayers)over2.0seconds,usingthecolor(100%,0%,0%)
The reason I know the boolean is activating 1-3 times is because when i test the map I get between 1-3 text messages on screen and 1-3 pings all instantaniously. I just want to have 1 ping and 1 text come through. Please help! Thank you
Right now as I have it setup I have a specific real number variable that I do not want to drop below 0 and go above 100. There are certain conditions in game that will allow the variable to either decrease or increase. As I have it setup right now:
If Realvariable>=100 Then Set Realvariable==100
If Realvariable<=0 Then Set Realvariable==0
This worked until I did some testing and realized that for my triggers the Realvariable absolutely CANNOT go below 0 or above 100 (in some situations it would go up to 101 and 1 second later drop down to 100 with my current setup).
I need a setup that will make it so that it can never surpass 100. There must be a way besides my current crappy setup. Is there a way to set boundries when creating the variable?
FYI: I'm not very educated when it comes to variables or editing their characteristics so please describe it to me like you would to someone who had no idea what you were talking about. It will help me out tremendously. Thank you so much! You guys are so awesome keep up the good work!
Just add the condition BEFORE increasing/decreasing the variable and not after.
What you're doing:
- Set MyVar = MyVar + 5
- If MyVar >= 100 Then Set...
- If MyVar <= 0 Then...
What you got to do do:
- If MyVar+5 >= 100 Then Set MyVar == 100 Else Set MyVar == MyVar + 5
or if you decrease it:
- If MyVar-5 <= 0 Then Set MyVar == 0 Else Set MyVar == MyVar - 5
May I ask why you do var+5? what's the +5 and -5 for exactly?
@Etravex: Go
They're just for example, they have no meaning. He's just showing you the idea of what you have to do, not exactly what you need to do to your variable.
To address the problem: it doesn't matter if you do the check before or after you set your variable to a value, but make sure you do it immediately before/after. Ex:
Either one works.
@ubermikeleet: Go
I was able to get it to trigger the boolean everytime with this setup. However, the boolean activates between 1-3 times each second and I'm not sure why. Let me show you what I have got setup:
For reference "Team1PointA" is the Real# variable I'm trying to keep within 0-100 boundaries. "Team1Msg1" is the boolean variable that is initially false
The reason I know the boolean is activating 1-3 times is because when i test the map I get between 1-3 text messages on screen and 1-3 pings all instantaniously. I just want to have 1 ping and 1 text come through. Please help! Thank you
@Etravex: Go
After you display the message, set Team1MSG1 to false.
@ubermikeleet: Go
Ok I will give it a shot.
Works! Thank you so much