ok i have a save script
g = GameLogic
c = g.getCurrentController()
o = c.getOwner()
scene = g.getCurrentScene()
PlayerList = scene.getObjectList()
saveFile = open("Game1.sav", "w")
saveFile.write("This is a valid save file
")
for i in range(0,len(PlayerList)):
obj = PlayerList[i]
if hasattr(obj,"character"):
cubePosi = obj.getPosition()
cubeRot = obj.getOrientation()
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]) + "
")
saveFile.close()
and a load script
g = GameLogic
c = g.getCurrentController()
o = c.getOwner()
scene = g.getCurrentScene()
PlayerList = scene.getObjectList()
cubePosi = o.getPosition()
cubeRot = o.getOrientation()
loadFile = open("Game1.sav", "r")
header = loadFile.readline()
header = header[0:-1]
if header == "This is a valid save file":
for i in range(0,len(PlayerList)):
obj = PlayerList[i]
if hasattr(obj,"character"):
for x in range(len(cubePosi)):
loadCoord = loadFile.readline()
cubePosi[x] = float(loadCoord[0:-1])
PlayerList[i].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])
PlayerList[i].setOrientation(cubeRot)
loadFile.close()
if i save than load it give me a wierd error and everything position and orientation gets really messed up
PYTHON SCRIPT ERROR:
Traceback (most recent call last):
File "Load.py", line 18, in <module>
ValueError: empty string for float()
the weirdest thing is that it worked fine yesterday,
thanks ahead of time,
Joel-Scorched Earth Games