|
| 02 Feb 2014 01:10 AM |
| How do I print if a number is an integer or not? |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| Joined: 06 Oct 2010 |
| Total Posts: 1496 |
|
|
| 02 Feb 2014 01:46 AM |
| i know man, i got confused |
|
|
| Report Abuse |
|
|
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
|
  |
| 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 |
|
|
|
| 02 Feb 2014 01:56 AM |
function isInt(number) return number == math.floor(number) end
Simple as that, enjoy. |
|
|
| Report Abuse |
|
|
| |
|
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 |
|
|
|
| 02 Feb 2014 02:25 AM |
| Don't worry, we all do it :) |
|
|
| Report Abuse |
|
|
|
| 11 Feb 2014 08:16 PM |
| OMG THX! it will make it way easier! to do reduce fractions! |
|
|
| Report Abuse |
|
|