How to extract the first decimal number from a timer?
troynall
Member Posts: 15
what would be the easiest way to just EXTRACT the TENTHs place value from the timer ?
Example,
1.08 = 0
1.14 = 1
1.26 = 2
1.95 = 9
Example,
1.08 = 0
1.14 = 1
1.26 = 2
1.95 = 9
Comments
1.26*10 = 12.6
floor(12.6) = 12
12/10 = 1.2 [save this into an attribute - let's call it "X"]
floor(1.2) = 1 [save this into another attribute - let's call it "Y"]
X-Y= the 'tenths place value'
Hi @troynall
And here it is, slightly differently (although very similar to @Socks version): a real attribute to hold your number called TempNum, and an integer attribute, let's call it FirstDec
So for the following example, FirstDec is set to 0 and TempNum to 1.95 --or whatever the current number is.
--------------
Change Attribute FirstDec to TempNum
Change Attribute TempNum to (TempNum-FirstDec)*10
Change Attribute FirstDec to floor(TempNum)
Display Text FirstDec
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Yep ! That's a lot neater ! >-
@gyroscope
mod(floor(number*10),10)
Example:
mod(floor(1.26*10),10) = 2
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Thanks guys.
Eventually, those features will make their way into the stable build available to everyone.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User