Calling functions? Inheritance?

Hey there,

I’m very excited with Corona!
Now i’m trying to port some knowledge that I have from as3.

So, problem one:
I have two lua files… The main one (obviously) and one called “screen”.
Now… on the screen one I just have:
[lua]
function start()
print(“HEY HEY”)
end[/lua]

On the main one I have:
[lua]local hello = require (“screen”)

function startFnc()
hello:start()
end

startFnc()[/lua]

So … what’s my problem here? Why can’t I call the start inside the “hello” / “screen”? It’s giving me errors…

Now inheritance. This is one of the best things that happened to AS3. Let’s say for example a level system. You have a main level where you have functions that are common to all the levels and then you have something like level1.lua, level2.lua… These level1, level2 need on inherit the main level! So we won’t need to always copy the common functions to the new file! Inherit plus override and stuff it’s awesome!
So… how can I do this? [import]uid: 35508 topic_id: 6296 reply_id: 306296[/import]

hello:start() is for calling methods on an object/table. Since “hello” isn’t a table that doesn’t work. Try hello.start()

There are a lot of different ways people do OOP in Lua, here’s my approach:
http://developer.anscamobile.com/code/object-oriented-sample-game-framework [import]uid: 12108 topic_id: 6296 reply_id: 21720[/import]

Tried hello.start() and it gave me this error:

Runtime error  
 .../basic-corona/main.lua:4: attempt to index upvalue 'hello' (a boolean value)  
stack traceback:  
 [C]: ?  
 .../basic-corona/main.lua:4: in function 'startFnc'  
 .../basic-corona/main.lua:7: in main chunk  
Runtime error: .../basic-corona/main.lua:4: attempt to index upvalue 'hello' (a boolean value)  
stack traceback:  
 [C]: ?  
 .../basic-corona/main.lua:4: in function 'startFnc'  
 .../basic-corona/main.lua:7: in main chunk  

About the link, you already gave me that link, I already read it. It seems really interesting but… I can’t understand much of it… Still don’t know how to move around and how to apply it. [import]uid: 35508 topic_id: 6296 reply_id: 21734[/import]

Well have you read the doc pages about modules?

http://developer.anscamobile.com/content/modules-and-packages

I think you need to define module() at the top of your require() code. [import]uid: 12108 topic_id: 6296 reply_id: 21752[/import]

oh like the AS3 import bla bla bla? I have to check that… Or at least try… [import]uid: 35508 topic_id: 6296 reply_id: 21758[/import]

it was exactly that… after giving: module(…, package.seeall) it worked! So… each file is called a module?
I think i’m sort of understanding the framework too…

Is it possible to do folders with “modules” inside? It would be better for organization. [import]uid: 35508 topic_id: 6296 reply_id: 21765[/import]