Everything posted by Explv
-
How do I move the logger?
- Trying to make the script execute another executable jar
No- cant see my settings
Nice GUI @Czar Only the scriptwriter can help you, post on the script thread.- YO
- Learing to write scripts
It will be very beneficial, the more proficient you are at Java, the better your scripts are likely to be. You should spend some time learning Java first, understanding all the basic concepts, before attempting to script. Once you have the basics, check out the OSBot API, read tutorials, read snippets, read scripting help section. There are people here that will say oh I didn't bother learning Java, their scripts are probably trash, or were purely written by copy and pasting from snippets, or they just constantly spam in scripting help until someone does it for them. Don't be that guy- Extreme scripts refund?
Lifetime of the script, not until OP dies... Many scripters have left in the past, and their scripts have been left unmaintained. Eventually those scripts will break, do you really think OSBot is then going to refund every purchase of that script? For very popular scripts OSBot will now try to maintain them themselves, however this is not always possible because the devs are busy. OP paid $10 and got 2 years out of a script, it's not like he got scammed.- Draw the bounding box of an area
Yes the convex hull algorithm would work. There is probably an easier overall solution, but I cba to think of one right now. Using https://github.com/bkiers/GrahamScan List<Position> positions = area.getPositions(); List<Point> points = new ArrayList<>(); for (Position pos : positions) { Polygon polygon = pos.getPolygon(getBot()); for (int i = 0; i < polygon.xpoints.length; i ++) { points.add(new Point(polygon.xpoints[i], polygon.ypoints[i])); } } List<Point> convexHull = GrahamScan.getConvexHull(points); Polygon areaShape = new Polygon(); for (Point point : convexHull) { areaShape.addPoint(point.x, point.y); } g.draw(areaShape);- Draw the bounding box of an area
Apologies, I have added an explanation. I am unable to test & fix myself atm because I am at work, but I can take a look later this evening. Perhaps you could try drawing the bounds (outline) of the final Shape, instead of the Shape itself? Note: this would only work if your Area is a rectangle area.getPositions() .stream() .map(pos -> pos.getPolygon(getBot())) .map(java.awt.geom.Area::new) .reduce((area1, area2) -> { area1.add(area2); return area1; }) .map(shape -> shape.getBounds2D()) .ifPresent(g::draw); What the code does: Gets the List<Position> in the area using getPositions() Constructs a Stream<Position> by calling stream() Maps each position to it's Polygon by calling getPolygon, now you have a Stream<Polygon> Maps each polygon to an Area instance by calling new Area(polygon), I use the Area::new method reference to make this shorter, now you have a Stream<Area> Reduces the Stream<Area> into a single Area, all the Areas are added together using the add(Area) method Map the combined Area Shape to it's bounds (Rectangle outline) If the final Rectangle is present, we draw it on screen using graphics.draw(Shape)- Draw the bounding box of an area
Maybe you're right, i'm not sure. I guess you could maybe try combining the polygons of each position and then drawing the end result? Something like: (NOTE UNTESTED) area.getPositions() .stream() .map(pos -> pos.getPolygon(getBot())) .map(java.awt.geom.Area::new) .reduce((area1, area2) -> { area1.add(area2); return area1; }) .ifPresent(g::draw); What the code does: Gets the List<Position> in the area using getPositions() Constructs a Stream<Position> by calling stream() Maps each position to it's Polygon by calling getPolygon, now you have a Stream<Polygon> Maps each polygon to an Area instance by calling new Area(polygon), I use the Area::new method reference to make this shorter, now you have a Stream<Area> Reduces the Stream<Area> into a single Area, all the Areas are added together using the add(Area) method If an Area is present, we draw it on screen using graphics.draw(Shape)- Draw the bounding box of an area
- Checking Idle time?
@slazter if you really have to do it, then you can probably make use of the isAnimating and isMoving methods in the Character class, in combination with some kind of timer.- Checking Idle time?
You should probably aim for your script to not fuck up then- Checking Idle time?
Seems like you are doing something wrong or need to improve your script. Why would you need to detect if you are idle for 7 seconds? Makes no sense to me- Explv's AIO [13 skill AIO in 1 script]
Same with most tutorial island scripts to be honest. Some people experience getting "instantly flagged" others do not.- Lambda Support for Wait Conditions (Make your code cleaner!)
It isn't very clear how he got to those percentages, and I can't be bothered to read his code. It says based on X commits, but I think X repositories would be a more accurate representation. All the Java style guides including Oracle's and Google's don't newline, I also have never seen a library that newlines. Although you can just auto format to clean up the disgraceful newlines, sometimes it can fuck up the formatting of other pieces of code. I would rather people just followed standard Java practice rather than trying to infect me with their .NET virus. More than anything, if I see someone using code conventions from a different language, it just makes me think they are a scrub. Of course I do think consistency is most important, but here on OSBot we don't newline- Explv's Scripting 101
Still not finished, will work on it tomorrow or weekend.- Explv's AIO [13 skill AIO in 1 script]
Could you please send a screenshot of your GUI setup to my inbox? It is hard for me to tell what is broken because you could be using any combination of tasks / activities etc. Thanks- Help me improve my script, and use Lambdas?
A few things I notice that are bad: You don't need to create your own methods for handling dialogue. There already exists a method getDialoges().completeDialogue(options) that will click continue and select options etc. Instead of having if statements for checking configs, you could just use a switch, it would be much cleaner: switch(getConfigs().get(123)) { case 0: doSomething(); break; case 1: doSomethingElse(); break; // etc. } In your questKnightsSword method you have a bunch of Areas. Those should be global final variables, as you are never changing them, and you don't want to keep creating new instances every time that method is called. The above also applies to the pickaxe filter, val and qItems variables in your questKnightsSword method In the questKnightsSword method, at the start, you always search for three NPCs. You should only search for an NPC if you are going to use it, e.g. only get the squire npc when you are going to talk to the squire. Some of your variables are poorly named, such as "val". Use proper naming conventions You should check the return status of an API call. For example you interact with the blurite rock and then sleep, but you don't actually check if the interaction was successful. If the interaction failed for some weird reason, the script would just sleep for 5 seconds: bluerite.interact("Mine"); Sleep.sleepUntil(()-> myPlayer().isAnimating(),5000); Should be: if (bluerite.interact("Mine")) { Sleep.sleepUntil(()-> myPlayer().isAnimating(), 5000); } Similar to the point above, you have a bunch of sequential API calls in your code, assuming that the previous call was successful. API calls CAN fail, and you should account for it. For example when you withdraw "q items" you just withdraw one after the other, not accounting for if the previous one failed and you needing to withdraw again. dialogueV2 is a terrible name for a method You have some elses without curly braces which could easily result in you messing something up You also have a few sleeps that are just sleep(random(int, int)). These should all really be replaced by a ConditionalSleep Regarding your first question, I would clean up your questKnightsSword method, there's quite a few areas in there that could benefit from being moved out into their own methods. As for you wanting to learn more about lambdas, you are already making use of them in the Sleep.sleepUntil method. You could also use a lambda expression for the pickaxe filter: Filter<Item> pickaxe = item -> item.getName().contains("pickaxe"); Because you are making a quest script with a bunch of quests, you should focus on studying OOP concepts. There are a lot of common things you have to do in quests, so you should be making proper use of inheritance, utility classes / methods etc. to reduce the amount of code you have to write. Regarding your 6th point "So i have a class called "Platser" where i save many areas or positions around runescape", I think you should store areas and positions in the places where you are going to use them. The only reason to create a class with variables like that is if you are using them in multiple places, for example the Banks class in the OSBot API. Damn, I have become too predictable- Explv's Scripting 101
I will try and finish the GUI section tonight- Notation of K and M like RS in PHP
wtf are you doing Are you trying to say that you don't want any rounding to occur at all?- Notation of K and M like RS in PHP
The code I just showed you will format it to 21.11m, it will always round down to 2dp... I have no idea what you are asking now...- Notation of K and M like RS in PHP
There are three different rounding functions, they are often found in all languages: floor (round down) round (round up or down) ceil (round up) Use floor instead of round. You need some extra logic if you want to perform the operation to n decimal places: floor(value * (10 ^ precision)) / (10 ^ precision) So in this case, as you want it to 2dp it would be: floor(value * 100) / 100 $holdingAmount = 21119054; if ($holdingAmount >= 1000000) { echo (floor(($holdingAmount / 1000000) * 100) / 100) . "m"; } else if ($holdingAmount >= 1000) { echo (floor(($holdingAmount / 1000) * 100) / 100) . "k"; } else { echo $holdingAmount; } I would also strongly recommend that you improve your "Googling" ability. All you had to do was type "php round down to 2 decimal places".- How to know where I am in map ?
Do you mean get the name of the location your player is currently in, like Varrock / Lumbridge?- Explv's AIO [13 skill AIO in 1 script]
Yeah I removed those buttons while I was refactoring the GUI. I will add them back when I get the chance, sorry about the inconvenience.- Project Catalyst
I don't think its just an anti-scam measure, it's also because OSBot is a business, if people had free reign over selling private scripts or setting up their own auth systems, OSBot loses out on those script sales. It also circumvents any pricing policies that mods may want to enforce, like undercutting other scripters, and it generally reduces the value of the SDN. Just saying you may want to get permission before working on it. Either way, good luck with it, looks like a nice project. - Trying to make the script execute another executable jar