How exactly libload works ?

My game starts from the menu.blend file. It has 10 buttons to choose level.

Levels are standalone single scene “games” = level.01.blend, level.02.blend, …, level.10.blend
I want to use LibLoad instead of links, because it is dynamic

My questions are:

[1] Will the new file level.01.blend completely replace the current playing blend file (menu.blend ?)
It will start from active layer and camera view automatically ?

[2] What happens to the old file when a new file is loaded ? Do I have to worry about freeing stuff ?
(if it works the first time, does not mean it will still work after a couple hours of playing)

[3] Any in-depth documentation of LibLoad will be appreciated. I have found few things but most are basic.

Thanks in advance, my game is going well, I believe this is one of the last issues I have and then R&D is over, Im going into
100% development.

Dimitris

No, it will be merge into the current scene

Yes

No, there is already a camera (as it is merged)

Nothing, the blend files are just read.

Yes, you should unload the previously loaded library after you do not need it anymore.

https://docs.blender.org/api/2.78b/bge.logic.html?highlight=libload#bge.logic.LibLoad

Hello, thanks for your reply,

What good is it then, if the loaded scene merges into current scene ?

This means I have to get rid of the menu, before I LibLoad the level.

How does one get rid of the current scene, then ?

Generally with LibLoad you take a more ‘constructive’ approach:

  • start with a mostly empty scene (have a scene with very little in it that you switch to)
  • load in the player objects
  • load on the enemy objects
  • load in the level objects
  • analyze the level objects and use it to spawn things

Aha I think I get it.

so you switch to that scene with setScene( ) as usually ,
and then the scene uses LibLoad to actually load itself . Right ?

Please tell me I finally got it.

I think what you want is the load blend command, not libload.

i use it like smoking said, 1 main blend with all overlay scenes included, and the player.
that blend loads in other blends like the world / buildings/trees etc, if you need an example of loading blends take a look in my sig, i got a loading screen there.

What do you mean “that blend loads in other blends” ? How is this done ?
(e.g. with the startGame( ) command ? )

No it libloads the blend files loading the whole blend into the main blend while running the main blend.
as i said i got an example in my signature take a look then you get an idea of how i do it.

for example:
main blend contains the character and all over/underlay scenes (menu/hud/etc)
then you got a few more blends like:
1 with trees
1 with buildings
1 with the world/ground
etc etc

those blends gets loaded into main and you got yourself a level to play.

i suggest you to read up on libload, its not that hard.
but there are many ways to do it.

Typically the menu is a separate scene (do not need to but often it has a lot of benefits to do it that way). While you directly or indirectly use the menu input what to load, you do not use LibLoad within the menu scene. You use it within the game (or level scene). You can switch from menu scene to the game scene, or you have the game scene parallel (background scene).

This means you transfer the desired information from menu scene to the game scene which perform the LibLoad operations there.

It can be something like that: “load forest level”.
You can even load/merge several different blends which all will be added to the current scene.

cotax and Monster = I read everything you have posted above, but still I was not sure I understand how to do it.

But I think I got it now = I will use setScene to switch between empty scenes, which only have one empty inside which LibLoads the actual data.

Anyway I will try this, and hope for the best :slight_smile:

I really appreciate your taking the time, thanks !

What I meant was this:
https://docs.blender.org/api/blender_python_api_2_77_release/bge.logic.html#bge.logic.startGame

You just call startGame(“my next level”) to load another blend directly rather than importing it in to the current blend.

Thanks,
that is a good option as well, I will try it as well,

It will take me a few days to experiment with everything and “report back” with whatever I did.

See ya and thanks again.

Hello !

I have finally understood how LibLoad works. Yes it is supposed to work incrementally.
Currently I am making my first game and I want to keep things as simple, also itis a small game, so Im using startGame(“Level2.blend”), etc

But for a big game I think LibLoad would be necessary. You can not copy stuff from level to level, you must reuse stuff. Currently my game
copies everything from level 1 to level 2 (texures, enemies, scripts, everything). You may get away with something like this in a small game,
but not in a big one.

Take care everyone

If you don’t want to copy things, you can try linking groups of objects in from other blends.