I am creating a little game and for now I have 3 scenes and 2 python modules:
MenuScene must display a menu and the GameScene must be loaded when pressing a START button. For now it only contains a camera, with an ‘Always’ sensor and a Python module (Menu.py) function (Menu.start) as a controller.
The Menu.py module imports the Game.py module, which is a common module that must be able to load/unload any scene of the game. It can load any of the game scenes but it also must load the menu scene if I exit the game to the main menu.
So, for now I must make sure Game.py know all the scenes of the game and here is where I have a problem.
This is my initial code in Menu.py:
import bpy import Game # start function def start(): # load game Game.load()
and my Game.py module:
import bge def load(): print("Loading game...") scenes = bge.logic.getSceneList()
I expect scenes to contain all 3 scenes but it only contains the actual one. Of course, I checked the API reference and saw this:
Scenes in your blend file that have not been converted wont be in this list. This list will only contain scenes such as overlays scenes.
I don’t understand how I must convert the scenes or what does this mean so I tried to add the scenes with bge.logic.addScene before getting the list but it doesn’t work and I suppose the cause is, as explained in this other note:
This function is not effective immediately, the scene is queued and added on the next logic cycle where it will be available from getSceneList
Now, how do I detect or force the next logic cycle so I can get the added scene? Or, maybe there’s another way of getting all the scenes. I am using modules and it seems like the Menu.start function assigned to the ‘Always’ sensor is only executed once. Maybe someone can tell me how would I do this while I am digging for more functions/sensors/actuators in the API reference that could help me.
Thanks for your answers