both blend files in that archive are already small . i made it to rar file thats probably why the uploader on forum doesnt accept it. next time i zip it
Most likely!
The reason you file is not working is because the library is already loaded in another scene, and hence cannot be reloaded for use elsewhere. I would recommend doing things a little differently. Instead of switching scenes, load in your scene files into the main scene. It’s quite cumbersome having each scene manage logic to other scenes.
You can use bge.logic.LibFree to delete the added objects from that library, and check if the library is already loaded using bge.logic.LibList
the main scene should be a static scene that controls everything. and from that i want it to show all other scenes as underlay scene. First step i made there is just adding 1 of the other scenes as underlay scene, then from the main scene i send messages to one of the underlay scene to make them replace each other… kinda like that.
At this stage, I do not know enough of what you need to achieve in order to make any further comments, but I will say that you should avoid having each underlay scene transition to other scenes. This should be done once, by a management scene, which can use logic.addScene and removeScene as necessary to change scenes.
Here’s an example of LibLoad scene switching.
boom.zip (247 KB)
thanks agoost i take a look now
Just for the protocol, I’m not using LibLoad ,cause it is not available in blender 2.49b, I link all my blend files with assets to the current scene file and it works like charm. LibLoad is a great feature, but at the end of the day, you can just link what you want to your scene/level. I think LibLoad purpose is for kind of open world 16m3 km open world. For a relatively small games like ours it isn’t worth it. No hate here just, my observation.
One area it can add advantages is to dynamically loaded assets, such as server-downloaded game maps, and open world. Besides that, I find it a convenience tool.
i did not use libload in my previous projects either. I thought KRUM really has alot of external blend files @.@ or not ?
thanks agoose77
from bge import logic
def switch_scene(cont):
own = cont.owner
scene = own.scene
map_index = own['mapnber']
map_name_object_name = own.get('map_name_object', 'Mapname')
map_names = [c.strip() for c in own['map_names'].split(",")]
map_name = map_names[map_index]
try:
previous_map_index = logic.globalDict['map_id']
except KeyError:
logic.addScene(map_name, 0)
else:
previous_map_name = map_names[previous_map_index]
map_scene = next(c for c in logic.getSceneList() if s.name == previous_map_name)
map_scene.replace(map_name)
logic.globalDict['map_id'] = map_index
scene.objects[map_object_name]['Text'] = map_name
Updated script.
thanks agoose77
now it says line 11 is wrong, the ‘maps’ is not defined yet
Sorry, I made a mistake, try that.
thanks agoose77
now it seems to work abit better, but still…
The start value of map index is 0, it is supposed to show the very first scene, but it does not. I only shows the second scene after i change index to 1. when i try to change index to 0 again or to 2. it doesnt continue changing
Make sure you trigger the controller first frame
thanks agoose77
i connect the script with an always sensor this time (before: property changed sensor). It shows the first scene but is not able to change value. the text doesnt change and even the scene
Think about what the script is doing - the script controller only runs whenever you trigger it. So, at the moment the always sensor is sending one positive pulse on the first frame.
Thereafter, it won’t trigger the script. So, you need to have both events trigger the controller.
- An Always sensor, as you have there.
- A property changed sensor, so that later changes to the property trigger the script.
You’ll also want to be sure this only runs once per tick:
from bge import logic
def any_positive(cont):
for sens in cont.sensors:
if.sens.positive:
return True
return False
def switch_scene(cont):
if not any_positive(cont):
return
own = cont.owner
scene = own.scene
map_index = own['mapnber']
map_name_object_name = own.get('map_name_object', 'Mapname')
map_names = [c.strip() for c in own['map_names'].split(",")]
map_name = map_names[map_index]
try:
previous_map_index = logic.globalDict['map_id']
except KeyError:
logic.addScene(map_name, 0)
else:
previous_map_name = map_names[previous_map_index]
map_scene = next(c for c in logic.getSceneList() if s.name == previous_map_name)
map_scene.replace(map_name)
logic.globalDict['map_id'] = map_index
scene.objects[map_object_name]['Text'] = map_name