Jeune Padawan Posted March 5, 2017 Share Posted March 5, 2017 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: 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. Quote Link to comment Share on other sites More sharing options...
k9thebeast Posted March 5, 2017 Share Posted March 5, 2017 @Override public void onMessage(Message message) { String messageText = message.getMessage(); } This is the correct syntax for overiding the onMessage() method. Also there is no need to cast the graphics, you can just do Graphics2D gr = g; Quote Link to comment Share on other sites More sharing options...
Jeune Padawan Posted March 5, 2017 Author Share Posted March 5, 2017 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 >_> Quote Link to comment Share on other sites More sharing options...
Juggles Posted March 5, 2017 Share Posted March 5, 2017 Ghetto way is to do (xpGained/XpPerLog)/hour or you can keep track of logs gained in inventory Quote Link to comment Share on other sites More sharing options...
Jeune Padawan Posted March 5, 2017 Author Share Posted March 5, 2017 (edited) 2 minutes ago, Juggles said: Ghetto way is to do (xpGained/XpPerLog)/hour or you can keep track of logs gained in inventory I do not know how to do neither. It's not explained in Explv's guide Edited March 5, 2017 by Jeune Padawan Quote Link to comment Share on other sites More sharing options...
Apaec Posted March 5, 2017 Share Posted March 5, 2017 (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: 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: 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 March 5, 2017 by Apaec 1 Quote Link to comment Share on other sites More sharing options...
Jeune Padawan Posted March 5, 2017 Author Share Posted March 5, 2017 (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 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. 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 : 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 Edited March 5, 2017 by Jeune Padawan 1 Quote Link to comment Share on other sites More sharing options...
Explv Posted March 5, 2017 Share Posted March 5, 2017 (edited) 9 minutes ago, Jeune Padawan said: He also says that for showing the exp, you gotta do this : 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 March 5, 2017 by Explv 1 Quote Link to comment Share on other sites More sharing options...
Jeune Padawan Posted March 5, 2017 Author Share Posted March 5, 2017 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. Quote Link to comment Share on other sites More sharing options...
Apaec Posted March 5, 2017 Share Posted March 5, 2017 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 Quote Link to comment Share on other sites More sharing options...
Jeune Padawan Posted March 5, 2017 Author Share Posted March 5, 2017 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 Quote Link to comment Share on other sites More sharing options...
Apaec Posted March 6, 2017 Share Posted March 6, 2017 10 hours ago, Jeune Padawan said: 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 ExperienceTracker tracks experience - https://osbot.org/api/org/osbot/rs07/api/util/ExperienceTracker.html Quote Link to comment Share on other sites More sharing options...