Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name:  Password:
Ambiera Forum > CopperCube > Feature requests and bug reports
New "Do Something Later" extension please?
Author Text

veganpete
Registered User
Quote
2021-07-02 09:28:47

I've mentioned before that for me, when I use the "Do Something Later" extension, it often appears to repeat itself over and over. Sounds, event's and variable changes get stuck in a loop which breaks the game.

For example.
Do something later (1000ms): set variable "x = 0"

-What I expect to happen is:
a single event which sets Variable x to 0 (after 1second delay).

-What I think actually happens is:
x is being set to 0 every second.

I can't really figure out what's causing the issue and no-one else can reproduce the problem.

Would anyone mind taking a look at the extension please to see if they can spot any reason for it - or maybe suggest how I can fix it?

I'd be happy to pay for your time/effort if you can get it working for me?.....

*I have Win10-64 with a registered (purchased) copy of CCB (which I have re-installed), so hopefully it's not a cracked/corrupt version.

Here's the default script from the coppercube site....

// This is a scripted coppercube action.
// It does an action somewhen later.
//
/*
<action jsname="action_DoLater" description="Do something later">
<property name="TimeMs" type="int" default="500" />
<property name="ActionToDo" type="action" />
</action>
*/

action_DoLater = function()
{
};

// called when the action is executed
action_DoLater.prototype.execute = function(currentNode)
{
var me = this;
this.registeredFunction = function() { me.doLaterFunc(); };

ccbRegisterOnFrameEvent(me.registeredFunction);

this.startTime = (new Date()).getTime();
this.endTime = this.startTime + this.TimeMs;
this.currentNode = currentNode;
}


action_DoLater.prototype.doLaterFunc = function()
{
var now = (new Date()).getTime();

if (now > this.endTime)
{
ccbInvokeAction(this.ActionToDo, this.currentNode);
ccbUnregisterOnFrameEvent(this.registeredFunction);
}
}


Thank you!


sven
Registered User
Quote
2021-07-02 10:57:07

DoLater script works fine..

Problem lays in your game logic.. probably you dont execute it once but in a while so it keeps executeing itself..

How to avoid that problem depends how you trying to use it..
i dont exactly know so i cant give example.


just_in_case
Registered User
Quote
2021-07-02 12:44:30

if you want you can use variables along with the script to make it execute correctly with the every few seconds behavior...

for example, every few seconds 1 Ms do something, If a variable has a value do something.

if variable Z = "true" then do something later now attach the action do something later and execute whatever action you want. Also, add the action set or change variable Z = "false" in the same action of doing something later.

now in your game whenever you want to execute that particular action then just simply set the variable Z = "true".

what this will do is it will only execute the do something later action if Z = true and as you were mentioning your problem of self-execution of the action which will be solved automatically cause the variable Z will be false after the execution of do something later action which will prevent it from self-executing.

above is just an alternative as you are having difficulty using the Do Later action. Also, there are some modified actions of do something later also available. if you want you can use them as well.

Alternatively am providing you a sample ccb file that hides and unhides a cube mesh after 2 seconds whenever you press the F key. Let me know if the sample file doesn't work for you.
Also am attaching a modified do later function which uses a variable named "delay" to do something later. I don't know who is the author of this modified action but you can use it if you want.

sample ccb file :- https://drive.google.com/file/d/...

Alternative Modified Action :- https://drive.google.com/file/d/...

hope that helps..

P.S:- As @Swen mentioned Do Later Action works perfectly there is nothing wrong with the action.





veganpete
Registered User
Quote
2021-07-03 11:50:29

Thanks sven


Thanks - yeah, admittedly I'm probably doing something wrong. Only thing is that it was all working well but then it randomly stopped working. So I re-wrote the entire game from scratch. I though this had fixed it because it was all working - but now this new game has started glitching in exactly the same way... here's what I'm trying to do...

At the start/restart of the game, I'm setting all my variables. Some of the variable are dependent on others - so I use the Do Later to make sure that one variable is set before the other. Here's an example....

On First Draw(and on restart), Set Variable1 = 0, Do Later 500ms, Set Variable2=1

To my logic, this should set variable2 from 0 to 1 after 500ms - but what happens instead is: every 500ms, variable2 is being set to 1.

Because of this glitch - every time I try to change variable2 during the game, it will always get set to 1 after 500ms - but surely the "Do Later" should only run "On first draw (and on restart)"?

Pretty sure it has something to do with the timing - I would understand if it's processing too many variables at once, it may throw the timing out - but I can;t make sense of why it would repeat over and over.


veganpete
Registered User
Quote
2021-07-03 11:58:32

Thanks just_in_case


Sample File works perfectly. In the end, I fixed my game with your suggestion - by limiting the Do Later actions using variables/flags.

I appreciate the link for the modified Do Later script. I'll try swapping the script over to see if it fixes the initial problem and report here if it works.




just_in_case
Registered User
Quote
2021-07-03 14:37:15

hey @veganpete in the above post it seems that you never defined Variable2 = 0 i don't know if you have typing error there but it reads variable 1 = 0 not Variable2 please make sure you are not doing any typos in your game with the variable name that can also be reason that you are getting variable2 = 1 every time.

also, are you using any If a Variable has a value then do something then cross-check for example if Variabel1 = 0 then do something later 500ms set Variable2 = 1 if it is the case then you might also need to change the value of the Variable1 during runtime otherwise it will execute the action continuously.


Capt. Pong
Guest
Quote
2021-07-05 14:25:56

are you working on a browser target?
may need to flush the cache

I too on Bimbows target get odd results when changing color of overlay.
It just not updating color, and then cycling through old values.




the CopyPast Commander


VP
Guest
Quote
2021-07-05 23:38:35

Thanks CaptainPong, I'm using Windoze as a target for now.


VP
Guest
Quote
2021-07-27 10:26:25

Sven - explain this simple program for me then please....

Before First Draw (and on reload)>Do something later (2000ms)>Change Scale of Object>PlaySound (not looped)

By my logic, it should change the scale of the image once and play the sound once. It should only repeat this if the scene is restarted. When you run the program, you'll see that the image is continually rescaled and the sound repeatedly plays.

What have I done wrong if it's not a bug? *Warning - this will eventually crash your computer, so don't run it longer than a few seconds!

Thanks.

https://drive.google.com/file/d/...


sven
Registered User
Quote
2021-07-27 12:02:46

EDIT:
error is here:
ccbInvokeAction(this.ActionToDo, this.registeredFunction);
comment it out or remove the line 39 in file action_AnimateScale.js




ERROR occurs only if i use action "Animate Scale of 3D Object"

Probably error is inside this script:
action_AnimateScale.js

DoLater script is working as it should.

If i use
DoLater 500 set_variable_X+=1
and DoLater 500 set_variable_x+=1
then at the end i get result 2 (as it should)


VP
Guest
Quote
2021-07-27 17:46:10

Thanks. So the "animate scale" action has a bug for you?

For me, it's not happening just with "animate scale"; it happens with many other things such as "change position", "play sound" etc - but only when I use them in conjunction with "do something later".

If I remove the "do later" action (or use variables as flags), everything else works as it should.


sven
Registered User
Quote
2021-07-27 17:51:37

error is here:
ccbInvokeAction(this.ActionToDo, this.registeredFunction);
comment it out or remove the line 39 in file action_AnimateScale.js

Did this fix problem with scaleing bug image?
(for me bug image was scaled in and then out again as it should.)


sven
Registered User
Quote
2021-07-27 18:12:05

I made a example..
Should set variable 1+1=2
Should play sound twice
should change position of cube twice.
Thats all what it should do..

Download here and if it doesnt work for you then there is really something wrong.
https://drive.google.com/file/d/...


VP
Guest
Quote
2021-07-27 18:12:51

If I comment out line 39 as suggested, I get an error "Warning function not defined" - then nothing changes scale any more.


sven
Registered User
Quote
2021-07-27 18:16:19

VP wrote:
If I comment out line 39 as suggested, I get an error "Warning function not defined" - then nothing changes scale any more.



Did you comment it out from AnimateScale script..
(do not comment it out from do later script.)


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internation?l" (you are not logged in)


Text:

 

  

Forum 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