Botre Posted July 21, 2015 Share Posted July 21, 2015 I'm working on an extremely high-level API that sits on top of the OSBot API, makes it a bit more beginner friendly and adds plenty of shortcuts. Here's how a simple pickpocketer looks like (works flawlessly): import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.ScriptManifest; /** * Created by Bjorn on 21/07/2015. */ @ScriptManifest(author = "Botre", info = "", logo = "", name = "PPS", version = 0.0) public class PickpocketScript extends BasicScript { private EntityDefinition definition = new EntityDefinition(this) .name("Man") .action("Pickpocket") .reachable(); private Target<NPC> target = new Target<>(definition, Searcher.closest(this, definition)); @Override public void loop() { if(target.valid() || target.find()){ target.get().interact("Pickpocket"); } } } 2 Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted July 21, 2015 Share Posted July 21, 2015 Nice dude! I had a similar idea where I was going to create my own scripting language for my scripts for presets, the following would be something that thieved from a guard: walkto varrock tag GUARD "Guard" NPC_TYPE interact GUARD "Pickpocket" My API would handle it flawlessly, with built in variables (varrock being varrock square for example), and the script would handle when to stop and restart etc. Good luck 1 Quote Link to comment Share on other sites More sharing options...
Tevo Posted July 21, 2015 Share Posted July 21, 2015 Nice stuff man, keep it up. Quote Link to comment Share on other sites More sharing options...
Eliot Posted July 21, 2015 Share Posted July 21, 2015 private EntityDefinition definition = new EntityDefinition(this) .name("Man") .action("Pickpocket") .reachable(); Is this supposed to be more clear than using a constructor? 2 Quote Link to comment Share on other sites More sharing options...
Botre Posted July 22, 2015 Author Share Posted July 22, 2015 (edited) private EntityDefinition definition = new EntityDefinition(this) .name("Man") .action("Pickpocket") .reachable(); Is this supposed to be more clear than using a constructor? new EntityDefinition(this .name("Man") .action("Pickpocket") .reachable()); vs new EntityDefinition( this, "Man", "Pickpocket", true); 1 constructor 0 ambiguity 100% modular 100% extendable So... yes? On top of that, the class is wrapped around a predicate: the ability to add properties in the sequence you want makes tactical logical shortcutting a piece of pie among other cool things. Source: public class EntityDefinition<T extends Entity> implements Predicate<T> { private Predicate<T> predicate; private MethodProvider mp; public EntityDefinition(MethodProvider mp) { this.mp = mp; predicate = o -> o != null && o.exists(); } public EntityDefinition name(String name) { predicate = predicate.and(o -> o.getName().equals(name)); return this; } public EntityDefinition action(String action) { predicate = predicate.and(o -> o.hasAction(action)); return this; } public EntityDefinition reachable() { predicate = predicate.and(o -> mp.getMap().canReach(o.getPosition())); return this; } @Override public boolean test(T t) { return predicate.test(t); } } Edited July 22, 2015 by Botre 1 Quote Link to comment Share on other sites More sharing options...
Eliot Posted July 22, 2015 Share Posted July 22, 2015 new EntityDefinition(this .name("Man") .action("Pickpocket") .reachable()); vs new EntityDefinition( this, "Man", "Pickpocket", true); 1 constructor 0 ambiguity 100% modular 100% extendable So... yes? On top of that, the class is wrapped around a predicate: the ability to add properties in the sequence you want makes tactical logical shortcutting a piece of pie among other cool things. Source: public class EntityDefinition<T extends Entity> implements Predicate<T> { private Predicate<T> predicate; private MethodProvider mp; public EntityDefinition(MethodProvider mp) { this.mp = mp; predicate = o -> o != null && o.exists(); } public EntityDefinition name(String name) { predicate = predicate.and(o -> o.getName().equals(name)); return this; } public EntityDefinition action(String action) { predicate = predicate.and(o -> o.hasAction(action)); return this; } public EntityDefinition reachable() { predicate = predicate.and(o -> mp.getMap().canReach(o.getPosition())); return this; } @Override public boolean test(T t) { return predicate.test(t); } } That's actually really good use of Predicate, props to you! 1 Quote Link to comment Share on other sites More sharing options...