atoo Posted October 22, 2017 Share Posted October 22, 2017 (edited) So im doing a multi location script for mining, ive added 2 locations so far for testing purpose but i is there some simplier way to make the bot listen to different locations? at the moment im doing things like these. Didnt look into someone else code because i dont want to paste, but if someone can give me a tip i'd appreciate it //example check if(skillgui.getOre() == "COAL" && skillgui.getArea() == "BarbVillage") { if(!getInventory().contains(item -> item.getName().contains("pickaxe"))) { if(!coalBankArea.contains(myPlayer())) getWalking().webWalk(coalBankArea.getRandomPosition()); if(coalBankArea.contains(myPlayer())) { if (!getBank().isOpen()) getBank().open(); else getBank().withdraw(item -> item.getName().contains("pickaxe"), 1); } } //example check 2 //doing the same thing cuz my logic is shit if(skillgui.getOre() == "TIN" && skillgui.getArea() == "OutVarrock") { if(!getInventory().contains(item -> item.getName().contains("pickaxe"))) { //possible to replace bankAreaVarrock with the thing we choose in our combobox? if(!bankAreaVarrock.contains(myPlayer())) getWalking().webWalk(bankAreaVarrock.getRandomPosition()); if(bankAreaVarrock.contains(myPlayer())) { if (!getBank().isOpen()) getBank().open(); else getBank().withdraw(item -> item.getName().contains("pickaxe"), 1); } } Edited October 22, 2017 by atoo Quote Link to comment Share on other sites More sharing options...
roguehippo Posted October 22, 2017 Share Posted October 22, 2017 (edited) what if you just stored the values in a HashMap in your main code with the key being the string name ex: outVarrock, barbVillage and the value would be the Area. then you can just do Area areaIWantTOWalkTo = hashmap.at(gui.getArea()); but im not really sure if i understood the question. are you trying to make checking which area the bot wants to mine in once or many times? might have got some syntaxt stuff wrong but i think a hashmap would be helpful. Edited October 22, 2017 by roguehippo 1 Quote Link to comment Share on other sites More sharing options...
HunterRS Posted October 22, 2017 Share Posted October 22, 2017 Just now, roguehippo said: what if you just stored the values in a HashMap in your main code with the key being the string name ex: outVarrock, barbVillage and the value would be the Area. then you can just do Area areaIWantTOWalkTo = hashmap.at(gui.getArea()); might have got some syntaxt stuff wrong but i think a hashmap would be helpful. Hash map of String, Area would work. You can also define a general area after the gui closes (miningArea) and use that in you check. if you are planning on having many locations I would go with the hashmap though... Quote Link to comment Share on other sites More sharing options...
atoo Posted October 22, 2017 Author Share Posted October 22, 2017 18 minutes ago, HunterRS said: Hash map of String, Area would work. You can also define a general area after the gui closes (miningArea) and use that in you check. if you are planning on having many locations I would go with the hashmap though... Ye i want to have a lot of locations, at the moment as my poop snippet showed is that im doing the same code over and over with just a if check of what ore/area i have choosed in my comboBox. 25 minutes ago, roguehippo said: what if you just stored the values in a HashMap in your main code with the key being the string name ex: outVarrock, barbVillage and the value would be the Area. then you can just do Area areaIWantTOWalkTo = hashmap.at(gui.getArea()); but im not really sure if i understood the question. are you trying to make checking which area the bot wants to mine in once or many times? might have got some syntaxt stuff wrong but i think a hashmap would be helpful. Exactly like that, thanks. Will look into it Quote Link to comment Share on other sites More sharing options...
HunterRS Posted October 22, 2017 Share Posted October 22, 2017 well they try something like this: Define your hashmap private HashMap<String, Area> miningLocationsMap = new HashMap<String, Area>(); Add values to the map in the onstart miningLocationsMap.put("Varrock", new Area(0,0,0,0)); etc.... and finaly, define your mining location: String locationString = skillgui.getArea(); Area miningLocation = miningLocationsMap.get(locationString); 2 minutes ago, atoo said: Ye i want to have a lot of locations, at the moment as my poop snippet showed is that im doing the same code over and over with just a if check of what ore/area i have choosed in my comboBox. 1 Quote Link to comment Share on other sites More sharing options...
atoo Posted October 22, 2017 Author Share Posted October 22, 2017 (edited) My game just freezes when i initialize this? String locations = skillgui.getArea(); Area miningAreas = miningLocationsMap.get(locations); nvm, i think i found the issue. Edited October 22, 2017 by atoo Quote Link to comment Share on other sites More sharing options...