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: Print whether or not number is an integer?

Previous Thread :: Next Thread 
ProjectMrHatbot is not online. ProjectMrHatbot
Joined: 24 Sep 2013
Total Posts: 16712
02 Feb 2014 01:10 AM
How do I print if a number is an integer or not?
Report Abuse
jonesj627 is not online. jonesj627
Joined: 06 Oct 2010
Total Posts: 1496
02 Feb 2014 01:14 AM
you use regrex, for example


plr = game.Players.LocalPlayer
plr.Chatted:connect(function(msg)
if msg:sub(1,5) == ":num " then
a =msg:match('%d+') -- this is regrex
if a == nil then
print("what player said was not a number")
else
print(a)
end
end
end)
if the player chats :num blahblahblah , a would return nil and it would print what player said was not a number, but if he said :num 383, it would print 383

look up regrex on lualearners or roblox wiki

Report Abuse
jd678 is not online. jd678
Joined: 18 Apr 2008
Total Posts: 11529
02 Feb 2014 01:40 AM
He wanted to know if a number was an Integer or not, not if text was a number or not :p
Report Abuse
jonesj627 is not online. jonesj627
Joined: 06 Oct 2010
Total Posts: 1496
02 Feb 2014 01:46 AM
i know man, i got confused
Report Abuse
jonesj627 is not online. jonesj627
Joined: 06 Oct 2010
Total Posts: 1496
02 Feb 2014 01:47 AM
well actually, you got use regrex and you could you the puncuation mark for the point in a number like 10.0844
Report Abuse
jd678 is not online. jd678
Joined: 18 Apr 2008
Total Posts: 11529
02 Feb 2014 01:50 AM
Yeah, you'd still have to check if it is a number, or perhabs you could just check to see if it is not a string
Report Abuse
galisprayo is not online. galisprayo
Joined: 20 Jan 2008
Total Posts: 3271
02 Feb 2014 01:56 AM
function isInt(number)
return number == math.floor(number)
end

Simple as that, enjoy.
Report Abuse
ProjectMrHatbot is not online. ProjectMrHatbot
Joined: 24 Sep 2013
Total Posts: 16712
02 Feb 2014 01:58 AM
Thanks!
Report Abuse
jd678 is not online. jd678
Joined: 18 Apr 2008
Total Posts: 11529
02 Feb 2014 02:17 AM
Derp, that is much easier lol. I always seem to try and over complicate things.
Report Abuse
galisprayo is not online. galisprayo
Joined: 20 Jan 2008
Total Posts: 3271
02 Feb 2014 02:25 AM
Don't worry, we all do it :)
Report Abuse
lukybot001 is not online. lukybot001
Joined: 16 Feb 2013
Total Posts: 41
11 Feb 2014 08:16 PM
OMG THX! it will make it way easier! to do reduce fractions!
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