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 Answers 2

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()
$\endgroup$
2
  • $\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$ Oct 30, 2015 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, 2015 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.

$\endgroup$
1
  • $\begingroup$ So what exactly should I do in this scenario? $\endgroup$ Oct 30, 2015 at 14:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .