generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Is there a way of finding the first number of a value?

Previous Thread :: Next Thread 
MARIOSTAR6464 is not online. MARIOSTAR6464
Joined: 21 Jul 2008
Total Posts: 13674
20 Jul 2011 11:52 AM
Example:

Value = 79

print([first number])
Report Abuse
comiconor is not online. comiconor
Joined: 26 May 2009
Total Posts: 16893
20 Jul 2011 11:53 AM
[ Content Deleted ]
Report Abuse
MARIOSTAR6464 is not online. MARIOSTAR6464
Joined: 21 Jul 2008
Total Posts: 13674
20 Jul 2011 11:56 AM
Well that doesn't work :x
Report Abuse
me2kool2talk2u is not online. me2kool2talk2u
Joined: 19 Feb 2007
Total Posts: 2914
20 Jul 2011 11:57 AM
v = Value:toString()
print(v.subString(0,1))

Report Abuse
comiconor is not online. comiconor
Joined: 26 May 2009
Total Posts: 16893
20 Jul 2011 11:57 AM
[ Content Deleted ]
Report Abuse
comiconor is not online. comiconor
Joined: 26 May 2009
Total Posts: 16893
20 Jul 2011 11:57 AM
[ Content Deleted ]
Report Abuse
MARIOSTAR6464 is not online. MARIOSTAR6464
Joined: 21 Jul 2008
Total Posts: 13674
20 Jul 2011 11:59 AM
me2kool2talk2u, I notiec that, but it still doesn't work.
Report Abuse
comiconor is not online. comiconor
Joined: 26 May 2009
Total Posts: 16893
20 Jul 2011 12:02 PM
[ Content Deleted ]
Report Abuse
MARIOSTAR6464 is not online. MARIOSTAR6464
Joined: 21 Jul 2008
Total Posts: 13674
20 Jul 2011 12:04 PM
I don't understand, Value is nil.
Report Abuse
MARIOSTAR6464 is not online. MARIOSTAR6464
Joined: 21 Jul 2008
Total Posts: 13674
20 Jul 2011 12:10 PM
Ehh?
Report Abuse
chaoticregandpledge is not online. chaoticregandpledge
Joined: 04 Dec 2009
Total Posts: 2894
20 Jul 2011 12:12 PM
value = 79
strval = tostring(value)
firststrnum = string.sub(strval,1,1)
firstnum = tonumber(firststrnum)
Report Abuse
BJCarpenter is not online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image