Forward reference member functions?

Normally I put all logic and initialisation of objects INSIDE functions. Put all that stuff inside an init() function at the top. But don’t call init() until the very last line of code. That way everything is always forwarded. Make sense?
Basically make the last line execute the very first instruction.

i.e

[lua]function init()

    doSomething()
    doSomethingElse()

end

local function  doSomething()
    print ( “doSomething” )
end

local function  doSomethingElse()
    print ( “doSomethingElse” )
end

init()[/lua]

@craig42: Thanks for the reply! To give a bit more background, the member functions belong to an ‘actor’ module that is used throughout my game. For example, when a new storyboard scene module is entered, the Doggins actor module is created. Then, whenever the user taps somewhere, the Doggins.move function is called. So I don’t think using an init function would help in this case.

It works fine as is, but it would be nice if I could forward reference the member functions and alphabetize them. I would have an easier time going through the Doggins module and revising code.

Thanks!

  • David

@craig42: Thanks for the reply! To give a bit more background, the member functions belong to an ‘actor’ module that is used throughout my game. For example, when a new storyboard scene module is entered, the Doggins actor module is created. Then, whenever the user taps somewhere, the Doggins.move function is called. So I don’t think using an init function would help in this case.

It works fine as is, but it would be nice if I could forward reference the member functions and alphabetize them. I would have an easier time going through the Doggins module and revising code.

Thanks!

  • David