Jump to content

Struggling with a bit of logic


Recommended Posts

Posted (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 by atoo
Posted (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 by roguehippo
  • Like 1
Posted
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...

Posted
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 

Posted

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.

 

  • Like 1

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...