Re:Punti salvataggio nel gioco

#218398

Fabio Meloni
Partecipante
  • Blenderista
  • Post sul forum 8

si lo sapevo il problema è che non conosco uno script ho blender 2.65 e ho provato con questo script per il salvataggio:

 

### 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 filen”)

 

### Write game data to file

for x in range(len(cubePosi)):

saveFile.write(str(cubePosi[x]) + “n”)

for x in range(len(cubeRot)):

for y in range(len(cubeRot[x])):

saveFile.write(str(cubeRot[x][y]) + “n”)

 

### Close save file

saveFile.close()

e questo per il caricamento:

 

### 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()

ma non funziona