Overlay scene not in scene list?

Ok so I currently have my camera object doing 2 things, the very first logic block sets the “Overlay” scene to be an overlay I also tick the priority button so it’ll be sure to do it first. The second thing is run a script, The import part of the script for this issue is the first thing I do it create an instance of my “Client” class, when I do this the client creates an instance of my “Chat” class, inside the Chat class I’m trying to get 2 objects from my Overlay scene which are both text fields.

So I figured I’d test this using something like this…

listScene = logic.getSceneList()
        for cur in listScene:

The issue is it will not list the Overlay scene when I do this in the Chat class constructor but if I run it a few times in the main loop it does end up finding the Overlay scene. Is there a known fix for this?

Edit: I suppose I could completely remove the chat from the client class and run it from the Overlay but the client has quite a bit of useful info to make it easier to work it and less need to rewrite the same code


Scenes get added after all the logic stuff happens.
So the order that things happen is:

  1. Scene add actuator called (Scene not yet added)
  2. Python script called
  3. Scene added

This is problematic since 2 needs to happen after 3.

You could fix this in a couple of different ways

  1. Have object that controls setup do it in 2 tics, with the script that requires the “Overlay” scene happening in the second tic
  2. Have some object in your overlay scene call the script, so you are certain that the overlay scene exists

I handle setup the first way:
Primary setup
Secondary setup

Good luck

Added scenes aren’t available from getSceneList() until the next logic tick.


Note This function [addScene] is not effective immediately, the scene is queued and added on the next logic cycle where it will be available from getSceneList

Based on what you said, it sounds like you could refactor the classes. Create a class or module that both the chat and the client class can subclass or import to avoid duplication.

Probably right about the classes but it’s a very small class really and I just did it the most simple way I could think of. I guess it’s possible to run chat.updateChat() as a module inside the overlay scene and run my clients recviece and send in the main scene.

Edit: I figured out a easy way to fix this so I figured I’d post it for anyone else who may have the same issue.

This is my Chat object’s update function so it is called every tick so it will update the scene object to the right one.

if not self.scene.name == "Overlay":
            for cur in self.listScene:
                if cur.name == "Overlay":
                    self.scene = cur
                    self.messageText = self.scene.objects["MessageText"]
                    self.inputText = self.scene.objects["InputText"]
            self.listScene = logic.getSceneList()

The scene variable is set to a types.KX_Scene so it’ll have a null name to start I assume.

The first thought I had when reading this:

Why do you have a chat outside the overview scene?

If the overview scene should act as view to the chat (which resides somewhere else) the chat has to deal with missing view anyway. A good way is that the (objects of the) overview scene registers themselves at the chat as view. This would allow to even switch the overview scene if it is necessary.

I just use the Overlay because it seems like the right thing, the overlay will control all the menu’s, health and mana bar, inventory, chat, anything that is in a set position and in a 2D view. The game world and the game itself will run in the main scene.

I don’t understand exactly what you mean so I’m a bit lost as to why using a overlay isn’t the best option for this?

I and (I think) Monster agree with you that having an overlay scene is a good thing.

But why is the “Chat” object not in the overlay scene? Why is it instead in the starting scene?

Moving it to the overlay scene solves your initial question and in general makes more sense.

It could be put in there I’d just need to change around my client class is going to handle all my networking stuff and since most of the chat is just send and recvieve I made the chat class and actually create it’s instance with my client class. I guess if the client class just sent data to my overlay scene object to update the visual it would work fine too and perhaps be a better idea to keep the network code separate from the graphics. but it would still require accessing the overlay from the main scene. This may change your thoughts on it as I forgot to mention it’s a network based chat, not sure.

I do have it working perfectly now but I’m always open to better ideas. :smiley: I will try to work on adding the graphical updates to the overlay scene but is there a better way to get the data from the Client class? It’s run from the main scene.