[SOLVED]Python LibLoad

Just some quick questions regarding LibLoad(). I am using it to dynamically load another object from another Blend file into my second layer. Then I am using addObject() to add this object to my Scene! This works great but when I am finished using this object should I somehow unload the Blend file that I loaded with LibLoad()? I tried using FreeLib() but this does not give an error but does not do anything either!. It seems FreeLib() is not the correct choice.

Now do I actually need to “Unload” the Blend file I loaded with LibLoad()? Will this save on resources? Also how do I get rid of the object now in my second layer if I just don’t need it anymore?

Sorry:o… And one last question…if there is no way to unload the blend I loaded with LibLoad(), how do I use the object a second time round… Since if I load it again with LibLoad() I get an error saying the Blend that I am trying to load is already open…

So from all this you can probably tell I am still learning Python… So go easy on the replies:p

Hi Shakedown. LibFree() should work. Use LibList() to print out the loaded libraries to the console so that you can see what Blender is naming it.

for library in bge.logic.LibList():
     print(library)

When I was testing LibLoad() and LibFree() a week ago, it seemed to me that it names the library after the .blend file you are loading. So if you use this to load the library:

LibLoad(bge.logic.expandPath('//some.blend'), 'Scene')

then you should be able to unload it like this:

LibFree(bge.logic.expandPath('//some.blend'))

At least, that’s what I seem to remember from my testing.

Thanks Blendenzo!

I was using the relative path to my Blender file for LibFree(). When I used LibList() I did see that blender was using the absolute path when I printed it out. I just did not put 2 and 2 together. The expandPath function seems to be the logical choice here…Thanks again…hope it is going well with your speedgame!..:slight_smile:

It is, and it isn’t. I realized too late that I had made my entire menu and intro system in Multitexture mode, but the game has to be GLSL. When I switched the menu to GLSL, everything broke. I didn’t sleep last night, so it’s fixed now. The next two days are going to be solid work…

Is this LibLoad() question related to a speedgame entry you might be working on? I had seen a few questions from you, but no actual announcement. I was going to use LibLoad() myself, but abandoned it because it was taking too much of my time.

Sorry to hear!..I am really looking forward to your game this year. I am such a sucker for zombie games…lol.

I was so keen to enter speedgame but unfortunately my son got sick again just as development was suppose to start. I lived out of hospital for a few days and then looked after him at home. He is perfectly well now…just had a bad bacterial infection…but by then it was just to late to get started. Regarding LibLoad()… Even though speedgame did not work for me, it has inspired me to start with an idea I have been sitting on for ages. So I am picking things up again to see what I have to work with…:slight_smile:

All the best for the weekend.