|
Post by d354n on Mar 15, 2017 4:04:22 GMT
Hi , anyone can you help me?
if typeof(var01) == string then else if typeof(var01) == pattern then else if typeof(var01) == location then end
thanks
|
|
|
Post by Mercobots on Mar 15, 2017 10:28:32 GMT
Hi This is ugly and not the best method, but he does the work
local L =Location(200,200) local R =Region(10,20,30,40)
if pcall(function()L:getW()end) then toast("Region") else toast("Location") end
|
|
|
Post by d354n on Mar 15, 2017 13:03:58 GMT
waw thank you farrusco
|
|
|
Post by d354n on Mar 15, 2017 13:04:29 GMT
how to know if it is string?
|
|
|
Post by AnkuLua on Mar 15, 2017 13:29:13 GMT
var = "This is string" print(typeOf(var)) -- the result is string
|
|
|
Post by Mercobots on Mar 15, 2017 13:52:47 GMT
use
-- local myVar = Location(200,200) -- local myVar = "string var" -- if typeOf(myVar) == "userdata" then if pcall(function()L:getW()end) then toast("Region") else toast("Location") end elseif typeOf(myVar) == "string" then elseif typeOf(myVar) == "number" then end
but is not a good practice check the type of a "userdata", you may retive a false "true"
see this example
local myVar = Pattern("img.png")
if typeOf(myVar) == "userdata" then if pcall(function()L:getW()end) then toast("Region") else toast("Location") end end
output
Location
|
|
|
Post by d354n on Mar 15, 2017 14:22:55 GMT
thank you
|
|