I use script in the event table.

0 favourites
  • 7 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • In different script blocks, those variables or instances that are retrieved need to be retrieved and invoked once with const. Is there any way that you can use it again and again with only one call without use const in every script blocks?

  • Each script block in an event sheet has its own scope, so local variables aren't shared. If you want to share something between them, you could use global scope instead.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • In each block of code, for example:

    	const a =runtime.object["a"].getfrisinstances();
    	
    

    We hope to get an instance of a once, and then call a. ***() in each script block.

    Instead of getting an instance of A once in every block of code that needs to call A.

    That makes it feel better to take advantage of the logical clarity of script code and reduce more useless code.

    For example, I wrote in the first code box: const a = runtime. obkect ["a"]. get ** ** ();

    Then I can call the instance a directly in each individual script box.

  • Each script block in an event sheet has its own scope, so local variables aren't shared. If you want to share something between them, you could use global scope instead.

    I'm not a professional, but it's great to be able to break down the scope barriers between blocks of code. Those that are retrieved once (retrieved instances) can be invoked directly in all blocks of code only once.

  • Take a look at the 'Ghost shooter code' example. That stores various instances in global variables, which can also be used in scripts in event sheets.

  • Take a look at the 'Ghost shooter code' example. That stores various instances in global variables, which can also be used in scripts in event sheets.

    Thank you for your answer. I learned a lot from this <Ghost shooter code>.,I got a lot of help with this question. Thank you.

    In addition, is < await ()> equivalent to "wait" in the event table? I don't know how to use him yet. How do you make it wait a few seconds in script?

  • They're sort of similar in that they essentially pause execution for a while and later resume, but there are many details that are different. Look up a tutorial on using async functions in Javascript, there's lots of information on the web.

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