HI
I’m using this save script:
### Add objects to be saved to this list ###
player = GameLogic.getCurrentScene().getObjectList()["OBDefault"]
playerPosi = player.getPosition()
playerRot = player.getOrientation()
camera = GameLogic.getCurrentScene().getObjectList()["OBCamera"]
playerRot = player.getOrientation()
### Open the file "skymap.sav" in write mode
saveFile = open("skymap.sav", "w")
### Write header to file
saveFile.write("This is a valid save file
")
### Write game data to file
for x in range(len(playerPosi)):
saveFile.write(str(playerPosi[x]) + "
")
for x in range(len(playerRot)):
for y in range(len(playerRot[x])):
saveFile.write(str(playerRot[x][y]) + "
")
for x in range(len(cameraRot)):
for y in range(len(cameraRot[y])):
saveFile.write(str(cameraRot[y]) + "
")
### Close save file
saveFile.close()
and this script for the healthbar:
##############################################
#
# HealthBar.py
#
# Health Bar Tutorial can be found at
#
# www.tutorialsforblender3d.com
#
# Released under the Creative Commons Attribution 3.0 Unported License.
#
######################################################
def main():
# get the current controller
controller = GameLogic.getCurrentController()
# get the hud object the controller is attached to
hud = controller.owner
#get player
player = getPlayer(hud)
# get player health
playerHealth(player, hud)
# update health bar
update(controller)
####################################################
def getPlayer(hud):
# check to see player has already been found
if hud.has_key("playerObj") == True:
# get player object
player = hud["playerObj"]
# need to find player object
else:
player = findPlayer(hud)
return player
#######################################################
def findPlayer(hud):
# get a list of active scenes
sceneList = GameLogic.getSceneList()
# check active scenes
for scene in sceneList:
# get object list for each scene
objList = scene.objects
# check object in each scene
for obj in objList:
# match player to saved player name
if obj.name == "OB" + hud["Player"]:
# save obj
player = obj
# save player object as owner property
hud["playerObj"] = player
# exit this loop
break
# has player been found?
if hud.has_key("playerObj") == True:
# exit main loop
break
return player
##########################################
def playerHealth(player, hud):
# get the player health
playerHealth = player["Health"]
# set max health limit
if playerHealth > 100:
# max health
playerHealth = 100
# save it
player["Health"] = playerHealth
# set min health limit
if playerHealth < 0:
#min health
playerHealth = 0
# save it
player["Health"] = playerHealth
# create/assign hud Health
hud["Health"] = playerHealth
###########################################
def update(controller):
# get the ipo actuator
act = controller.actuators["health"]
# use hud Health with Ipo Actuator
act.propName = "Health"
# update health bar
controller.activate(act)
##############################################
# run program
main()
and what i want is to get the property Healt from object Default.
and save it to the file with this save script… and of course load it when i!m loading the game back…