3
$\begingroup$

I have two blend files, a.blend and b.blend.

I open a.blend, and run the game engine P. A script is then run that uses the function bge.logic.startGame("b.blend"), which starts running the game setup in b.blend.

In b.blend, another script runs. This one needs a value that is in a script in a.blend. How can I pass a var from a script in a.blend to the script in b.blend?

$\endgroup$
2
$\begingroup$

You could dump it to a file.

a.blend

with open('/tmp/mydata', 'w') as f:
    f.write(a_setting)

b.blend

with open('/tmp/mydata', 'r') as f:
    b_setting = f.read()
| improve this answer | |
$\endgroup$
  • $\begingroup$ Eh.... that is really inefficient, I did think of doing that already. I wonder it it could be passed more efficiently via an external source though. $\endgroup$ – GiantCowFilms Oct 30 '15 at 19:00
  • $\begingroup$ As you start your game session just once, it "just" increases loading time a bit when starting. A typical game has a save(load option already, so you might use it for such a purpose as well. $\endgroup$ – Monster Nov 2 '15 at 5:29
0
$\begingroup$

You can't.

As the name implies, you start a brand new game session. The sessions have no relationship to each other (except the starting operation). Each session starts from scratch.

| improve this answer | |
$\endgroup$
  • $\begingroup$ So what exactly should I do in this scenario? $\endgroup$ – GiantCowFilms Oct 30 '15 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.