SAVE from one blend file to another

Hi guys, how are you?
I need your help once again…
I´m making a game in blender 2.49 (It´s like a Mario world) where I have a “world map” where I can choose what level I wanna play.
The idea is everytime I finish a stage, the next stage is available to be played.

So, my problem is, I do not know how to make this happen in blender, for example:

  • I have “worldmap.blend” and if I enter the first level “level1.blend” (With game actuator, start new game), there is no problem at all.
  • Then, I reach the end of “level1.blend”, and I need to say to the blender file “worldmap.blend” that the second level should be available to play.

I´ve been watching some scripts that Monster made (Great by the way), but as far as I know they only works in the same blend file… (I need to communicate one blendfile to another, to be storing my game progress)

I do not know a thing about programming (I´m the most ignorant guy in the earth about code) I´m specialist in 3d areas and logic bricks:

So, I really, really appreciate your time and help


Alejandro Navarro

See this, made by me.

And this made by us at the office

Thanks again!

If you create a file, you can save to that file - like a text file. Python has many commands available to do this, such as the
open() command.

Python would allow you to achieve this very easily, and you could with python have all your game happening into a single .blend file, which only gets things from other .blends.

Are you willing to learn some python or you just want logic bricks? If you want to give python a shot, will just explaining how you can achieve that yourself be enough or you just want a complete code to just insert at your game?

Is not my intention right now to learn programming, because I´m quite stressed with the amount of work I have to do everyday…
(I work around 12 hours at day or more) But oin a not distant future would be useful…
So, if anyone could give me a hand and tell me exactly how I could achieve this, I´ll be se grateful…

12 hours a day? That is a lot more than the usual 8 hours.

I will try to keep it simple, I do not know how the BGE behaves if you do not have a main blend file instead of switching entire .blend files; but into a game project with a single blend file you would need:

1 - A default always sensor(without pulse mode please) connected to a python controller set to script, with the below code:

#import BGE and python stuff
from bge import logic as logic
import os, sys

#change current dir and solve directory separator issues on any OS

#make it know where is the code folder, otherwise it wont know where it is and for it only things in the main project folder, know as //, exists. So no subfolders are know without this REPLACE WITH WHERE THE FOLDERS ARE LOCATED AT YOUR GAME PROJECT

2 - Make a second Always sensor(now with pulse mode on) connected to a python controller set as module. If you set the path to your game code folder correctly, you will just enter at the controller ‘main.update’.

3 - Add a property to the object with these logic bricks called ‘init’, with boolean and checked.

4 - Make a file called with a text editor like gedit or other. Below a resumed version of my

try: #Always verify for problems
	# Import needed modules

	from bge import events as events # bge module needed for input checks
	from bge import logic as logic # bge uh...logic module

	import g_variables # My custom variables module

	import graphics # my graphics module

	import input # my inputs module

	import sound # My sounds module

	class Main():

		def __init__(self):

			self.sound = 0 = 0

			self.input = 0

			print('Core modules succefully loaded')

		# Start the game
		def base_setup(self):

			# Create core classes instances
			self.sound = sound.Sound() = graphics.Graphics()			

			self.input = input.Input() 


		# Update the Game
		def update(self): # Check for graphic changes

			self.input.update() # Check for input changes

			self.sound.update() # Check for sound changes

                        #OTHER UPDATE CHECKS HERE

	# The blender object calling the script
	init_game = logic.getCurrentController().owner.get('init')

	# Create a main instance if first run, otherwise update the created instance
	if init_game: 

		logic.main = Main() # Have to store in the BGE dictionary before calling class function otherwise it will not exist if logic is asked about it


		init_game = False

	# Single function which update all the game
	def update():


except: # If something is wrong

	print('A fatal error has occured, closing Questverse')

	logic.endGame() # Ends the game

5 - Every python variable you define at or other module which was ‘imported’ will be kept throughout all the game until you close it. To keep the data after that you will need to store it into a external file at runtime, with this however I cannot help you, as my project hadn’t come to this part yet.

6 - Make a simple ‘If-Else’ check at the module of your choice, if the condition is met, the level will be playable, otherwise it won’t.

I really advise you to learn python, because logic bricks can soon become something very, very hard to manage, not to mention a lot of other issues; they do are useful for initial learning only thought. Better learn slowly than never.

could you just use the game actuator. start new game worldmap.blend when you finish the level and start new game level one when you select level one?

I use quite a complex system, but it works really well and is both flexible and expandable:
4 base files:

  1. Menu.blend
  2. Main.blend
  3. Models.blend
  4. Enemies.blend
    and then however many blend file in a folder called “Levels”

What happens is you open and play from “Menu.blend”
When you start it it opens and plays Main.blend.
Main.blend uses libload to load all the models and enemies.
It then libloads the level, and adds in the models and enemies at the correct locations (indicated by empties in the level)

The level is found by using a function in the blend API that gets a list of all the blend files in a directory. So any new levels will appear by themselves.

Can add new levels easily
Assets (models) are kept separate, meaning they don’t have to be duplicated for each level.
Levels are self-contained.

Complex to write.
Requires good python knowledge. (The script I use would be useless to you, as it is for a particular setup)
Possibly increases loading time.