- Joined
- Dec 4, 2020
- Messages
- 5
- Thread Author
- #1
Hey folks. I'm new around here and trying my hand at putting together some bots. Not entirely new to scripting but this is getting me.
Basically, I am trying to get all reachable iron ores from a position (there should be 3), and add them into an array/list. Here is currently what the section looks like:
I am using rockSelect to keep track of which rock the player is currently mining. OreMuncher.rocks is the list I created in the main class with
When in-game, absolutely nothing happens. All other parts of my script work; world switching, retrieving the pickaxe, dropping, I'm just struggling with getting these stupid rocks into a list.
Thanks heaps folks! Let me know if you need anything more from me
Basically, I am trying to get all reachable iron ores from a position (there should be 3), and add them into an array/list. Here is currently what the section looks like:
Code:
public void execute() {
OreMuncher.rocks = GameObjects.newQuery().reachableFrom(OreMuncher.getOreLocation()).ids(11365).actions("Mine").results().asList();
if(OreMuncher.rocks.size() > 0) logText("Rocks found");
if(OreMuncher.rocks.size() > 0 && OreMuncher.getPlayer() != null && Distance.between(OreMuncher.getOreLocation(), OreMuncher.getPlayer()) < 1){
logText("Mining iron");
switch(OreMuncher.getRockSelect()){
case 0: {
OreMuncher.rockSelect++;
OreMuncher.rocks.get(OreMuncher.rockSelect).interact("Mine");
}
case 1: {
OreMuncher.rockSelect++;
OreMuncher.rocks.get(OreMuncher.rockSelect).interact("Mine");
}
case 2: {
OreMuncher.rockSelect = 0;
OreMuncher.rocks.get(OreMuncher.rockSelect).interact("Mine");
}
}
Execution.delayUntil(()->OreMuncher.getPlayer().getAnimationId() != -1, 5000);
}
else if(OreMuncher.getPlayer() != null && Distance.between(OreMuncher.getOreLocation(), OreMuncher.getPlayer()) > 1) {
logText("Moving to mining location");
Path p = RegionPath.buildTo(OreMuncher.getOreLocation());
if(p != null)
p.step();
}
else if(OreMuncher.rocks.size() == 3 && !OreMuncher.rocks.get(OreMuncher.rockSelect).isVisible())
Camera.turnTo(OreMuncher.rocks.get(OreMuncher.rockSelect));
else logText("No rocks found.");
}
I am using rockSelect to keep track of which rock the player is currently mining. OreMuncher.rocks is the list I created in the main class with
Code:
public static List<GameObject> rocks = new ArrayList<>();
When in-game, absolutely nothing happens. All other parts of my script work; world switching, retrieving the pickaxe, dropping, I'm just struggling with getting these stupid rocks into a list.
Thanks heaps folks! Let me know if you need anything more from me