The console says you have a ton of broken links, look at the warnings.
I guess I’m confussing you, so to clarify: I don’t mean that these links between bricks don’t exist, I mean that these links are lost when loading the blend from another file. This usually happens when one links bricks on one object to bricks on another object.
Note that even if this isn’t the cause of the crash it’s still going to break your logic; if a controller depends on receiving a signal from a sensor whos lost a link to it, that signal will never arrive. And I can’t test it right now, but I think that if you tried to reference that sensor in python through
cont.sensors you would run into trouble as well.
So first things first: fix these links. How? To start off, avoid linking bricks across objects. If controller on object A needs to evaluate a property on object B, you can setup logic like so
And if you want to read the body of the message in python, you can have the controller which receives it interpret it like so,
from bge.logic import getCurrentController
cont = getCurrentController()
mess = cont.sensors["Message"]
prop = None
#check that bodies !=  -- just an empty list
#if true, convert the body of the message (a string) into the right type
if mess.bodies: prop = eval(mess.bodies[-1])
#if prop != None, message was received
if prop: doSomething()
#note: if value of property is false, doSomething() will never execute!
In case you haven’t used it before,
eval() in python turns a string into an expression; basically it translates text into other values, though it’s limited to common types (int, float, bool, list, dict).
eval( str([0,0,0]) ) returns a list containing three zeroes rather a string “[0,0,0]”. Same functionality for dictionaries, so you can pass around a lot of data this way. Fun fact: it also works on expressions, so you can also do things like
#say s == "function(var)"
var = 1
eval(s) #executes function and uses the attributes we just defined
#say s == "var == 1"
var = 1
if eval(s): print("python is good for you")
Finally, this isn’t a matter of handling exceptions, it’s a matter of fixing your game logic. You could, maybe, add a ton of try/catch blocks onto every last piece of code that depends on a brick that could get lost when opening the file, but that’s a terrible idea. What you want to do is make sure that none of these links get lost, and the way to do that is doing some rethinking.
Yes, I get it – absolute bummer and there’s no quickfix for this. Welcome to game development!