Mocro Posted September 28, 2015 Share Posted September 28, 2015 (edited) i want to have cutted willow : 202 but it wont work for me. g.drawString("Cut : "+ this.cuttedwood , 15, 88); someone got a code for it. Based on added xp. Edited September 28, 2015 by Mocro Quote Link to comment Share on other sites More sharing options...
Mocro Posted September 28, 2015 Author Share Posted September 28, 2015 Wouldn't it be "cut" not "cutted" ? Happy? Quote Link to comment Share on other sites More sharing options...
Apaec Posted September 28, 2015 Share Posted September 28, 2015 (edited) Wouldn't it be "cut" not "cutted" ? It's a variable name - it could be named 'dickcheese' for all we care and it would still work @OP It's very hard to tell what's wrong with that line without seeing how you're manipulating the variable. Care to post some further code snippets where you change it's value? lemme write some sort of example if you want to do it via exp. a message listener would probably be a better way but exp works too ;p //global vars private int woodCut = 0; //ini //onstart experienceTracker.startAll(); //global methods private int getChoppedLogs(int expPerLog) { return (experienceTracker.getGainedXp(Skill.WOODCUTTING) / expPerLog); } //onpaint method: graphics.drawString("Logs chopped: " + getChoppedLogs(40), 0, 0); //where graphics is ur graphics2d, 40 is the exp per log, and 0,0 are the co-ords for string wrote it in the reply box so sorry if there are any errors Edited September 28, 2015 by Apaec Quote Link to comment Share on other sites More sharing options...
Lemons Posted September 28, 2015 Share Posted September 28, 2015 (edited) The way I prefer to do inventory tracking is to compare a "last inventory" with the present inventory, and compare the differences. I wrote up some quick, untested code (it's based off my full accounting code, linked at the end). If it doesn't work let me know, but basically you'll call compareItems() whenever you want to be checking for changes in items (aka during woodcutting), and resetItems() whenever you bank. Code is in spoiler: // WARNING: Untested code /** Holds the amount of willows we have cut */ private int willowsCut = 0; /** Holds the last inventory that was compared */ private Item[] lastInv; /** * Simple getter * @return the number of willows cut */ public int getWillowsCut() { return willowsCut; } /** * Compares your last inventory with the current inventory. */ public void compareItems() { if (lastInv == null) { lastInv = getInventory().getItems(); return; // It will be the same, no need to check } String item = "Willow logs"; Item[] currInv = getInventory().getItems(); for (int i = 0; i < 28; i++) { // Check for the same thing if ((currInv[i] == null && lastInv == null) || currInv[i].getName().equals(lastInv[i].getName())) continue; // Its the same, continue if (currInv[i] != null) { // We have an item when we didn't if (currInv[i].getName().equals(item)) willowsCut++; // It was a willow log, ++ } else { // We don't have an item when we did if (lastInv[i].getName().equals(item)) willowsCut--; // It was a willow log, -- } } lastInv = currInv; // Update the inv } /** * Run this when the lastInv needs refreshing, aka after banking */ public void resetItems() { lastInv = getInventory().getItems(); } And a link to pastebin since there is no syntax coloring here(?): http://pastebin.com/ZUYr6rEH Edit: There is, but I'll leave this here regardless And here is a link to my full accounting code (sorry its mixed in with the paint). Its used in my API so it won't be the easiest port, but the general idea is there: https://github.com/Lem0ns/OSBotAPI/blob/master/painters/GenericPainter.java#L501 Edited September 28, 2015 by Lemons 1 Quote Link to comment Share on other sites More sharing options...
miuchiz mons Posted September 28, 2015 Share Posted September 28, 2015 off topic, but how did you learn to code? and how long did it take you? Quote Link to comment Share on other sites More sharing options...
Apaec Posted September 29, 2015 Share Posted September 29, 2015 off topic, but how did you learn to code? and how long did it take you? If you want to learn yourself http://osbot.org/forum/topic/58775-a-beginners-guide-to-writing-osbot-scripts-where-to-get-started-by-apaec/ gl 1 Quote Link to comment Share on other sites More sharing options...
Mocro Posted September 30, 2015 Author Share Posted September 30, 2015 It's a variable name - it could be named 'dickcheese' for all we care and it would still work @OP It's very hard to tell what's wrong with that line without seeing how you're manipulating the variable. Care to post some further code snippets where you change it's value? lemme write some sort of example if you want to do it via exp. a message listener would probably be a better way but exp works too ;p //global vars private int woodCut = 0; //ini //onstart experienceTracker.startAll(); //global methods private int getChoppedLogs(int expPerLog) { return (experienceTracker.getGainedXp(Skill.WOODCUTTING) / expPerLog); } //onpaint method: graphics.drawString("Logs chopped: " + getChoppedLogs(40), 0, 0); //where graphics is ur graphics2d, 40 is the exp per log, and 0,0 are the co-ords for string wrote it in the reply box so sorry if there are any errors Thanks The way I prefer to do inventory tracking is to compare a "last inventory" with the present inventory, and compare the differences. I wrote up some quick, untested code (it's based off my full accounting code, linked at the end). If it doesn't work let me know, but basically you'll call compareItems() whenever you want to be checking for changes in items (aka during woodcutting), and resetItems() whenever you bank. Code is in spoiler: // WARNING: Untested code /** Holds the amount of willows we have cut */ private int willowsCut = 0; /** Holds the last inventory that was compared */ private Item[] lastInv; /** * Simple getter * @return the number of willows cut */ public int getWillowsCut() { return willowsCut; } /** * Compares your last inventory with the current inventory. */ public void compareItems() { if (lastInv == null) { lastInv = getInventory().getItems(); return; // It will be the same, no need to check } String item = "Willow logs"; Item[] currInv = getInventory().getItems(); for (int i = 0; i < 28; i++) { // Check for the same thing if ((currInv[i] == null && lastInv == null) || currInv[i].getName().equals(lastInv[i].getName())) continue; // Its the same, continue if (currInv[i] != null) { // We have an item when we didn't if (currInv[i].getName().equals(item)) willowsCut++; // It was a willow log, ++ } else { // We don't have an item when we did if (lastInv[i].getName().equals(item)) willowsCut--; // It was a willow log, -- } } lastInv = currInv; // Update the inv } /** * Run this when the lastInv needs refreshing, aka after banking */ public void resetItems() { lastInv = getInventory().getItems(); } And a link to pastebin since there is no syntax coloring here(?): http://pastebin.com/ZUYr6rEH Edit: There is, but I'll leave this here regardless And here is a link to my full accounting code (sorry its mixed in with the paint). Its used in my API so it won't be the easiest port, but the general idea is there: https://github.com/Lem0ns/OSBotAPI/blob/master/painters/GenericPainter.java#L501 awsome off topic, but how did you learn to code? and how long did it take you? Youtube Java coding allot of people have tuts It's a variable name - it could be named 'dickcheese' for all we care and it would still work @OP It's very hard to tell what's wrong with that line without seeing how you're manipulating the variable. Care to post some further code snippets where you change it's value? lemme write some sort of example if you want to do it via exp. a message listener would probably be a better way but exp works too ;p //global vars private int woodCut = 0; //ini //onstart experienceTracker.startAll(); //global methods private int getChoppedLogs(int expPerLog) { return (experienceTracker.getGainedXp(Skill.WOODCUTTING) / expPerLog); } //onpaint method: graphics.drawString("Logs chopped: " + getChoppedLogs(40), 0, 0); //where graphics is ur graphics2d, 40 is the exp per log, and 0,0 are the co-ords for string wrote it in the reply box so sorry if there are any errors I need the exp to get it automaticly is that possible getChoppedLogs(40), Quote Link to comment Share on other sites More sharing options...