Init function and reinitialize function?

Why might a program need a function like the one below:

function init(self)
	reinitialize(self)
end

It seems redundant since all that is contained within the init function is another function and nothing else, yet I see programs with these function still.

What is the point/necessity of them? what do they do?

“reinitialize(self)” should be within the function, the indentation just got removed when I posted it.

If I understand correctly what you are asking then one of the major reasons to do it is because you might have more than one way to initialize it that doesn’t involve reloading the whole scene/file.

For instance, if your level could be instantly reloaded after a game over then by putting it in a separate function you are able to also call the reinitialize(self) from a different location (such as a on message).

The init would only run when you start the level the first time, but on a game over the level doesn’t need to be reloaded, only restarted.

2 Likes

thats very useful, thanks!