Hey guys,
so previously in my game i have put all my game logic code into every separate level in my game, obviously this is not the best method, seeing as if i change anything in my logic i have to change it in every level file. So now im trying to modularize my code, i have a single “logic” file and then each level file is its own separate file.
What i currently am doing is loading my level using director class, and at the top of my level i say
[lua]local logic = require(“logic”)[/lua]
so in turn this loads my level up and runs my logic code and it seems to work great, the issue comes when i want to try and reload the same level if i want to retry the level.
Do i need to unload the “logic” that i required, before i can again require it? i guess i just am not sure what needs to be done here. Any help or ideas would be great, thanks!
here is my error that i get
…arc/Desktop/TIRE NEW WORKINGS/iPad/Source/level6.lua:1192: attempt to index field ‘?’ (a nil value)
stack traceback:
[C]: ?
…arc/Desktop/TIRE NEW WORKINGS/iPad/Source/level6.lua:1192: in function ‘buildLevel’
…arc/Desktop/TIRE NEW WORKINGS/iPad/Source/level6.lua:1204: in main chunk
[C]: in function ‘require’
…c/Desktop/TIRE NEW WORKINGS/iPad/Source/director.lua:310: in function ‘loadScene’
…c/Desktop/TIRE NEW WORKINGS/iPad/Source/director.lua:639: in function ‘changeScene’
…rc/Desktop/TIRE NEW WORKINGS/iPad/Source/loading.lua:229: in function ‘callback’
…/TIRE NEW WORKINGS/iPad/Source/transitionManager.lua:35: in function <… new workings>
(tail call): ?
?: in function <?:1138>
?: in function <?:215>
Runtime error
…c/Desktop/TIRE NEW WORKINGS/iPad/Source/director.lua:345: bad argument #-2 to ‘insert’ (Proxy expected, got nil)
stack traceback:
[C]: ?
[C]: in function ‘insert’
…c/Desktop/TIRE NEW WORKINGS/iPad/Source/director.lua:345: in function ‘_listener’
?: in function <?:501>
?: in function <?:215>
[import]uid: 19620 topic_id: 18000 reply_id: 318000[/import] </…>