Fail libload

I have this fail in Linux 64 bits. What’s the problem?

Writing: /tmp/main.crash.txt
Segmentation fault (core dumped)

Sometimes crash, sometimes show this

Warning, sensor “Always” could not find its controller (link 1 of 1) from object “demonCharacter”
there has been an error converting the blender controller for the game engine,logic may be incorrect

And sometimes works fine.

PS: sorry I want to post in Game Engine Support and Discussion

Sounds like you’ve got a corrupt blendfile if you’re getting the ‘could not find controller’ error. It’s the only time I’ve got it.

Try creating a new blendfile, and going File->Append
First try appending the scenes.

If that doesn’t work, you may have to append the objects.

I would like to look at the script you’ve written to libload as well if it’s possible.

Thanks for reply :wink:

Fragment of code



class LibraryBlend():def __init__(self, scene="Game"): 
        self.scene = scene
        self.listBlends = []      
        self.numberBlends = 0
        self.library = {}

[INDENT=2]
[/INDENT]
 def update(self): 
        #Comprueba si listaBlends esta vacía, en caso de que lo éste invoca a cargaEscena 
        #print("Blends: ", self.numeroBlends, "Lista: ", len(self.listaBlends)) 
        if (self.numberBlends > 0 and self.numberBlends == len(self.listBlends)): 
            print("Loaded game") 
            self.loadScene(self.scene)


def characterLoad(self, name): 
        path = bge.logic.expandPath("//models/characters/" + name + ".blend") #Converts a blender internal path into a proper file system path. 
        if(path not in bge.logic.LibList()): 
            self.numberBlends = self.numberBlends + 1 
            self.library[self.numberBlends-1] = bge.logic.LibLoad(path, "Scene", load_actions=True, async=True) 
            self.library[self.numberBlends-1].onFinish = partial(loaded, self, path)



def loaded(library, path, status): 
    print("Path: %s" % status.libraryName) 
    library.listBlends.append(path)



Couple of quick thoughts (nothing to do with the problem).
The variable numberBlends can be calculated easily with len(bge.logic.LibList()). Actually maybe not, I’m not quite sure of the purpose of some of these variables, but I’ll assume there is one


The way I read this code suggests that is part of a larger ‘game loading’ system. You have a list of blends that you want to load (listBlends I’d guess), and then each time you call update, it loads the next blendfile, and when they’re done, it prints ‘loaded scene’ and switches too the scene. It uses async, presumably to show a loading bar. (or at least, to trigger the next one loading).


So what’s going wrong?
To be honest, I’m not sure. Try without async libload, and see if it’s a problem with async. Try different blends to see if some of them are corrupt.

Thanks for comment. I fix some things but I progress slowly

For example I can’t to do libload in scene “Loading” and then replace the scene for “Game” because objectsInactive are in Loading scene. So I try to change my script.

I am attempting this. I have and always and a python controller module that way I call to mainMenu.update() when all library is loaded with libload I execute

bge.logic.getCurrentController().script = "game.update"

But this fail, only execute once game.update and then mainMenu.update forever. I don’t know why still

Hmm, I wonder, do any of the files you are loading have more than one scene in them?

I had a case where adding a HUD from a libloaded scene would cause some instability in the scenes list.

1 scene only the blends with libload

for
bge.logic.getCurrentController().script = “game.update”

do you know something?

Are you in script mode or module mode on the logic brick? I’m guessing module mode.

You may want to make sure that it’s getting the right controller, by instead using the one provided with the function


def valid_function(cont):
    print(cont.owner)
    cont.script = "game.update"

I’ve changed that attribute in some of my past projects, and it’s always worked for me. Are you sure you aren’t setting it back somewhere?

And yeah, there is the problem that libloads happen in the scene you start them from.
So I tend to have quite the following system set up, whereby the two scenes can communicate.

In the loading scene I have a message actuator connected to a python controller on a text object, and using that I can display what I’m loading, or use vertical bars (|) for a rough loading bar.
In the game scene, I have:
Always(run once) -> and -> add overlay loading scene
Always(run always) -> Python (the loading script)
The loading script loads blends, and then sends a message to the loading screen to get it to update.
After the loading script has loaded all the blends, it end’s itself (obj.endObject())

I’ve never really used a script that runs every frame generically ‘for the game’ like what you are proposing to change it into (game.update). I tend to let objects manage themselves.

Yeah I tested a code how that and only one print.

Now I tested with object,

 bge.logic.getCurrentScene().objects["Loading"].endObject()

but next line I do

 print(bge.logic.getCurrentScene().objects)

and print [Loading, Game, and objects loaded with libload] . I don’t know why print Loading

ah… an advice if you test this code I put in script controller update run and only need an always



p = 1

def update():global p #I don't know if this is necessary
print(p)



You can initialize all you need before function simply

and print [Loading, Game, and objects loaded with libload] . I don’t know why print Loading

Probably because it is the same frame, and it hasn’t been removed yet. Things like that only happen on frames.

i don’t sure of this because the object deleted have a module with loop of images and text loading made with bgui and this never dissapear of screen. I don’t understand why.

Ok I did a comprobation and Loading isn’t in scene now but I see the bgui loading scene implement in loading object… I’m confusing :S

Ahh, BGUI is not attached to an object. It is created by a script attached to an object, but the things it displays are seperate. SO instead of ending the object creating the BGUI interface, you have to also iterate through anything it has created, and remove those by their own functions to do so.

Thanks I will test if blends are corrupted when I finish to fix bgui code ;). But I don’t know how still xD