I am programming a game in Lua based Corona that requires that I require a module inside of another module. I am getting a looping error. The reason I am doing it this way is because I need to use a function that I have defined in main.lua in a module that itself is required in main.lua. To solve that problem, I decided I would hold my game state in a separate module called gameState.lua. But then, I get the circular requirement error. Is there any way to get around this in Corona SDK?

有帮助吗?

解决方案

I need to use a function that I have defined in main.lua in a module that itself is required in main.lua.

Move that function out to a third module and require it in the other two.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top