OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: JasonO on 24 Jun 2009, 02:35:52
-
Hi guys,
I have a number, and I want a seperate value for each number. I thought about dividing by 100, dividing by 10, etc, but wont always work :(
So, the number I have is 120. I want this so I can have it like this:
_var1 = 1;
_var2 = 2;
_var3 = 0;
For example. The number is the speed, and wont be used for anything other than land vehicle so 3 digits is enough
I'm really trying to learn SQF, and I was wondering if this is possible.
Thanks a lot (again!) for your help :)
Edit: I really have to stop posting here, THEN find a solution lol.
_num1 = _speedVar % 10;
_speedVar = _speedVar / 10;
_speedVar = _speedVar - (_speedVar mod 1);
_num2 = _speedVar % 10;
_speedVar = _speedVar / 10;
_speedVar = _speedVar - (_speedVar mod 1);
_num3 = _speedVar % 10;
_num1, _num2 and _num3 all hold the seperate values.
-
_speedVar = _speedVar - (_speedVar mod 1);
// Can be written as:
_speedVar = floor _speedVar;
floor rounds a number down and ceil rounds a number up. Just shorter and more clear what you are doing.