|
| 20 Jul 2011 11:52 AM |
Example:
Value = 79
print([first number]) |
|
|
| Report Abuse |
|
|
comiconor
|
  |
| Joined: 26 May 2009 |
| Total Posts: 16893 |
|
| |
|
| |
|
|
| 20 Jul 2011 11:57 AM |
v = Value:toString() print(v.subString(0,1))
|
|
|
| Report Abuse |
|
|
comiconor
|
  |
| Joined: 26 May 2009 |
| Total Posts: 16893 |
|
| |
|
comiconor
|
  |
| Joined: 26 May 2009 |
| Total Posts: 16893 |
|
| |
|
|
| 20 Jul 2011 11:59 AM |
| me2kool2talk2u, I notiec that, but it still doesn't work. |
|
|
| Report Abuse |
|
|
comiconor
|
  |
| Joined: 26 May 2009 |
| Total Posts: 16893 |
|
| |
|
|
| 20 Jul 2011 12:04 PM |
| I don't understand, Value is nil. |
|
|
| Report Abuse |
|
|
| |
|
|
| 20 Jul 2011 12:12 PM |
value = 79 strval = tostring(value) firststrnum = string.sub(strval,1,1) firstnum = tonumber(firststrnum) |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2011 12:21 PM |
I usually try to use math.
I always found that to be difficult in Roblox Lua, 'cause I can never find an INT() function - (Integer) ie:
INT(7.9) = 7
But I have done it with the Round-up & Round-down functions (floor() & celi()), which gives an integer.
so ya go:
a = 79
temp = a/10 -- 7.9
now it gets tricky. I always forget which is "Round-up" or "Round-down", but somehow, strip the decimal .9 (you might want to add .5, before you do, depending on your application)
temp = floor(temp) -- WARNING; not real code.
GL, Brian
|
|
|
| Report Abuse |
|
|