Hello,
I have been pointed at using the “Blenderplayer” after asking the question “How is it possible to run BGE using the command line?” in the Game Engine Support and Discussion – Forum two days ago.
Running the “Blenderplayer” using command line arguments is rather straight forward. Unfortunately, this does not hold – at least for me - for passing arguments to the script running in the logic bricks of the related blender file.
The blenderplayer help suggests using the syntax “[…/blenderplayer.exe” , “-g”, “- my_argument”, blender_file]”. Is this the correct position? Since the blenderplayer is starting, it seems like to be. Even though, I haven’t any example code beyond that.
I am really struggling parsing the argument in the script running in the logic bricks again. The
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument("- my_argument", help="Coordinates")
all_arguments = parser.parse_args()
dash_index = all_arguments.index('-')
script_args = all_arguments[dash_index + 2: ]
parsed_script_args,_ = parser.parse_args(script_args)
return parsed_script_args
args = get_args()
the_argument=args.my_argument
doesn’t work. I am aware that the parsed arguments are string. They are split in the code afterwards.
Any hint and idea how to restructure to code is welcome.
Thanks for your help.