| |
|
|
| 18 May 2012 02:23 PM |
To detect its type you can use this
type()
example
print(type("LOL")) Output: string |
|
|
| Report Abuse |
|
|
|
| 18 May 2012 02:23 PM |
local whatever = "Test"
if (type(whatever) == "string") then -- String elseif (type(whatever == "number") then -- Number end
I believe there is: string, number, boolean, function, table, userdata. Maybe more |
|
|
| Report Abuse |
|
|
|
| 18 May 2012 02:24 PM |
| How to use it in a If statement? |
|
|
| Report Abuse |
|
|
|
| 18 May 2012 02:24 PM |
Lol, Thanks clone. But not enough info. But thanks crazy ;P |
|
|
| Report Abuse |
|
|
| |
|
juriaan
|
  |
| Joined: 25 Nov 2008 |
| Total Posts: 939 |
|
|
| 18 May 2012 02:26 PM |
@Crazyman32
The list of Type :
"number", "string", "boolean", "table", "function", "thread", and "userdata".
|
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 18 May 2012 02:30 PM |
| Well thanks all, It really helps me with my plugin =D |
|
|
| Report Abuse |
|
|
|
| 18 May 2012 02:39 PM |
Problem, Im using it for a text box on my plugin.
But. Even if you input a number to it Roblox calls it as a string. But if I use to number and its a string it won't work, I don't think.
Any ideas? |
|
|
| Report Abuse |
|
|
|
| 18 May 2012 02:39 PM |
local input = tonumber(TEXTBOX.Text) if (input) then -- It's a number else -- Not a number end |
|
|
| Report Abuse |
|
|
rayoma
|
  |
| Joined: 13 Nov 2009 |
| Total Posts: 1911 |
|
|
| 18 May 2012 03:21 PM |
@clone That would always give you a string in this situation. How I would always do this is simple,
print(not not tonumber(string));--will be true if it's a number, false if it isn't |
|
|
| Report Abuse |
|
|
|
| 18 May 2012 03:26 PM |
@rayoma - No, that would be the same as:
print(tonumber(string))
You said "not" twice, so you inforced a double negative - print the opposite of the opposite of tonumber(string), or print tonunumer(string). Just like saying, "I don't not want to go the doctor's" is like saying "I want to go to the doctor's". |
|
|
| Report Abuse |
|
|
| |
|
rayoma
|
  |
| Joined: 13 Nov 2009 |
| Total Posts: 1911 |
|
|
| 18 May 2012 03:30 PM |
@electric Using double nots is the most common way to change something into a boolean. Your script would either give a number or nil, mine would give true or false. There is a difference. |
|
|
| Report Abuse |
|
|
|
| 18 May 2012 03:33 PM |
| @rayoma - If you read my post thoroughly, you'd notice I wasn't correcting you, simply making a comment. |
|
|
| Report Abuse |
|
|
rayoma
|
  |
| Joined: 13 Nov 2009 |
| Total Posts: 1911 |
|
|
| 18 May 2012 03:34 PM |
@electric - If you read my post thoroughly, you'd notice I wasn't correcting you, simply making a comment.
|
|
|
| Report Abuse |
|
|
|
| 18 May 2012 03:58 PM |
> Your script would either give a number or nil, mine would give true or false. There is a difference.
wutnao? |
|
|
| Report Abuse |
|
|
rayoma
|
  |
| Joined: 13 Nov 2009 |
| Total Posts: 1911 |
|
|
| 18 May 2012 04:03 PM |
> No, that would be the same as
------------- > Just like saying, "I don't not want to go the doctor's" is like saying "I want to go to the doctor's".
------------- wutnao? |
|
|
| Report Abuse |
|
|
|
| 18 May 2012 04:05 PM |
| Heh, true. If I didn't say "no", it wouldn't be a correction though. :P |
|
|
| Report Abuse |
|
|