Akimwarrior Designer
Posts : 30 Join date : 2011-02-27
| Subject: Timer creation and comparing it? Sun 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? | |
|
b0xb0x Administrator
Posts : 130 Join date : 2011-02-25 Age : 28 Location : California
| Subject: Re: Timer creation and comparing it? Sun 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? | |
|
Akimwarrior Designer
Posts : 30 Join date : 2011-02-27
| Subject: Re: Timer creation and comparing it? Sun 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 | |
|
b0xb0x Administrator
Posts : 130 Join date : 2011-02-25 Age : 28 Location : California
| Subject: Re: Timer creation and comparing it? Sun 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(). | |
|
Letalas Member
Posts : 5 Join date : 2011-02-25
| Subject: Re: Timer creation and comparing it? Sun 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 | |
|
Sponsored content
| Subject: Re: Timer creation and comparing it? | |
| |
|