Jump to content

Idle timer


Mushphang
 Share

Recommended Posts

Hi all,

 

basically my script does things after its been idle for too long. I've tried multiple things on this idle timer and I can't seem to get it to function properly. On script start it works properly, but after grabbing an item, this idle function no longer starts ticking the idle timer. 

			if (!myPlayer().isMoving() && item == null) {
				logB = "Idle";
				newTime = (System.currentTimeMillis() - idleTime);
				if (newTime >= 30000) {
					//stuff
                                        idleTime = (System.currentTimeMillis());
				}
			}

the item should/is updating everytime the state loops

Edited by Mushphang
Link to comment
Share on other sites

Hi all,

 

basically my script does things after its been idle for too long. I've tried multiple things on this idle timer and I can't seem to get it to function properly. On script start it works properly, but after grabbing an item, this idle function no longer starts ticking the idle timer. 

			if (!myPlayer().isMoving() && item == null) {
				logB = "Idle";
				newTime = (System.currentTimeMillis() - idleTime);
				if (newTime >= 30000) {
					//stuff
                                        idleTime = (System.currentTimeMillis());
				}
			}

the item should/is updating everytime the state loops

 

Problem could be the item not being null but the player not moving. Don't really know the specifics for this but what I usually do is:

 

	if (myPlayer().isMoving()) {
             // Reset the timer if the player is moving
             idleTime = System.currentTimeMillis();
        } 
         
        newTime = (System.currentTimeMillis() - idleTime);
        if (newTime >= 30000) {
           //stuff
           idleTime = (System.currentTimeMillis());
         }
			

If everything is going well, reset the idleTime. If things are not going well then it will do something after 30 seconds and reset the timer

Edited by nosepicker
  • Like 2
Link to comment
Share on other sites

Problem could be the item not being null but the player not moving. Don't really know the specifics for this but what I usually do is:

 

	if (myPlayer().isMoving()) {
             // Reset the timer if the player is moving
             idleTime = System.currentTimeMillis();
        } 
         
        newTime = (System.currentTimeMillis() - idleTime);
        if (newTime >= 30000) {
           //stuff
           idleTime = (System.currentTimeMillis());
         }
			

If everything is going well, reset the idleTime. If things are not going well then it will do something after 30 seconds and reset the timer

 

Will test it out! Thanks smile.png

 

So far so good, can't believe I was stumped on it for so long when it was that easy of a fix. Got so fixated on !myPlayer.isMoving() I guess.

Edited by Mushphang
Link to comment
Share on other sites

Here's what i use to keep my mule logged in. I just set it to move the camera every 250 seconds. 

 public void onStart() {       
        timer = System.currentTimeMillis();
 }
 
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ case code 
 if(System.currentTimeMillis() - timer >= 250000) {
        status = "moving camera";
        int currentYaw = getCamera().getYawAngle();
        getCamera().moveYaw(currentYaw + (random(-50, 70)));
        timer = System.currentTimeMillis();
 }

Could use a failsafe incase the degrees changed = 0. Worst case scenario it gets logged out and osbot logs it back in and continues. 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...