Check if Scene exists.

LtVax27

  • *
  • Posts: 85
I have several scenes with designs in them that I want to run through to generate 3D List data. I need to check if <the next scene exists> if not -Main Menu.
I tried to put <[Scene with name __ ]as boolean> but both existing and non return false.

Luyren

  • *
  • Posts: 1690
See attached image.
Working.

LtVax27

  • *
  • Posts: 85
See attached image.

That seems to do the same thing.
As the Scenes are named the same I inc the number but want it to check if there is another before it tries.

Luyren

  • *
  • Posts: 1690
I got that block combination to return true if a scene with that name exists, and false if it doesn't. Isn't that what you need?
Working.

LtVax27

  • *
  • Posts: 85
Still getting the same results on my end?
Ship002 - Exists       Ship015 - Non     Start - Exists     Hippo - Non
Might be a Scene event bug, (testing)



« Last Edit: July 10, 2019, 09:32:44 pm by LtVax27 »

merrak

  • *
  • Posts: 2428
It might be returning the first scene in cases where the scene doesn't exist. Here's the code for the block, found in Script.hx

Code: [Select]
        /**
         * Get the ID of a scene by name.
         *
         * @return The ID current scene or 0 if it doesn't exist.
         */
        public static function getIDForScene(sceneName:String):Int
        {
                for(s in GameModel.get().scenes)
                {
                        if(sceneName == s.name)
                        {
                                return s.ID;
                        }
                }

                return 0;
        }

It seems like you could just call getIDForScene and check whether or not the returned value is 0.

LtVax27

  • *
  • Posts: 85
Unfortunately I never know what I'm doing with custom code, did try and print a few parts trying to get names but ended up thinking of an easy way to do what I need.

While this does work I need a 1sec delay or it detects the ?Scene loading transition?, so the more I add the longer the 1st load of the game will be.
Might change how I'll do this by having the player Scan the Space Ship and take them to the Scene containing that design, I can then log that data and just have a DOCK button to go to the scene that uses the data to generate 2 ships docked together.

« Last Edit: July 11, 2019, 05:02:35 am by LtVax27 »