Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Announcements and Showcase
Promise (and setTimeout) in CopperCube!

xanimalkingx
Registered User
Quote
2019-03-08 22:10:29

So, I recreated setTimeout and Promise in CopperCube. Promise was possible because of the BluebirdJS NPM module, which I used Browserify to make work in CopperCube. Then I recreated setTimeout so BluebirdJS will stop complaining about setTimeout not being defined.
Promises allow you asynchronously run code, without freezing/lowering the framerate of your code and do many other things, like run callback methods for async tasks.

How to use:
1.) Copy "behavior_bluebird" into "C:/Users/USERNAME/Documents/CopperCube/extensions"
2.) In CopperCube, (Top Menu Bar) "Edit" > "Plugins" > "Reload and Verify Extensions and Plugins"
3.) In each scene you want to use this, attach the "Bluebird Module" on the root scene node only.
4.) Now every other extension used in your scene and any execute javascript action in your scene can use "Promise` and "setTimeout` now!

Download:
http://www.mediafire.com/file/0t...

Documentation:
Bluebird: http://bluebirdjs.com/docs/api-r...
setTimeout: https://www.w3schools.com/jsref/...


niko
Moderator
Quote
2019-03-11 08:20:44

Cool, thanks for posting!


just_in_case
Moderator
Quote
2019-03-17 05:46:10

Thanks a lot for sharing this.


Robo
Guest
Quote
2019-06-18 16:07:04

Sounds Interesting.

In simple terms what does this acheive for games in CopperCube ? - FPS increase ?

I don't know what a Promise is...

SetTimeout - how is that different to the DoLater function ?


xanimalkingx
Registered User
Quote
2019-06-22 02:56:30

A Promise is an action, that can do something later asynchronously. It comes with ES6 but CopperCube is in ES5. setTimeout is more reliable because it doesn't interrupt the FPS of the game while it waits to do the task.


Robert
Guest
Quote
2020-04-24 02:18:51

I have tried this Bluebird extension and had endless setTimeout is not defined messages. Do you have a script example that works ?

Also I did get it to work a bit (I think) and load files from the hard drive but causes temporary freezing up...is that normal as I thought it should not affect other code running...?


Robo
Guest
Quote
2020-04-30 01:22:49

According to Niko, this Bluebird behavior will only work inside browsers and is not for PC games....


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inte?national" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact