Cyber Syndicate
<center><p style='font-size:120%;'><strong>Welcome to Cyber Syndicate!<strong></p>

You are visiting as a guest; please <strong>register</strong> or <strong>log in</strong>.

Being logged in provides many benefits, including access to the useful <strong>Methods forum</strong>, posting permissions, and voting permissions.

<strong>Enjoy.</strong></center>
Cyber Syndicate
<center><p style='font-size:120%;'><strong>Welcome to Cyber Syndicate!<strong></p>

You are visiting as a guest; please <strong>register</strong> or <strong>log in</strong>.

Being logged in provides many benefits, including access to the useful <strong>Methods forum</strong>, posting permissions, and voting permissions.

<strong>Enjoy.</strong></center>
Cyber Syndicate
Would you like to react to this message? Create an account in a few clicks or log in to continue.



 
HomeLatest imagesRegisterLog in

 

 Timer creation and comparing it?

Go down 
3 posters
AuthorMessage
Akimwarrior
Designer
Designer



Posts : 30
Join date : 2011-02-27

Timer creation and comparing it? Empty
PostSubject: Timer creation and comparing it?   Timer creation and comparing it? Icon_minitimeSun Feb 27, 2011 11:52 am

I want to create a Timer that starts when a certain action is complete.
But after that i want to compare the time.. but how do i do that?
Back to top Go down
b0xb0x
Administrator
Administrator



Posts : 130
Join date : 2011-02-25
Age : 28
Location : California

Timer creation and comparing it? Empty
PostSubject: Re: Timer creation and comparing it?   Timer creation and comparing it? Icon_minitimeSun Feb 27, 2011 12:02 pm

To create a timer, you can use
Code:
Timer timer = new Timer(int millis);
To start it when a certain action is complete, depending on the action, you can put the action checker in the loop, and then do
Code:
if (actionToLookFor) timer.reset();
To compare the time, do you mean with the time the script has been running?
Back to top Go down
https://cybersyndicate.forumotion.com
Akimwarrior
Designer
Designer



Posts : 30
Join date : 2011-02-27

Timer creation and comparing it? Empty
PostSubject: Re: Timer creation and comparing it?   Timer creation and comparing it? Icon_minitimeSun Feb 27, 2011 12:09 pm

I plant my herb
and exactly 75min later it will be done

so: plant herb --> start timer
timer done --> tele to spot and pick
Back to top Go down
b0xb0x
Administrator
Administrator



Posts : 130
Join date : 2011-02-25
Age : 28
Location : California

Timer creation and comparing it? Empty
PostSubject: Re: Timer creation and comparing it?   Timer creation and comparing it? Icon_minitimeSun Feb 27, 2011 12:16 pm

After you have created the Timer in your variable declaration, you can do it. Where you have your method for for planting herbs, right after your plant action, do timer.reset().
Back to top Go down
https://cybersyndicate.forumotion.com
Letalas
Member
Member



Posts : 5
Join date : 2011-02-25

Timer creation and comparing it? Empty
PostSubject: Re: Timer creation and comparing it?   Timer creation and comparing it? Icon_minitimeSun Feb 27, 2011 1:39 pm

I recently did something similar; except what I did was I got the system time when it was planted and stored it, then when checking back all I had to do was basically currentTime - startTime

Code:
startTime = System.currentTimeMillis();

public int timeRemaining(){  //in seconds
   return (growTime - (int)(System.currentTimeMillis() - startTime)/1000);
}

Not tested just an example of what I did.

There is also the full timer class of rsbuddy, http://ve.vsm6ds6m.vesrv.com/doc/com/rsbuddy/script/util/Timer.html
Back to top Go down
Sponsored content





Timer creation and comparing it? Empty
PostSubject: Re: Timer creation and comparing it?   Timer creation and comparing it? Icon_minitime

Back to top Go down
 
Timer creation and comparing it?
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Cyber Syndicate :: Development :: Scripting Help-
Jump to: