

liverare
Scripter II-
Posts
1300 -
Joined
-
Last visited
-
Days Won
3 -
Feedback
0%
Everything posted by liverare
-
Make sure user/osbot/data/ exists Make sure user/osbot/data/<script> exists (as written in the script) Post code and screen shots of your data folder structure
-
Laughing at stupid shit isn't centrist.
-
It doesn't matter who they are, it only matters that they crash and burn and we laugh all the while. Enjoy the shitshow
-
That's more of a bot problem than a script problem.
-
You could pre-define these doors (at least the ones you care about): public enum Door { // DEFINE DOORS HERE VARROCK_DOOR_A("Big door", 1000, 2000, 0), VARROCK_DOOR_B("Doory door", 2000, 3000, 1), FALADOR_DOOR_A("White door", 3000, 4000, 2), // etc. ; // OOP CODE HERE private final String name; private final int x; private final int y; private final int z; // -1 = ignore plane check private Door(String name, int x, int y, int z) { this.name = name; this.x = x; this.y = y; this.z. = z; } private Door(String name, int x, int y, int z) { this(name, x, y, -1); } @Override public String toString() { return String.format("[name=%s, x=%s, y=%s, z=%s]", name, x, y, z); } public boolean isDefined(RS2Object gameObject) { return gameObject.getName().equals(name) && gameObject.getX() == x && gameObject.getY() == y && (z == -1 || gameObject.getZ() == z); } // static methdo (it belongs to Door class, not instantiated Door objects) public static boolean isDefined(RS2Object gameObject) { boolean defined = false; for (Door door : values()) { if (door.isDefined(gameObject)) { defined = true; break; } } return defined; } } It's pretty verbose and isn't very future proof, but you can get very nitty-gritty with how exact it is the things you want to find are, then you can do: List<RS2Object> openableDoors = s.objects.getAll().stream().filter(Door::isDefined).collect(Collectors.toList()); With this, you don't necessarily need to search for the doors because the information about those doors are already defined. You'd only need to actually find those doors in-game when you intend to interact with them. (Also there might be problems because this is ad-hoc code I wrote in notepad)
-
I've been suckered into this ponzi scheme, parting with £30.00 worth of Ripple: I'll check back in a year or so to see whether I'm set to retire or not.
-
So you want to files, huh? M'kay. Example code: import java.io.IOException; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "", info = "", logo = "", name = "Chicken Killer", version = 0) public class ChickenKiller extends Script { OSBotFileAPI osbotFile; String profile; @Override public void onStart() throws InterruptedException { initialiseCustomAPIs(); iWantToOpenAFile(); iWantToSaveStuffToAFile("Hello world!"); } private void initialiseCustomAPIs() { osbotFile = new OSBotFileAPI(); osbotFile.exchangeContext(bot); osbotFile.initializeModule(); } private void iWantToOpenAFile() { try { profile = osbotFile.open(); logger.debug(profile); } catch (RuntimeException | IOException e) { logger.error(e); } } private void iWantToSaveStuffToAFile(String stuff) { try { osbotFile.save("Hello world!"); } catch (RuntimeException | IOException e) { logger.error(e); } } @Override public int onLoop() throws InterruptedException { return 250; } } Testing: Folder is automatically created if it doesn't exist: I manually created a text file for testing and added it into the script data folder: I re-ran the script so that I could now select something: And then the script did a little save testing with the same file: Functions: public boolean folderExists() protected synchronized String readFromFile(File file) throws FileNotFoundException, IOException public synchronized String readFromFile(String filename) throws FileNotFoundException, IOException protected synchronized void writeToFile(File file, String fileContent) throws IOException public synchronized void writeToFile(String filename, String fileContent) throws IOException public synchronized String open(FileFilter fileFilter) throws RuntimeException, FileNotFoundException, IOException public synchronized String open() throws RuntimeException, FileNotFoundException, IOException public synchronized void save(FileFilter fileFilter, String fileContent) throws IOException public synchronized void save(String fileContent) throws IOException public synchronized boolean deleteFile(String filename) Source:
-
String food = "trout"; NPC rockCrab; @Override public int onLoop() { if (atBank()) { doBank(); } else if (atRockCrabs()) { doRockCrabs(); } return 250; } private void doBank() { if (stockedUpOnFood()) { if (goodHealth()) { goToRockCrabs(); } else { eat(); } } else if (bankHasFood()) { withdrawFood(); } else { stopScript(); } } private void doRockCrabs() { if (goodHealth()) { if (findRockCrab()) { attackRockCrab(); } } else if (hasFood()) { eat(); } else { goToBank(); } } Easy to debug. Easy to predict. Simple script logic. This is a high-level overview of an upcoming rock crab script. You can see from this small snippet everything my script does without having to read further into the script. Additionally, the logic's presented simplistically, enough so that it can be compared to pseudo code (if you plan your scripts). Maintainability is one of the most important elements of a script. Why? There'll come a time when this logic fails and you may not necessarily be the one maintaining your own scripts. Years from now when you've probably f'd off to pursue some other interest, your work will still be here, being used by people. Your script will break (because Jagex can't leave well enough alone) and some poor motherfucker is going to be tasked with salvaging your works. Do you really want to give him or her a hard time of it? You don't need to use task frameworks. You can, but please know what you're doing and how to make the most use out of it first. I've seen new scripters try use tasks frameworks and it saddens me, because their desired outcome could be written so much simpler.
-
Your loop method is a little unwieldy. Try to make it a series of calls instead: updateValues(); // get health etc if (isFighting()) { if (hasFood()) { if (lowHealth()) { eat(); } } else { if (lowHealth()) { goToBank(); } } } else if (isLootValid()) { loot(); } else { // etc. } This is a ad hoc example of a high-level loop function. Instead of crunching numbers, we do some logic instead. That way, you can tell what the script is doing and what you can expect it to do.
-
ad hoc api.projectiles.getAll() .stream() .filter(this::isProjectileTargetingMe) .filter(this::isProjectileARangedAttack) .collect(Collectors.toList()); private boolean isProjectileTargetingMe(Projectile p) { return api.myPlayer().equals(p.getTargetEntity()); } private boolean isProjectileARangedAttack(Projectile p) { return p.getId() == -1; // TODO } get projectiles get only projectiles targeting us get only projectiles with certain ID Then you can mess about figuring out whether you're praying the right prayer. Look into Lambda expressions for Java.
-
>code changes >newly created jar file OKAY stop what you're doing and set up your Eclipse properly: If you're using intellij, then try looking for a way to set it up like you can in Eclipse.
-
If your files are .java, then they need to be compiled to .class. If your files are .class, then they need to be put into OSBot's script folder (C:/users/you/osbot/scripts). If you've compiled and packaged your script as a .jar, then that needs to go in there as well. Also, if you're using Eclipse, check this out:
-
The Zeitgeist - We ALL Knew it was Coming to This
liverare replied to liverare's topic in Spam/Off Topic
I would rather beat up my black friend until he puts on the glasses. He will learn about the thot. -
+ =
-
You're in a shit situation, so let me try and help: Am I supposed to do everything front-end and back-end purely by myself without any support from other developers? You're expected to yes. It's called being a full-stack developer. If you're not a full-stack developer, then let her know immediately and drop the project. Is that normal in such an environment? Yes. It's called being in business; your boss has obligations to meet too. However, in programming--programming especially--deadlines are a flimsy term. You should negotiate them with at least +50% additional time, because it's better to seen to deliver early than late. Should I just work the hours I'm supposed to work? Yes. You're an uni-student; part-time work is okay as long as it's part-time. Focus on your studies, because you're paying a very high fucking premium for it. A few $ or £ here and there will mean jack fucking shit if you fail your studies. If you can, drop the work altogether and focus on your studies. Should I just let go? Yes. You're not a full-stack developer and you're a student. Don't start working for real until you've got a degree behind you. Should I ask for more pay? If so, how much do you reckon? From who...? The part-time job's not going to pay you much more unless you're exemplary to them. The person you're doing the web stuff for should definitely be paying you more, A LOT FUCKING MORE, if you're expected to be a lone full-stack developer erecting an entire e-commerce website. Look at what you can earn as a full-stack developer. My advice to you: Drop the work altogether and finish your studies. If you can't afford to do that, then drop the web project and stick to your part-time work. PART-TIME, NOT ZERO-HOURS UNTIL IT'S BASICALLY FULL-TIME, BUT AT PART-TIME RATES. If you can't afford to do that either, then tell your boss they shouldn't expect an all-singing-all-dancing website. You don't have the time; you're not a full-stack dev (or tell them they're not treating/paying you as though you were); and e-commerce is a whole separate beast to wrangle. If you want to keep the web project then tell your boss they can expect a static webpage that show cases their products and informs them of their business address and phone number. Nothing more; nothing less. Also, if you're working 50 hours a week for just £100, then you my friend are a dumb ass motherfucker. I can't stress to you how bad pay that is. That's legit £2/hour.
-
It's not pretty, but if you CTRL+F for the main loop method, then you can see what the script's actually doing: @Override public int loop() { if (!authCheck) return -1; if (!verified) { threadPitch(100); } else if (game.isLoggedIn()) { mouse.setSpeed(random(5, 8)); if (inDungeon) { getCurrentRoom(); if (exit) { exitDungeon(); exit = false; } else if (finish) { finishDungeon(); finish = false; } else if (newDungeon) { startDungeon(); newDungeon = false; } else if (settingsFinished) { if (bossFight) { safeTile = null; if (getObjInRoom(FINISHED_LADDERS) != null) { finish = true; } else if (floor == Floor.FROZEN) { frozenBoss(); } else if (floor == Floor.ABANDONED) { abandonedBoss(); } else if (floor == Floor.FURNISHED) { furnishedBoss(); } else if (floor == Floor.OCCULT) { occultBoss(); } else if (floor == Floor.WARPED) { warpedBoss(); } bossFight = false; retrace = false; } else if (explore) { exploreRoom(); explore = false; } else if (open) { if (openNextDoor()) { explore = true; } else retrace = true; nearDoor = null; nearDoor2 = null; doorTimer = null; open = false; } else if (retrace) { retraceDungeon(); retrace = false; } else { if (failSafe()) return 100; if (developer) secondaryStatus = "We don't know what to do :("; return random(500, 1000); } } } else { if (newDungeon && inDungeon()) { status = "Starting a new dungeon!"; inDungeon = true; } else if (objects.getNearest(END_STAIRS) != null) { status = "Jumping down the stairs..."; if (doObjAction(objects.getNearest(END_STAIRS), "Jump-down")) { if (waitToStop(true)) waitToStop(true); } } else if (objects.getNearest(ENTRANCE) != null) { enterDungeon(); } else { // Failsafe } } } secondaryStatus = ""; unreachable = false; return random(0, 20); } What's wrong with this script is that there are a lot of functions which could be stored in their own classes, such as: private boolean walkFast(RSTile dest, final int r) private boolean walkTo(final RSTile dest, final int r) private boolean walkToScreen(final RSTile dest) private boolean walkToMap(final RSTile t, int r) private boolean walkToDoor(final int r) private boolean walkBlockedTile(RSTile dest, final int r) private boolean walkAround(final RSTile t, final int x, final int y, final boolean isNpc) private void walkAdjacentTo(final RSTile dest, final int maxDist) private boolean waitToStop(boolean deanimate) private boolean useItem(final int itemID, final RSObject obj) private boolean useItem(final int itemID, final RSNPC npc) That's just some (because the list is huge! Just copy/paste that code into Notepad++, hit Language > Java, then View > Fold All). That being said, I have no right to criticise one of the best scripts in RS history (one that I used myself). The developer of this script was a genius.
-
Maintainability is the most important key of any piece of script or program, because it will break and some poor fucker's going to be tasked with fixing it. The simpler the script is (i.e., keep everything on the main loop), the easier time that guy's gonna have. The way I'm going about things; I am doing everything I possibly can to steer clear from any kind of node/state system. Instead, if there's a scenario in which I need to (a large AIO agility script), then it's time to step back, break it down into multiple scripts and release them separately. The user gets to choose what's actually relevant to them (because an AIO with a high price tag might be mostly useless), and should one script from the batch break, then you only need to fix the problems unique to that script.
-
The best design principle is: keep it simple. If your abstracting shit out, having shit run concurrently, doing shit which--from the layman coder--looks completely alien, then you're doing it shitly. Right/wrong be damned. Keep it simple. You're writing a script, not a program. OSBot already abstracts out the three most important methods: start, loop, and exit. You don't need to further abstract shit unless you want to, and if you do, then you'd better be writing one hell of a program-script.
-
Yes. I don't take script icons very seriously. I used it to get 99 crafting from 80-something and I haven't been banned. I don't have proggy for it though, because I used this script when it was in its early stages of simply being fit for purpose.
-
Extending method provider and nullpointerexception
liverare replied to Theorems's topic in Scripting Help
If you're new to Java, then I suggest you start with the basics. You don't need states and tasks to write a good script. -
Map<String, Integer> bankCache; void updateBankCache() { bankCache = Stream.of(bank.getItems()) .collect(Collectors.toMap(Item::getName, Item::getAmount, (a, b) -> a + b)); } { /// ... some bank-ery stuff before here updateBankCache(); bank.close(); // .. some other-ery stuff happens nao int bankedOakLogs = bankCache.get("Oak logs"); } There are items in RS that have the same name, but do not stack on top of each other in the bank, like the Wintertodt supply crates. With such items, there needs to be a merger function that makes sure the final map only contains unique keys. The merger function here "(a, b) -> a + b" is simply adding together the quantities of those unique items. Without a merger function, the script will error when items like the Wintertodt supply crates are found.
-
Goblins under Fishing Guild. Why? Safe, AFK, and good place to use cannon. Hob goblins in the wildi is quicker (more kills p/hour), but is risky. Although I got my scroll from them in under 100 kills (very lucky!) when I grinded out my champions cape.
-
Hopefully an intermediate language will be developed so the bot can run on a desktop, tablet, or IOS/Android smartphone, like JavaScript.