Jump to content

How to show x number of logs chopped?


Recommended Posts

Posted

Yo. Basically, I'm making a very simple woodcutting script and I'm working a bit on the paint right now. So far, I got the "Elapsed Time" working good. For the number of logs chopped, I declared the "int logsChopped = 0" variable at the top of the script. Then, in the onPaint, here's what I have:

5J2mNZX.png

Problem is, first, why the hell is the "gr" underlined at line 74?

Second, I thought it would add +1 to the number of logs chopped every time it saw the message "You get some some logs." in the chat. However, it is not.

Also, what would I have to write if I wanted my bot to close the bank window with the "x" button at the top right?

 

Thanks a lot.

Posted (edited)
27 minutes ago, Jeune Padawan said:

Yo. Basically, I'm making a very simple woodcutting script and I'm working a bit on the paint right now. So far, I got the "Elapsed Time" working good. For the number of logs chopped, I declared the "int logsChopped = 0" variable at the top of the script. Then, in the onPaint, here's what I have:

5J2mNZX.png

Problem is, first, why the hell is the "gr" underlined at line 74?

Second, I thought it would add +1 to the number of logs chopped every time it saw the message "You get some some logs." in the chat. However, it is not.

Also, what would I have to write if I wanted my bot to close the bank window with the "x" button at the top right?

 

Thanks a lot.

A few things here.

Firstly, it's most likely underlined as it is an unused variable (no idea what you were expecting that line to do!?) - nowhere in your onPaint are you using 'gr'. You can safely delete that whole line.

Secondly, the way your paint is displaying it should correctly show your logsChopped variable, so your issue is with the onMessage. A brief look at the API sees onMessage has a Message parameter rather than a String parameter. However it is also worth considering that if a player were to type "You get some logs.", your counter will be incremented!

Finally, the bank#close() method will use escape if you've got 'esc to close interfaces' configured in your game settings. If 'esc to close interfaces' is off in your game settings, then the close() method will use the 'X'.

Hope that helps!

~apa

 

16 minutes ago, Jeune Padawan said:

bxUQb1r.png

 

I highly doubt I did it correctly with the message. It also seems like I couldn't put it in an if statement.

 

The "gr" is still underlined >_>

try:

public void onMessage(final Message m) {
		String msg = m.getMessage().toLowerCase();
  		if (m.getType().equals(MessageType.GAME) && msg.contains("you get some logs")) logsChopped++;
}

:)

Edited by Apaec
  • Like 1
Posted (edited)
30 minutes ago, Apaec said:

A few things here.

Firstly, it's most likely underlined as it is an unused variable (no idea what you were expecting that line to do!?) - nowhere in your onPaint are you using 'gr'. You can safely delete that whole line.

Secondly, the way your paint is displaying it should correctly show your logsChopped variable, so your issue is with the onMessage. A brief look at the API sees onMessage has a Message parameter rather than a String parameter. However it is also worth considering that if a player were to type "You get some logs.", your counter will be incremented!

Finally, the bank#close() method will use escape if you've got 'esc to close interfaces' configured in your game settings. If 'esc to close interfaces' is off in your game settings, then the close() method will use the 'X'.

Hope that helps!

~apa

 

try:


public void onMessage(final Message m) {
		String msg = m.getMessage().toLowerCase();
  		if (m.getType().equals(MessageType.GAME) && msg.contains("you get some logs")) logsChopped++;
}

:)

 

Nice :D This works perfectly now. As for the xp per hour? How the hell do I do that? I tried doing it Pugs' way but it's not working.

 

iRaxZyz.png

 

I declared private int logsPerHour and totalLogsPerHour at the beginning of the script. Idk how to implement it >_> Pug's code seems like it's outdated compared to Explv's but he's not talking about any thing /per hour in this paint guide.

He also says that for showing the exp, you gotta do this : 

mdLGnqR.png

How do I call this in the paint?  g.drawString("XP Earned: "  + formatValue( what do I put here ? ), 10, 330);  

Thanks for the quick help. Really nice. 

P.S. getBank().close(); worked great with esc turned off! It closes with the x button now :D

Edited by Jeune Padawan
  • Like 1
Posted (edited)
9 minutes ago, Jeune Padawan said:

 

He also says that for showing the exp, you gotta do this : 

mdLGnqR.png

How do I call this in the paint?  g.drawString("XP Earned: "  + formatValue( what do I put here ? ), 10, 330);  

Thanks for the quick help. Really nice. 

 

For xp, like I show in my paint tutorial, you use the XP tracker.

In onStart() call:

getExperienceTracker().start(Skill.WOODCUTTING);

Then in your paint:

g.drawString("XP Gained: " + formatValue(getExperienceTracker().getGainedXP(Skill.WOODCUTTING)), x, y);

Or for xp/hour you can use

getExperienceTracker().getGainedXPPerHour(Skill.WOODCUTTING)

 

Edited by Explv
  • Like 1
Posted
12 minutes ago, Explv said:

 

For xp, like I show in my paint tutorial, you use the XP tracker.

In onStart() call:


getExperienceTracker().start(Skill.WOODCUTTING);

Then in your paint:


g.drawString("XP Gained: " + formatValue(getExperienceTracker().getGainedXP(Skill.WOODCUTTING)), x, y);

Or for xp/hour you can use


getExperienceTracker().getGainedXPPerHour(Skill.WOODCUTTING)

 

Wow this works perfectly. Your way of doing it is way easier than the other ways. Is there a way of doing that for items picked up? Like logs or something?

 

Thanks a lot for the help.

Posted
54 minutes ago, Jeune Padawan said:

Wow this works perfectly. Your way of doing it is way easier than the other ways. Is there a way of doing that for items picked up? Like logs or something?

 

Thanks a lot for the help.

ExperienceTracker is a class in the API https://osbot.org/api/org/osbot/rs07/api/util/ExperienceTracker.html , you can see the available methods to you. As a result you should be able to determine that you will need to write your own "per hour" method for the logs per hour.

See if you can figure out how to write this by yourself, to start you off here is an empty method you can work with:

private int getPerHour(Timer t, int val) {
  // Code here!
  return -1;
}

Where Timer is your timer class, assuming you're using one (or similar). If not, perhaps change that to the time elapsed since the script start (as a long value).

Ofcourse you will need to replace the -1!

Let me know if you're still stuck :)

~apa

Posted
11 minutes ago, Apaec said:

ExperienceTracker is a class in the API https://osbot.org/api/org/osbot/rs07/api/util/ExperienceTracker.html , you can see the available methods to you. As a result you should be able to determine that you will need to write your own "per hour" method for the logs per hour.

See if you can figure out how to write this by yourself, to start you off here is an empty method you can work with:


private int getPerHour(Timer t, int val) {
  // Code here!
  return -1;
}

Where Timer is your timer class, assuming you're using one (or similar). If not, perhaps change that to the time elapsed since the script start (as a long value).

Ofcourse you will need to replace the -1!

Let me know if you're still stuck :)

~apa

Isn't this only for tracking experience? Or can I use the experienceTracker for items? Seems weird or I probably misread what you said lol

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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