So, Corona is a bit sucky. Well, I have to life with it I’ve seen that the require function stores all functions from the module in a table. I was wondering how to not have this, or remove the table thing. I’d like to have multiple files, where one represents the core and the other utility functions. But I don’t like to use tbl.func() in the core, I prefer just func(). So, is this even possible, and how? [import]uid: 76100 topic_id: 12546 reply_id: 312546[/import]
very simple, set a reference to it and use it the way you want.
local func = tbl.func
now use func() instead of tbl.func
hope that resolves your issue,
LUA is great in a lot many ways, it is as limiting as we can utilise it. Corona harnesses this awesomeness of LUA, so it can be amazing or sucky depending on the individual. It does have a slight learning curve, once you are over that, it is all downhill.
cheers,
? [import]uid: 3826 topic_id: 12546 reply_id: 45901[/import]
Nah, that’s simply renaming functions manually. That will really suck when you have 10 utility files, each with around 20 functions. Yes, that’s normal for me Especially for Corona as it’s functions are pretty… well weird. For example, getting thr gyroscope rotation will require 3 long named variables, but I’m used to funcs such as local x,y,z = getGyroRotation()
Oh well, to the point, I already found out. Just learned that _G holds all global functions, so the following test script did the job
[lua]tbl={}
tbl.one = function ( txt ) print ( txt ) end
tbl.two = function () print ( “2” ) end
for k,v in pairs ( tbl ) do _G[k]=v end
one ( “test” )
two ( )
> test
> 2[/lua] [import]uid: 76100 topic_id: 12546 reply_id: 45904[/import]