Jump to content

Struggling with a bit of logic


atoo

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...