Ambiera Forum

Discussions, Help and Support.

Create a new account, Search, or Login:
Name: Password:
Ambiera Forum > CopperCube > Programming and Scripting
Any way to make a pause?
Author Text

dekon_17
Registered User
Quote
2022-03-22 18:24:28

Yeah, might be an easy question... If only I wouldn't use the things like timeMs and getTime in my scripts. The thing is, if I would make the pause scene (pause menu), the scripts would stop probably, sure. The thing is, the time won't stop. So, if calculating something uses time, it will calculate this as if some time passed. This even includes such simple thing as DoLater action. Is there any way to bypass this problem?


Arcanjo
Guest
Quote
2022-03-23 05:29:31

Try to create a new scene of pause of Game.
The functions will not work in the previously screen when you change to another scene.


sven
Registered User
Quote
2022-03-23 10:31:40

With scripting you can do it.
I will make example if i have time..

You need to change doLater script also.. its time values needs to be sync with your Game and Pause timers..


sven
Registered User
Quote
2022-03-23 10:53:30

Press P to pause or unpause TIME.

In scripts folder you see scripts i made:
behavior_GTime
action_NEWDoLater


You see in NEW doLater i use gameTime not NOWtime.


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

This is very fast example but should give you idea how to make your own version.
This may include errors -i didnt test it 100%.


dekon_17
Registered User
Quote
2022-03-23 15:50:14

Huh... That's actually kinda smart, yet an easy solution. I think I might be able to do something like that (or maybe something similar, or without using the global variable, who knows). Thanks for help, sven, I really appreciate it.


sven
Registered User
Quote
2022-03-23 20:50:02

I edited script and added Game_Speed variable.
So it can speedUP or slowDOWN gameTIMER

//Script by sven from ambiera forum.
//for more stuff visit my youtube channel:
//https://www.youtube.com/channel/UCN3jBL46fjoVrtGnpcnCO4w
//also visit my itch page:
//https://5v3n.itch.io/

/*
<behavior jsname="behavior_GTime" description="GTime">
</behavior>
*/

//GLOBALS
Game_Timer=0;
Pause_Timer=0;
game_paused=0;
game_speed=1.0;


behavior_GTime = function()
{
this.startTime = (new Date()).getTime();
}

behavior_GTime.prototype.onAnimate = function()
{
//Now timer
var now = (new Date()).getTime() ;
//Game timer
if (game_paused==0)
{
Game_Timer = ( (now-this.startTime)-Pause_Timer) *game_speed;
}
//Pause timer
if (game_paused==1)
{
Pause_Timer = (now-this.startTime)-(Game_Timer/game_speed);
}
ccbSetSceneNodeProperty(ccbGetSceneNodeFromName("gt"), "Text", "GTime " +Game_Timer);
ccbSetSceneNodeProperty(ccbGetSceneNodeFromName("pt"), "Text", "PTimer " +Pause_Timer);
return true;
}



Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Int?rnational" (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