I’m working on making a timer that counts to the .1 second. I am doing it by converting frames (counted by an always trigger) to .1 second increments, then converting that to whole number seconds and .1 seconds. The problem is I have to have the whole number seconds and .1 seconds as two separate Labels, so I have to adjust the position of the .1 seconds label as the whole number label adds more digits.
My question is: How do I count the number of digits in a number? For example, 8 has one digit, 147 has three digits, and so on.
Well, I ended up just making filters for every place. So, it checks if the number is >= 0, >= 10, >= 100, etc. I would like a solution where it doesn’t error out after a certain point, but I suppose nobody will be playing a level for more than a couple of days at very very most anyway
I tried using a timer at .1 before, and it didn’t seem to work very well. Converting frames to seconds works anyway, and it accounts for game lag, which I like.
This seems like what I want. The documentation page for the expression block only has pretty basic info, is there a list somewhere of all the functions we can use?
@johnpost You can use Haxe (a programming language) in the expression block. It’s probably too advanced to be explained in the documentation because most people won’t even understand it since they don’t have any programming experience. You can find a lot about Haxe in the website. Even about the code I wrote above (Std.string(A).length):
So there’s a lot you can do with an expression, but it’s limited to returning a single integer since that’s the only thing an expression allows as an output.
It might change in the future because grazer mentioned like a month ago that he’s going to work on allowing different data types like text, lists and floating points. We’re most likely going to get new behavior blocks for that to make it less complicated. But that’s all unimportant for now. You can keep an eye on it.