The Daily Click ::. Forums ::. Klik Coding Help ::. how can I randomize "the timer" ?
 

Post Reply  Post Oekaki 
 

Posted By Message

deb_J



Registered
  22/05/2015 17:52:15
Points
  10
2nd June, 2015 at 02/06/2015 09:43:24 -

Hi...I want to randomize "the timer" ...

Right now I can set to stop loading webpage in every 1 minute.
Image

but I want to randomize the time. For example, I want to Stop loading webpage between 1 to 2 minute, randomly.

how can I do it? can anyone please help me?



 
Deb

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
2nd June, 2015 at 02/06/2015 11:29:35 -

Try this and see if it works for you. You're not using the timer, you'd be using Alterable Values.



- Create an active object called "web page timer."
- Create an event that reads:
IF At Start of a given frame
THEN set Alterable Value A[web page timer] to random((60)+61)
- Create an event that reads:
IF Always
THEN Add 1 to Alterable Value B ["web page timer"]
- Another event:
IF Alterable Value A ["web page timer"] = Alterable Value B ["web page timer"]
THEN Stop loading web page



If it seems to work, then increase the numbers by as much as you want to find an appropriate time to stop loading the web page. Adding zeroes to the end of the numbers in the "Start of Frame" step would likely set things between 1 and 2 minutes. Keep it short until testing works.

 
n/a

deb_J



Registered
  22/05/2015 17:52:15
Points
  10
2nd June, 2015 at 02/06/2015 17:40:21 -


Originally Posted by s-m-r
Try this and see if it works for you. You're not using the timer, you'd be using Alterable Values.



- Create an active object called "web page timer."
- Create an event that reads:
IF At Start of a given frame
THEN set Alterable Value A[web page timer] to random((60)+61)
- Create an event that reads:
IF Always
THEN Add 1 to Alterable Value B ["web page timer"]
- Another event:
IF Alterable Value A ["web page timer"] = Alterable Value B ["web page timer"]
THEN Stop loading web page



If it seems to work, then increase the numbers by as much as you want to find an appropriate time to stop loading the web page. Adding zeroes to the end of the numbers in the "Start of Frame" step would likely set things between 1 and 2 minutes. Keep it short until testing works.



Thank you sir. its working. Thank you so much...But I need little more help...

meanwhile I was trying another way to do it so that I dont need to create program every time I want to change the timeout.
So this is what I did :-

I added "Numeric Up-Down Control" object 2 times and active object called "web page timer." like you said.

Numeric Up-Down Control and Numeric Up-Down Control 2
Image

then I set default numeric value in Numeric Up-Down Control 60 and Numeric Up-Down Control 2 - 120
Image

then I set Alterable Value Z ["web page timer"] = Random(Value( "Numeric Up-Down Control" )+Value( "Numeric Up-Down Control 2" ))
Image

Problem I am facing is, random time is taking from 0 to 60 I guess? Because webpage sometimes is getting stopped from loading within 3 second , sometimes after 15 seconds , sometimes after 6 seconds... So I guess its not taking random time between 60 to 120 seconds. Its taking from 0 to 60 or 120 I guess ! How do I make it take value between 60 to 120?

Edited by deb_J

 
Deb

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
3rd June, 2015 at 03/06/2015 02:53:51 -

Well, try changing your values to a range of 600 to 1200. I think each tick of the internal clock (as opposed to the Timer) is one millisecond or something.

I've never used the Numeric Up-Down Control Object, so I really can't help much with that.

 
n/a

deb_J



Registered
  22/05/2015 17:52:15
Points
  10
3rd June, 2015 at 03/06/2015 09:55:03 -


Originally Posted by s-m-r
Well, try changing your values to a range of 600 to 1200. I think each tick of the internal clock (as opposed to the Timer) is one millisecond or something.

I've never used the Numeric Up-Down Control Object, so I really can't help much with that.



ok. No problem. Can you please tell me how do I set random number between 60 to 120 ?

when I am setting Random((60)+120), sometimes it is taking random number 52 or 40 ...I mean its taking below 60. I want to it to take a value between 60 to 120 !

 
Deb

Fifth

Quadruped

Registered
  07/05/2003
Points
  5818

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
3rd June, 2015 at 03/06/2015 10:01:10 -

You've got the parentheses wrong there. Random((60)+120) is the same as Random(180), which is why you're still getting low values. What you want is (Random(60)+120).

Also, if you want to be precise with your timing, there are 50 frames per second by default. So a value of 50 would give you a 1-second delay. If you work out about how many seconds you want, just multiply that number by 50 and you should be good.

 
Go Moon!

deb_J



Registered
  22/05/2015 17:52:15
Points
  10
3rd June, 2015 at 03/06/2015 10:20:01 -


Originally Posted by Fifth
You've got the parentheses wrong there. Random((60)+120) is the same as Random(180), which is why you're still getting low values. What you want is (Random(60)+120).

Also, if you want to be precise with your timing, there are 50 frames per second by default. So a value of 50 would give you a 1-second delay. If you work out about how many seconds you want, just multiply that number by 50 and you should be good.



LOL...yes...I was. I was getting confused.Thank you so for your reply.


 
Deb

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
3rd June, 2015 at 03/06/2015 11:20:25 -

Whoops! My mistake in the example. Sorry about that!

 
n/a
   

Post Reply



 



Advertisement

Worth A Click