I’m trying to make a one and two player racing game. I have two cars and two scenes. There is one scene that has both cars. But none of the others do. And I was wondering if it would be possible to use the load script to load from a different scene.
(I don’t know a lot about python, but i think that the line at the top “cube= GameLodgic.getCurrentScene()” has something to do with it.
The save script i’m using
Add objects to be saved to this list
cube = GameLogic.getCurrentScene().getObjectList()[“OBCarGreen”]
cubePosi = cube.getPosition()
cubeRot = cube.getOrientation()Open the file “Game1.sav” in write mode
saveFile = open(“TwoPlayer.NC”, “w”)
Write header to file
saveFile.write("This is Two Player
")Write game data to file
for x in range(len(cubePosi)):
saveFile.write(str(cubePosi) + "
")
for x in range(len(cubeRot)):
for y in range(len(cubeRot)):
saveFile.write(str(cubeRot[y]) + "
")Close save file
saveFile.close()
The load script i’m using
Add objects to be saved to this list
cube = GameLogic.getCurrentScene().getObjectList()[“OBCar_Green.001”]
cubePosi = cube.getPosition()
cubeRot = cube.getOrientation()Open the file “Game1.sav” in read mode
loadFile = open(“TwoPlayer.NC”, “r”)
Check for the header
header = loadFile.readline()
header = header[0:-1]if header == “This is Two Player”:
Load game data from file
for x in range(len(cubePosi)):
loadCoord = loadFile.readline()
cubePosi = float(loadCoord[0:-1])
cube.setPosition(cubePosi)
for x in range(len(cubeRot)):
for y in range(len(cubeRot)):
loadCoord = loadFile.readline()
cubeRot[y] = float(loadCoord[0:-1])
cube.setOrientation(cubeRot)Close save file
loadFile.close()
Thanks in advance.