0
$\begingroup$

In BGE, in an initialization script, I have these instructions:

var=bge.logic.expandPath("//")
print("====== path=",var,"=======")

and now the variable "var" is set to the path of the Blender file.

Ok, but when I export the game (Save As Game Engine Runtime) and move the saved file to another path or another PC, the "var" variable does not change, i.e. it remains the one it was before moving the file.

$\endgroup$

1 Answer 1

0
$\begingroup$

Have you looked at the right console?

You need to start the game with option -c to see the console window of the game.

When you do not see the game's console you might have looked at the console of the still opened Blender.

In my test the path was correctly pointing to the location of the game's folder.

$\endgroup$
3
  • $\begingroup$ Thank you for your answer. What you suggest is right, but I want to launch the game from the terminal. I would like to run it through a script: ` #!/bin/bash exec "/game_path/mygame" ` And even if I do ` cd "$(dirname "$0") exec "/game_path/mygame" ` (dirname "$0") sets the current directory to the script path the instruction ` var=bge.logic.expandPath("//") ` in the game script sets "var" to the path to the Blender file at the time of export. Translated with www.DeepL.com/Translator $\endgroup$
    – Ave
    Mar 22, 2018 at 11:04
  • $\begingroup$ It seams you are using Linux. I do not know the specific behavior of the blenderplayer running on this OS (I use Windows). $\endgroup$
    – Monster
    Mar 23, 2018 at 6:11
  • $\begingroup$ Thank you @Monster, but I solved it myself: I created a launcher that instead of starting the bash script executes the instruction: "Exec=/myPath/myGame". $\endgroup$
    – Ave
    Mar 24, 2018 at 7:13

You must log in to answer this question.

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