Everything posted by Explv
-
doorHandler not behaving as expected
You could try this as an alternative solution to DoorHandler, you pass the getDoor method an area that contains the door to distinguish it from other doors: import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.utility.ConditionalSleep; public class DoorHelper { private final Script S; public DoorHelper(final Script S){ this.S = S; } public RS2Object getDoor(Area doorArea){ //noinspection unchecked return S.getObjects().closest(obj -> obj.getName().equals("Door") && doorArea.contains(obj)); } public boolean doorIsClosed(RS2Object door){ return door.hasAction("Open"); } public void openDoor(RS2Object door){ if(door != null && doorIsClosed(door)){ door.interact("Open"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return !doorIsClosed(door); } }.sleep(); } } }
-
Launching a JavaFX Application from Script
Got it to work by doing this. Thanks dude
-
Launching a JavaFX Application from Script
Just tried: Platform.runLater(() -> ClassName.launch(ClassName.class)); But no dice, I will try your full solution now, thanks man
-
Launching a JavaFX Application from Script
Edit: Nevermind, got the error now: Caused by: java.lang.IllegalStateException: This operation is permitted on the event thread only; currentThread = pool-1-thread-2 I am having issues with launching a JavaFX application from the onStart method in Script. There is no issue with the application itself, as it works perfectly fine when called from the main method in the same class. I am launching the application using the following code, it produces "error in script onStart()", but no useful message: @Override public void onStart(){ ClassName.launch(ClassName.class); } Thanks
-
Get all the objects of in ID inside an area.
I am just using lambda expressions as it shortens your code significantly: http://tutorials.jenkov.com/java/lambda-expressions.html This: getObjects().filter(obj -> obj.getId() == ID && AREA.contains(obj)); Is equivalent to: getObjects().filter(new Filter<RS2Object>() { @Override public boolean match(RS2Object obj) { return obj.getId() == ID && AREA.contains(obj); } });
-
Bot isn't walking
You are passing it a position right walking.walk(position);
-
DoorHandler NullPointerException?
Are you sure that line is the one causing the error? There isn't anything obviously wrong with it.
-
Client can't find program to open with, java doesn't work
No problem
-
Client can't find program to open with, java doesn't work
Try this: http://osbot.org/forum/topic/87717-fixing-osbot-not-starting/
-
doorHandler
if(getMap().canReach(STAIR_AREA.getRandomPosition())){ walker.walk(STAIR_AREA.getRandomPosition(), true); } else{ doorHandler.handleNextObstacle(STAIR_AREA)); }
-
More JForm trouble
Sure, I will pm you
-
How to do this?
The simplest way to create any quest script is to use configs. When you perform some activity during a quest, a value in the configs will change. You can use these values to determine your progress in the quest, and then perform the relevant action. To see the configs, go into the Settings -> Options -> Debug -> Configs You will then see a list of numbers on your screen: The number of the left is the config ID, and the number on the right, is its current value. The value on the right will update at various points in the quest. Lets say for example, the config ID is 200, before you start the quest the value would be 200 : 0. After you talk to the cook, the config might be 200 : 20. Once you know the config value you need, you can then setup a switch in your onLoop like this: switch(getConfigs().get(200)){ case 0: talkToCook(); break; case 20: walkToCows(); break; }
-
More JForm trouble
I recommend that you learn how to do these basic Swing tasks without a GUI builder, before using a GUI builder Just create two JList<String> intialised with DefaultListModel<String> and then use model.addElement and model.remove: String[] friends = { "Noob1", "Noob2", "Noob3", "Noob4" }; DefaultListModel<String> friendsModel = new DefaultListModel<>(); for(String friend : friends){ friendsModel.addElement(friend); } JList<String> friendsList = new JList<>(friendsModel); DefaultListModel<String> foesModel = new DefaultListModel<>(); JList<String> foesList = new JList<>(foesModel); JButton addFoe = new JButton("> Foes >"); addFoe.addActionListener(e -> { for(int i : friendsList.getSelectedIndices()) foesModel.addElement(friendsModel.remove(i)); }); JButton addFriend = new JButton("< Friends <"); addFriend.addActionListener(e -> { for(int i : foesList.getSelectedIndices()) friendsModel.addElement(foesModel.remove(i)); });
-
Get all the objects of in ID inside an area.
This can be done in a shorter way: RS2Object[] objects = getObjects().filter(obj -> obj.getId() == ID && AREA.contains(obj)); Usually what you want to do is find the closest object, for example to find the closest Willow tree in a specified Area: RS2Object willowTree = getObjects().closest(obj -> obj.getName().equals("Willow") && AREA.contains(obj));
-
Game log listener
You can do this, but this example is incorrect, the argument is not a String. It should be: @Override public void onMessage(Message message){ if(e.getType() == Message.MessageType.GAME && e.getMessage().equals("A magical force stops you from moving")){ // do something } }
-
GrandExchange functions
if(getGrandExchange().getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.FINISHED_BUY) Or if you import these: import org.osbot.rs07.api.GrandExchange.Status; import org.osbot.rs07.api.GrandExchange.Box; You can just do: if(getGrandExchange().getStatus(Box.BOX_1) == Status.FINISHED_BUY)
-
onPaint()
You override the methods in Script when you want to use them, this means both the return type and parameters must be identical: @ScriptManifest(author = "", name = "", info = "", version = 0, logo = "") public class Main extends Script{ @Override public void onStart(){ } @Override public int onLoop() throws InterruptedException{ return 0; } @Override public void onPaint(Graphics2D g){ } @Override public void onExit(){ } }
-
Method to define closest NPC that isn't in combat?
I found your Filter to be written a little oddly as well Why would you do: Filter<NPC> monsterFilter = new Filter<NPC>() { @Override public boolean match(NPC n) { if (n.getId() != monsterID) return false; if(!n.getName().equals(monsterName)) return false; if(n.isUnderAttack()) return false; return true; } }; when you could just do: Filter<NPC> monsterFilter = new Filter<NPC>() { @Override public boolean match(NPC n) { return n.getName().equals("Cow") && !n.isUnderAttack(); } }; But yeah, lambdas make everything more simple anyway ^_^
-
Method to define closest NPC that isn't in combat?
Or you could just do: NPC monster = getNpcs().closest(npc -> npc.getName().equals("Cow") && !npc.isUnderAttack()); Just suppress it, the warning is for an operation that is potentially unsafe, but in this case we know it is fine. @SuppressWarnings("unchecked") NPC monster = getNpcs().closest(npc -> npc.getName().equals("Cow") && !npc.isUnderAttack()); Also with regards to your arrow method, it can be simplified to: public boolean arrowsPresent() { return getGroundItems().closest(arrowType) != null; } And it should work fine, it is probably an issue somewhere else in your code.
-
Script doesn't start
Move: gui.setVisible(true); To the end of your GUI method.
-
Explv's Dank GUI Tutorial
Yes. When the user stops the script the JFrame is disposed of if it exists. The JFrame is also hidden when the user starts the script: startButton.addActionListener(e -> { // This code is called when the user clicks the button started = true; // Set the boolean variable started to true gui.setVisible(false); // Hide the GUI }); See the line gui.setVisible(false); // Hide the GUI
-
how to check if
Intellij IDEA Darcula Theme
-
how to check if
myPosition() Just does: myPlayer().getPosition() Decompiled myPosition() declaration:
-
how to check if
NPC cow = getNpcs().closest("Cow"); if(cow.getPosition().distance(myPosition()) <= 1) // do something
-
walk() vs random path walking
Well interactions are pretty random by themselves. Also going back to path walking, if you call walk() like this: Position[] path = { new Position(0, 1, 0), new Position(0, 2, 0), new Position(0, 3, 0) }; getLocalWalker().walkPath(path); It will walk to each position in the array, but randomise each position to a distance of 1 tile. So most things are already randomised for you.