ID:158512
 
Okay, my question is how would I determine the first, second, and third didgit number using code. Like if I needed to check if the second number of src.velocity was to determine the icon state of something.

I suppose if I were a better coder I would know how to use len to figure this out but unfortunetly I'm not so, how would I go about doing this?

NOTE: Yeah I used search, couldn't find anything relevant though.
Turn it into a string and use copytext(), findtext(), or text2ascii().
In response to Popisfizzy
Any reason why
mob
verb
testverb()
var/Q = num2text(src.velocity)
src<<"<b>[Q]"

returns a number?
SadoSoldier wrote:
Okay, my question is how would I determine the first, second, and third didgit number using code. Like if I needed to check if the second number of src.velocity was to determine the icon state of something.

First digit is round(n/100). Second digit is round((n%100)/10). Third digit is round(n%10).
In response to Garthor
Ah thanks alot!
In response to SadoSoldier
Note that that does assume it's only three digits. If it can be more, the first one would be round((n%1000)/100). But that wouldn't be the "first" digit.
In response to Popisfizzy
That's a good approach as long as the number will not turn into something like "1.2e1" or "12.345".
In response to Jemai1
In that case, math on it will not be accurate anyways.