Hi, I have these “if” for when I press k to load differnt level maps on my game I am working on. Just by looking at the code below I know it wont work, cus it will loop it self back to the starting map that was loaded. I tried using break so that it will get off the ifs but I dont think you can do that… or when I tried it says its out of the loop.
if self.town == "towns/a":
self.environ.detachNode()
self.town = "towns/controlroom"
#Load the first environment model town.egg
self.environ = loader.loadModel(self.town)
self.loaded = "9999"
self.environ.reparentTo(render)
self.environ.setScale(0.15,0.15,0.15)
self.environ.setPos(0,0,0)
self.town = ""
if self.town == "towns/controlroom":
self.environ.detachNode()
self.town = "towns/dg1"
#Load the first environment model town.egg
self.environ = loader.loadModel(self.town)
self.loaded = "9242"
self.environ.reparentTo(render)
self.environ.setScale(0.15,0.15,0.15)
self.environ.setPos(0,0,0)
if self.town == "towns/dg1":
self.environ.detachNode()
self.town = "towns/a"
#Load the first environment model town.egg
self.environ = loader.loadModel(self.town)
self.loaded = "1"
self.environ.reparentTo(render)
self.environ.setScale(0.15,0.15,0.15)
self.environ.setPos(0,0,0)
Yea, but the code still loops it self, I need to some how put a break or something inside so it will go out of the ifs… I tried doing this but no luck still… Just need to get this error out of the way SyntaxError: ‘break’ outside loop
if self.town == "towns/a":
self.environ.detachNode()
self.town = "towns/controlroom"
#Load the first environment model town.egg
self.environ = loader.loadModel(self.town)
self.loaded = "9999"
self.environ.reparentTo(render)
self.environ.setScale(0.15,0.15,0.15)
self.environ.setPos(0,0,0)
break
elif self.town == "towns/controlroom":
self.environ.detachNode()
self.town = "towns/dg1"
#Load the first environment model town.egg
self.environ = loader.loadModel(self.town)
self.loaded = "9242"
self.environ.reparentTo(render)
self.environ.setScale(0.15,0.15,0.15)
self.environ.setPos(0,0,0)
break
elif self.town == "towns/dg1":
self.environ.detachNode()
self.town = "towns/a"
#Load the first environment model town.egg
self.environ = loader.loadModel(self.town)
self.loaded = "1"
self.environ.reparentTo(render)
self.environ.setScale(0.15,0.15,0.15)
self.environ.setPos(0,0,0)
break
else:
break