help me convert this blender 2.4x save load script to 2.7x
Save.py:
### Add objects to be saved to this list ###cube = GameLogic.getCurrentScene().getObjectList()["OBCube"]
cubePosi = cube.getPosition()
cubeRot = cube.getOrientation()
### Open the file "Game1.sav" in write mode
saveFile = open("Game1.sav", "w")
### Write header to file
saveFile.write("This is a valid save file
")
### Write game data to file
for x in range(len(cubePosi)):
saveFile.write(str(cubePosi[x]) + "
")
for x in range(len(cubeRot)):
for y in range(len(cubeRot[x])):
saveFile.write(str(cubeRot[x][y]) + "
")
### Close save file
saveFile.close()
Load.py:
### Add objects to be saved to this list ###cube = GameLogic.getCurrentScene().getObjectList()["OBCube"]
cubePosi = cube.getPosition()
cubeRot = cube.getOrientation()
### Open the file "Game1.sav" in read mode
loadFile = open("Game1.sav", "r")
### Check for the header
header = loadFile.readline()
header = header[0:-1]
if header == "This is a valid save file":
### Load game data from file
for x in range(len(cubePosi)):
loadCoord = loadFile.readline()
cubePosi[x] = float(loadCoord[0:-1])
cube.setPosition(cubePosi)
for x in range(len(cubeRot)):
for y in range(len(cubeRot[x])):
loadCoord = loadFile.readline()
cubeRot[x][y] = float(loadCoord[0:-1])
cube.setOrientation(cubeRot)
### Close save file
loadFile.close()