I'm trying to subtract 1% of a variable on my map (World Market Food) from itself. The string I typed in should logically work, so why doesn't it? I tried rounding it to a whole number, truncating it, copying the interger value of the variable to a different variable (Variable - Modify WMFood 2: * 0 ||||| Variable - Modify WMFood 2: + WMFood ||||| Variable - Modify WMFood: - (Round((WMFood / 100)))), and I'm stumped...
The same argument scripted to return to me in a text message works just fine (UI - Display (Text((WMFood / 100))) for (All players) to Subtitle area). So why doesn't the same math equation work when modifying a variable?
I did try searching the forums with the search strings "Math Variable" "variable percent" "variable from variable" to no avail, so umm... Please help?
This is effectively 2 different operations. A division and a rounding. You say the result does not work but which operation is it that fails?
The code you typed which returns it in a text message is only a division not a rounding so did you make a typo?
Please find out what is causing the error. Also it may help if you tell us the variable type of each variable as maybe there is some conversion issues if you are using reals and ints interchangably.
Damn be me to it. To clearify the term round, rounds up to the closed whole number infront of the decimal so your division will always end up as 0 or 1. And no your text message return doesn't work fine because its not doing the same things and is missing things.
Variable - Modify WMFood: - (Round((WMFood / 100)))
I'm trying to subtract 1% of a variable on my map (World Market Food) from itself. The string I typed in should logically work, so why doesn't it? I tried rounding it to a whole number, truncating it, copying the interger value of the variable to a different variable (Variable - Modify WMFood 2: * 0 ||||| Variable - Modify WMFood 2: + WMFood ||||| Variable - Modify WMFood: - (Round((WMFood / 100)))), and I'm stumped...
The same argument scripted to return to me in a text message works just fine (UI - Display (Text((WMFood / 100))) for (All players) to Subtitle area). So why doesn't the same math equation work when modifying a variable?
I did try searching the forums with the search strings "Math Variable" "variable percent" "variable from variable" to no avail, so umm... Please help?
First of all I have not encountered a function called "Round" because I have never had the need for using it. So I can only guess at how it opperates.
"Variable - Modify WMFood: - (Round((WMFood / 100)))"
This is effectively 2 different operations. A division and a rounding. You say the result does not work but which operation is it that fails?
The code you typed which returns it in a text message is only a division not a rounding so did you make a typo?
Please find out what is causing the error. Also it may help if you tell us the variable type of each variable as maybe there is some conversion issues if you are using reals and ints interchangably.
@finiteturtles: Go
Damn be me to it. To clearify the term round, rounds up to the closed whole number infront of the decimal so your division will always end up as 0 or 1. And no your text message return doesn't work fine because its not doing the same things and is missing things.
Do you use integer arithmetics?
Integer Arithmetics:
99/100 is 0.
Round((99 / 100)) is 0.
Real Aritmethics:
99.0 / 100.0 is 0.99
Round((99.0 / 100.0)) is 1.0.