1212q Posted February 18, 2018 Share Posted February 18, 2018 (edited) Hi, I'm curious if there's any way to check if coal bag is full or not, using configs, or in any other way. Edited February 18, 2018 by 1212q Quote Link to comment Share on other sites More sharing options...
dreameo Posted February 18, 2018 Share Posted February 18, 2018 3 hours ago, 1212q said: Hi, I'm curious if there's any way to check if coal bag is full or not, using configs, or in any other way. To see if there is a config, get a list of all configs when coal bad empty, then get another list when coal is full. See if there is any differences. Not sure how well this would work. Quote Link to comment Share on other sites More sharing options...
Chase Posted February 18, 2018 Share Posted February 18, 2018 1 hour ago, dreameo said: To see if there is a config, get a list of all configs when coal bad empty, then get another list when coal is full. See if there is any differences. Not sure how well this would work. Just use the built in config debugger. Manually empty and fill the coal bag and see if any config value is changed. 1 Quote Link to comment Share on other sites More sharing options...
dreameo Posted February 18, 2018 Share Posted February 18, 2018 1 minute ago, withoutidols said: Just use the built in config debugger. Manually empty and fill the coal bag and see if any config value is changed. Not sure the size of configs but why do anything manual lol. Leave it to the b0t to figure ish out for you. Quote Link to comment Share on other sites More sharing options...
HunterRS Posted February 18, 2018 Share Posted February 18, 2018 (edited) 1 hour ago, dreameo said: Not sure the size of configs but why do anything manual lol. Leave it to the b0t to figure ish out for you. For such small things it is much quicker to manualy do it than write a script that saves the configs, fills the bag, saves configs, empties bag, saves configs. Even if you write a general script and just use a handler for the fill/empty it is much simpler to just do it manually with the debuger. Takes 2 seconds. Just my personal prefferance though. Edited February 18, 2018 by HunterRS Quote Link to comment Share on other sites More sharing options...
d0zza Posted February 18, 2018 Share Posted February 18, 2018 As far as I know there aren't any configs for the coal bag, I've used a boolean flag in the past to check if it's full or not. Quote Link to comment Share on other sites More sharing options...
1212q Posted February 19, 2018 Author Share Posted February 19, 2018 (edited) The only way I check configs is toggling the configs option in debug, but when interacting with coal bag there is no change in any config on the screen. How can I get list of configs? Edited February 19, 2018 by 1212q Quote Link to comment Share on other sites More sharing options...
liverare Posted February 19, 2018 Share Posted February 19, 2018 (edited) If no configurations changed when you emptied/filled the coal bag, then there is no way to detect whether the coal bag is emptied/filled with configurations. I'd check myself, but I don't have a coal bag. You can always use event-based checking. This is where you grab the number of coal you have in your inventory before you add/remove coal from your coal bag, then you get the new number of coal in your inventory. Calculate the difference and add/subtract that from a running coal number. Edited February 19, 2018 by liverare Quote Link to comment Share on other sites More sharing options...
battleguard Posted February 20, 2018 Share Posted February 20, 2018 Here is some code that i wrote years ago that might be of some help to you. It looks like I went with checking the message listener for when the coal bag was full you could also though count the number of times you put coal in the bag I would imagine. https://github.com/battleguard/rsbot5scripts/blob/master/rsbot5/src/com/battleguard/olderscripts/p****bot-Miner/CoalBag.java package Miner; import org.p****bot.core.event.events.MessageEvent; import org.p****bot.core.script.job.Task; import org.p****bot.core.script.job.state.Node; import org.p****bot.game.api.methods.tab.Inventory; import org.p****bot.game.api.wrappers.node.Item; public class CoalBag extends Node { public static final int COAL_BAG_ID = 18339; private static final int COAL_ID = 453; private static final String EMTPY_MSG = "Your coal bag is empty."; private static final String FULL_MSG = "Your coal bag is already full."; private static boolean inUse = false; public static boolean bagFull = false; public static final boolean setup() { return inUse = Inventory.getCount(COAL_BAG_ID) > 0; } public static final boolean isValid() { return inUse; } public static final void withdrawCoal() { RockTimer.state = "Withdrawing Coal"; final Item CoalBag = Inventory.getItem(COAL_BAG_ID); if (CoalBag != null) { if(CoalBag.getWidgetChild().interact("Withdraw-many")) { bagFull = false; } else { checkBag(); } Task.sleep(1000); } } public static final void checkBag() { RockTimer.state = "Checking Bag"; final Item CoalBag = Inventory.getItem(COAL_BAG_ID); if (CoalBag != null) { CoalBag.getWidgetChild().click(true); } } public static final void putCoalInBag() { RockTimer.state = "Adding coal to bag"; final Item CoalBag = Inventory.getItem(COAL_BAG_ID); final Item Coal = Inventory.getItem(COAL_ID); if (CoalBag != null && Coal != null) { Coal.getWidgetChild().click(true); Task.sleep(1000); CoalBag.getWidgetChild().click(true); Task.sleep(1000); } } public static final void checkMessage(final MessageEvent msg) { if (msg.getId() == 0) { if (msg.getMessage().equals(FULL_MSG)) { bagFull = true; } if (msg.getMessage().equals(EMTPY_MSG)) { bagFull = false; } } } @Override public boolean activate() { return !Banker.isDepoOpen() && Inventory.isFull() && !bagFull; } @Override public void execute() { putCoalInBag(); } } Quote Link to comment Share on other sites More sharing options...
liverare Posted February 20, 2018 Share Posted February 20, 2018 4 hours ago, battleguard said: Here is some code that i wrote years ago that might be of some help to you. It looks like I went with checking the message listener for when the coal bag was full you could also though count the number of times you put coal in the bag I would imagine. https://github.com/battleguard/rsbot5scripts/blob/master/rsbot5/src/com/battleguard/olderscripts/p****bot-Miner/CoalBag.java package Miner; import org.p****bot.core.event.events.MessageEvent; import org.p****bot.core.script.job.Task; import org.p****bot.core.script.job.state.Node; import org.p****bot.game.api.methods.tab.Inventory; import org.p****bot.game.api.wrappers.node.Item; public class CoalBag extends Node { public static final int COAL_BAG_ID = 18339; private static final int COAL_ID = 453; private static final String EMTPY_MSG = "Your coal bag is empty."; private static final String FULL_MSG = "Your coal bag is already full."; private static boolean inUse = false; public static boolean bagFull = false; public static final boolean setup() { return inUse = Inventory.getCount(COAL_BAG_ID) > 0; } public static final boolean isValid() { return inUse; } public static final void withdrawCoal() { RockTimer.state = "Withdrawing Coal"; final Item CoalBag = Inventory.getItem(COAL_BAG_ID); if (CoalBag != null) { if(CoalBag.getWidgetChild().interact("Withdraw-many")) { bagFull = false; } else { checkBag(); } Task.sleep(1000); } } public static final void checkBag() { RockTimer.state = "Checking Bag"; final Item CoalBag = Inventory.getItem(COAL_BAG_ID); if (CoalBag != null) { CoalBag.getWidgetChild().click(true); } } public static final void putCoalInBag() { RockTimer.state = "Adding coal to bag"; final Item CoalBag = Inventory.getItem(COAL_BAG_ID); final Item Coal = Inventory.getItem(COAL_ID); if (CoalBag != null && Coal != null) { Coal.getWidgetChild().click(true); Task.sleep(1000); CoalBag.getWidgetChild().click(true); Task.sleep(1000); } } public static final void checkMessage(final MessageEvent msg) { if (msg.getId() == 0) { if (msg.getMessage().equals(FULL_MSG)) { bagFull = true; } if (msg.getMessage().equals(EMTPY_MSG)) { bagFull = false; } } } @Override public boolean activate() { return !Banker.isDepoOpen() && Inventory.isFull() && !bagFull; } @Override public void execute() { putCoalInBag(); } } You should really make a coal bag API as apposed to shoving it into a task node. That way, it's a little more maintainable and, if it proves flawless, it could perhaps make it into the official API to then be maintained by the developers and scriptwriters. Here's a 10 minute example of me taking what you wrote and scribbling out an API: import org.osbot.rs07.api.model.Item; import org.osbot.rs07.api.ui.Message; import org.osbot.rs07.api.ui.Message.MessageType; import org.osbot.rs07.listener.MessageListener; import org.osbot.rs07.script.API; import org.osbot.rs07.utility.ConditionalSleep; public class CoalBagAPI extends API implements MessageListener { /** * Maximum amount of coal that can be stored in the coal bag when the user is * not wearing a smithing cape. */ public static final int STORAGE_COUNT = 27; /** * Maximum amount of coal that can be stored in the coal bag when the user is * wearing a smithing cape. */ public static final int STORAGE_COUNT_SMITHING_CAPE = 36; /** * Smithing cape increases the size capacity of the coal bag. */ private boolean usingSmithingCape; /** * Keep a running tally of the amount of coal stored in the coal bag. */ private int storedCoalAmount; @Override public void initializeModule() { bot.addMessageListener(this); usingSmithingCape = equipment.contains("Smithing cape"); } @Override public void onMessage(Message messageObj) throws InterruptedException { String messageText = messageObj.getMessage(); /* Check whether message is from the game */ if (messageObj.getType().equals(MessageType.GAME)) { /* Check the message contents */ if (messageText != null) { switch (messageText) { /* Set counter to 0 */ case "Your coal bag is empty.": storedCoalAmount = 0; break; /* Set counter to max storage value */ case "Your coal bag is already full.": storedCoalAmount = (usingSmithingCape ? STORAGE_COUNT_SMITHING_CAPE : STORAGE_COUNT); break; } } } } public boolean isUsingSmithingCape() { return usingSmithingCape; } public void setUsingSmithingCape(boolean usingSmithingCape) { this.usingSmithingCape = usingSmithingCape; } public int getStoredCoalAmount() { return storedCoalAmount; } public void setStoredCoalAmount(int storedCoalAmount) { this.storedCoalAmount = storedCoalAmount; } public boolean isFull() { return usingSmithingCape ? storedCoalAmount == STORAGE_COUNT_SMITHING_CAPE : storedCoalAmount == STORAGE_COUNT; } public boolean isEmpty() { return storedCoalAmount == 0; } public int getRemainingSpace() { return usingSmithingCape ? (STORAGE_COUNT_SMITHING_CAPE - storedCoalAmount) : (STORAGE_COUNT - storedCoalAmount); } private int getCoalAmount() { return (int) inventory.getAmount("Coal"); } private Item getCoalBag() { return inventory.getItem("Coal bag"); } public boolean fill() throws InterruptedException { boolean successful = false; Item coalBag = getCoalBag(); int invCoalCount = getCoalAmount(); int remainingSpace = getRemainingSpace(); int amountToBeStored = 0; ConditionalSleep sleepUntilCoalAddedToBag = null; if (coalBag == null) { /* Don't bother returning true/false */ throw new InterruptedException("No coal bag found!"); } else if (invCoalCount > 0 && remainingSpace > 0) { /* Calculate the difference for when you store the coal */ amountToBeStored = (invCoalCount - remainingSpace); /* Try to fill the coal bag */ if (coalBag.interact("Fill")) { /* Sleep for 3.5 seconds (3500) */ sleepUntilCoalAddedToBag = new ConditionalSleep(3500) { @Override public boolean condition() throws InterruptedException { /* Wake up when the coal has been added */ return getCoalAmount() != invCoalCount; } }; /* It shouldn't take us 3.5 seconds to check whether the bag's been filled */ if (sleepUntilCoalAddedToBag.sleep()) { storedCoalAmount += amountToBeStored; successful = true; } } } return successful; } public boolean empty() throws InterruptedException { boolean successful = false; Item coalBag = getCoalBag(); int remainingSpace = inventory.getEmptySlotCount(); int amountToBeWithdrawn = 0; ConditionalSleep sleepUntilCoalRemovedFromBag = null; if (coalBag == null) { /* Don't bother returning true/false */ throw new InterruptedException("No coal bag found!"); } else if (storedCoalAmount > 0 && remainingSpace > 0) { /* Figure out how much inventory space we're about to lose */ amountToBeWithdrawn = Math.min(storedCoalAmount, remainingSpace); /* Try to fill the coal bag */ if (coalBag.interact("Empty")) { /* Sleep for 3.5 seconds (3500) */ sleepUntilCoalRemovedFromBag = new ConditionalSleep(3500) { @Override public boolean condition() throws InterruptedException { /* Wake up when the coal has been added */ return inventory.getEmptySlotCount() != remainingSpace; } }; /* It shouldn't take us 3.5 seconds to check whether the bag's been filled */ if (sleepUntilCoalRemovedFromBag.sleep()) { storedCoalAmount -= amountToBeWithdrawn; successful = true; } } } return successful; } /** * TODO ... * @return * @throws InterruptedException */ public boolean check() throws InterruptedException { return false; } } 3 Quote Link to comment Share on other sites More sharing options...