SmaTTeR Posted May 9, 2021 Posted May 9, 2021 What's the code to check if my player is in a certain area and if it is to walk to another? Tried couple different things and couldn't get it to not error. Making a simple walking script for my first script and this is only problem i'm having so far.
Lunar Posted May 9, 2021 Posted May 9, 2021 if (area.contains(myPosition()) { getWalking.webWalk(newArea); } area being the area that your character is currently in, newArea being the place you want your character to be. I reccomend using Explv's Map to make areas. 1
SmaTTeR Posted May 9, 2021 Author Posted May 9, 2021 4 hours ago, Lunar said: if (area.contains(myPosition()) { getWalking.webWalk(newArea); } area being the area that your character is currently in, newArea being the place you want your character to be. I reccomend using Explv's Map to make areas. I tried that and it errors because of contains. But if for say I'm in lumbridge and I want it to check if I'm there can I just put if (area.contains(myPosition()) ? or do I need to define the area that I'm asking if it contains my player?
Lunar Posted May 9, 2021 Posted May 9, 2021 1 hour ago, SmaTTeR said: But if for say I'm in lumbridge and I want it to check if I'm there can I just put if (area.contains(myPosition()) ? or do I need to define the area that I'm asking if it contains my player? You'd have to define the area. Explv's map makes it really easy to do that, I linked it in my previous reply.
Gunman Posted May 9, 2021 Posted May 9, 2021 1 hour ago, SmaTTeR said: I tried that and it errors because of contains. But if for say I'm in lumbridge and I want it to check if I'm there can I just put if (area.contains(myPosition()) ? or do I need to define the area that I'm asking if it contains my player? You need to define the area. And make sure it's the OSBot Area import and not the Java Area import.
SmaTTeR Posted May 9, 2021 Author Posted May 9, 2021 (edited) so... Area[] lumbridgeSpawn = { new Area(3217, 3219, 3217, 3224), new Area(3217, 3226, 3226, 3212) }; then if (area.contains(myPosition()) { getWalking.webWalk(newArea); } would that be right? And these are the imports I have... import org.osbot.rs07.api.map.Area; import org.osbot.rs07.script.Script; import org.osbot.rs07.api.model.Player; import org.osbot.rs07.api.Walking; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; Edited May 9, 2021 by SmaTTeR
Gunman Posted May 9, 2021 Posted May 9, 2021 @SmaTTeR Read #6 here https://osbot.org/forum/topic/115124-explvs-scripting-101/
rawgreaze Posted June 17, 2021 Posted June 17, 2021 (edited) On 5/9/2021 at 3:15 PM, SmaTTeR said: so... Area[] lumbridgeSpawn = { new Area(3217, 3219, 3217, 3224), new Area(3217, 3226, 3226, 3212) }; then if (area.contains(myPosition()) { getWalking.webWalk(newArea); } would that be right? And these are the imports I have... import org.osbot.rs07.api.map.Area; import org.osbot.rs07.script.Script; import org.osbot.rs07.api.model.Player; import org.osbot.rs07.api.Walking; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; why are you importing java.awt.* i have used osbot for about 3 hours now and I have managed to make a fish->bank bot.. it's super simple.. your area is an array not really sure what you are doing there but the area should be: final Area MYAREA = new Area(x1,x2, x2,y2); <- this is the 2-dimensional square area, this is the grid the areas are 2d there is no Z-axis for an area, that would be for a Position also take a look at import org.osbot.rs07.api.map.constants.Banks has some very useful default locations such as GRAND_EXCHANGE or LUMBRIDGE_UPPER for bank etc then literally all you need to do is webwalk to a position.. so if(MYAREA.contains(myPosition())), then you want to getWalking().webWalk(Banks.LUMBRIDGE_UPPER); for example. I don't believe you can walk to an "area" try walking to a position, which is import org.osbot.rs07.api.map.Position; Edited June 17, 2021 by rawgreaze
Gunman Posted June 17, 2021 Posted June 17, 2021 6 hours ago, rawgreaze said: final Area MYAREA = new Area(x1,x2, x2,y2); <- this is the 2-dimensional square area, this is the grid the areas are 2d there is no Z-axis for an area, that would be for a Position Area area = new Area(0,0,0,0).setPlane(0); Plane is Z 1
rawgreaze Posted June 18, 2021 Posted June 18, 2021 2 hours ago, Gunman said: Area area = new Area(0,0,0,0).setPlane(0); Plane is Z yes it sets the Z for the whole area i don't think you can make a 3d box can you? like in lumbridge you cant select the whole castle and all floors? you would have to do each floor i suppose. also i think i know what he did, on the map he used the top 2 numbers and the 2 underneath, he should only be using the top x and y
rawgreaze Posted June 18, 2021 Posted June 18, 2021 11 minutes ago, Malcolm said: If you wanted a 3d box you'd have to check each plane. I didn't test but probably works. private boolean inArea() { final Area area = new Area(0,0,0,0); for (int i = 0; i < 3; i++) { if (area.setPlane(i).contains(myPlayer())) { return true; } } return false; } You could also make an Area[]{} and pass area.contains(myPlayer()) that might work