Quick question about tables and functions

I was looking at a tutorial at mobileTuts and in a few of the samples they declared the functions as a table like this

local startTheGame = {}  
  
--Then the actual function:  
  
function startTheGame ()  
end  

Are functions actually tables? I’ve read as much about Lua as I can and try to soak everything in but did I miss that somewhere?

Thanks guys
Cin. :wink: [import]uid: 65840 topic_id: 22405 reply_id: 322405[/import]

There not tables no. However you can have a class of functions based on a table :

For instance :

  
local displays = {}  
  
function displays.init()  
end  
  
function displays.show()  
end  
  
--and so on  
  

then you are delving into the word of object orientated programming.

You can then do powerful things like this

[code]
local displays = {}

function displays:init()
print(“Hello”)
end

function displays:show()
self:init() --Will execute the displays init function
end

displays:show() – Will print hello [import]uid: 84637 topic_id: 22405 reply_id: 89307[/import]

From the LUA 5.0 reference:

There are eight basic types in Lua: nil, boolean, number, string, function, userdata, thread, and table.
Tables, functions, and userdata values are objects: variables do not actually contain these values, only references to them.

local startTheGame = {}

is a forward reference. A placeholder to stop code that occurs before the actual function from complaining in the compiler.
This line creates a variable called startTheGame and points it at a table

I feel sure that you could omit the = {} and it would still work.
Because the line
function startTheGame ()

then (I think) resets the pointer to point to the function.

… happy to hear from other opinions.

[import]uid: 108660 topic_id: 22405 reply_id: 89308[/import]

Thanks,
here’s the tut that got me confused.
http://mobile.tutsplus.com/tutorials/corona/corona-sdk-create-a-rapid-roll-like-game-interaction/

I’ve read about the new “classes” way of doing things instead of the module way.

I just find it a bit confusing as a beginner and everyone does everything different and everyone say this and that is the best way or is best for memory etc and all the IDE, editors, physics editor, level helpers/designers etc etc.

Why doesn’t Corona have their own development IDE with leveldesigners, physics editor, spritesheet tool?? Sorry for the side track…

Thanks for the replies.
C. [import]uid: 65840 topic_id: 22405 reply_id: 89311[/import]

We are working on such things Cindy, it’s just all a matter of A) time and B) feature priority.

[import]uid: 84637 topic_id: 22405 reply_id: 89312[/import]

Thanks danny. [import]uid: 65840 topic_id: 22405 reply_id: 89341[/import]