Cannot set text from globalThis variable

0 favourites
  • 8 posts
From the Asset Store
OpenAI TTS
$10 USD
Text-to-Speech plugin.Allows your Construct 3 project to convert written text into spoken words
  • Hi There,

    I am testing out some things for a project and I want to use Vanilla JS for game logic but I cannot construct function script to return the value I have set in globalThis.

    I am setting the variable on Layout start but when trying to set the text on a sprites on created event it is undefined and not setting the text.

    If I console.log while after it has all loaded the variable content shows as expected.

    Can someone point out what I am missing.

    Many thanks

    Tagged:

  • runtime.setReturnValue()

  • Thanks Wilson, Yeah I have tried that and it is still not working.

    This is what the code outputs on the console. It is looking like a bug if I am honest.

  • I have spotted that the issue event is execution order, On Start Layout is calling after the Sprite creation event.

    Is there any documentation on execution order and can you force Layout before Spite Creation event or is there another event I can't spot that can run before those events?

  • Ok, resolved this by removing the instances from the layout and then spawning them in. Kinda annoying and one might say it is a bug that the instances created events do not execute in order. On Layout started should fire before the instances of objects on the layout.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • "On created" fires before the "On start of layout" event to create the instances present on the layout. This is necessary so that you can refer to them in the "On start of layout" event.

  • Ah good spot, I might have changed that while playing around trying to get it to work.

  • You can define global variables in the main.js script inside runOnStartup to have it run before the layout.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)