May 9, 20214 yr 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.
May 9, 20214 yr 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.
May 9, 20214 yr Author 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?
May 9, 20214 yr 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.
May 9, 20214 yr 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.
May 9, 20214 yr Author 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, 20214 yr by SmaTTeR
June 17, 20214 yr 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, 20214 yr by rawgreaze
June 17, 20214 yr 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
June 18, 20214 yr 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
June 18, 20214 yr 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
Create an account or sign in to comment