BGE: The WM_OT_blenderplayer_start addon now saves a copy of the current blendfile with a trailing '~' to keep paths intact. An unsaved file will still go to the tmp directory. This file is deleted when the blenderplayer process exits.

This commit is contained in:
Mitchell Stokes 2013-08-29 04:31:55 +00:00
parent 567e13b2bb
commit dea537fd68

@ -1286,9 +1286,10 @@ class WM_OT_blenderplayer_start(Operator):
self.report({'ERROR'}, "Player path: %r not found" % player_path)
return {'CANCELLED'}
filepath = os.path.join(bpy.app.tempdir, "game.blend")
filepath = bpy.data.filepath+'~' if bpy.data.is_saved else os.path.join(bpy.app.tempdir, "game.blend")
bpy.ops.wm.save_as_mainfile('EXEC_DEFAULT', filepath=filepath, copy=True)
subprocess.call([player_path, filepath])
os.unlink(filepath)
return {'FINISHED'}