Questions about lua - Gideros Forum

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

#### Top Posters

Member
edited August 2019
Sorry for the baby question:
How to check that the table has a function? So far I have found a way out:if #a[1]==0 , Is it possible to do it differently?
 ``` function test() print ("test1") end   a={{p=test},234523}   for i=1,2 do if #a[i]==0 then a[i].p() else print(a[i]) end   end```
my games:
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!

• Member
solved the problem:
 ``` function test() print ("test1") end   a={{test},0}   if type(a[1])=="table" then a[1][1]()   end```

Likes: Apollo14

my games:
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
+1 -1 (+1 / -0 ) Share on Facebook
• Maintainer
why not just test for a function ?
 ```function test() print ("test1") end   a={test,0}   if type(a[1])=="function" then a[1]() end```

Likes: oleg

+1 -1 (+1 / -0 ) Share on Facebook
• Member
edited August 2019
hgy29 said:

why not just test for a function ?

Because I need to pass parameters to the function
 ``` function test(param) print ("test1",param) end   a={{test,23},0}   if type(a[1])=="table" then a[1][1](a[1][2])   end```
my games: