Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name: Password:
Ambiera Forum > CopperCube > Programming and Scripting
"Every few seconds do something" doesn't work on WebGL
Author Text

dekon_17
Registered User
Quote
2022-04-07 17:41:01

Yeah, despite having great achievements for the past couple of days, I stumbled in a problem that I wasn't expecting. Such basic behavior as "Every few seconds do something" just does nothing! Even more than just that, scripting the stuff with "timeMs" or "new Date().getTime()" don't work neither. The code, basicly, looks like this:
/*
<behavior jsname = "behavior_RanTime" description = "Do stuff at random intervals">

<property name = "Min" type = "int"/>
<property name = "Max" type = "int"/>
<property name = "Action" type = "action"/>

</behavior>
*/

behavior_RanTime = function()
{
this.End = null;
};

behavior_RanTime.prototype.onAnimate = function()
{
if (this.End == null)
{
var Num = Math.floor (Math.random() * (this.Max - this.Min + 1)) + 1;
var Time = new Date().getTime();
this.End = Num + Time;
};

var Now = new Date().getTime();
if (Now >= this.End)
{
this.End = null;
ccbInvokeAction (this.Action);
print ("Done");
};
};

It works well on Windows, still doesn't work with WebGL. The reason why I used "new Date" method is because... Because I tried to avoid "timeMs" problem (with no success, as you probably understand). Is there any way to aviod this problem?


sven
Registered User
Quote
2022-04-07 21:28:07

I tested your script with webgl and..

for me your script works as expected.
(i did play sound - print command does nothing)

also everyfewseconddosomething works as expected.


dekon_17
Registered User
Quote
2022-04-08 06:02:04

Oh... OH...
Well, looks like I screwed up "a bit". Then I probably have problems with my "Spawn" script, since it was the only action I used with it. That was unfortunate... Thanks, sven.


Arcanjo
Guest
Quote
2022-04-08 08:43:24

There are incompatibility of scripts with several platforms.
Some scripts don't work to Android Platform and the same to WebGl platform.

You might find the error and customize the script to WebGl.


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© 2020 Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact