Hello! I wanna make a game in which there will be 5 levels, If you pass the first, the second will be unlocked etc.
So the problem is :
If for example I play and unlock the 4th level and then close my game, then when I reopen it I want to have it unlocked and not having to pass all the levels again…
In other words, I want a way to save my process in the game…
If you were wanting to save object properties for example, connect an always sensor (True Pulse) to a script controller
Then, (if you wanted to be really complex) you could make a script that saves Every property to a single GlobalDict Variable.
This particular example would only work if it were used on one object, (you could use on more than one if you changed the name of the GlobalDict variable.)
import bge
controller = bge.logic.getCurrentController()
owner = controller.owner
if not "properties" in bge.logic.globalDict:
bge.logic.globalDict["properties"] ={}
def save():
for property in owner.getPropertyNames():
bge.logic.globalDict["properties"][property] = owner[property]
controller.activate(controller.actuators["save"])
print(bge.logic.globalDict["properties"])
def load():
controller.activate(controller.actuators["save"])
for property in bge.logic.globalDict["properties"].keys():
owner[property] = bge.logic.globalDict["properties"][property]
print(bge.logic.globalDict["properties"])
if controller.sensors["s"].positive:
save()
elif controller.sensors["l"].positive:
load()
This script will save and load all the object properties.
attach two actuators( a game: save and a game: load), called “save” and “load”.
Make two sensors, called s and l, s = save, l = load
Then when you activate sensor l it will load the properties, but if you activate sensor s it saves properties