SRL Archive - OSR Help

Help finding objects like doors and stairs


Success

2014-07-27 14:51:23

Hello! So my script is coming along very well! I got my initial setup of what I'm doing working, my banking working, and my walking working. Along with those I have to climb up two stairs and open a door to continue to the bank.
Right now I'm using this to find the door:

Procedure OpenDoor1;
begin
MakeCompass('N');
SetAngle(SRL_ANGLE_HIGH);

If FindObjCustom(x, y, ['pen'], [2012657], 2) then
begin
Wait(randomRange(100, 250));
ClickMouse2(Mouse_Left);
If DidRedclick then
Wait(RandomRange(3000, 4000));
exit end else exit;
end;
Though this works, it doesn't always pick up the door so it will skip to the next step and mess up the whole script.
So I considered using R_OpenDoor(Point(265, 205), 'S'); and I'm not sure if I have this typed 100% correctly or if it's just not working on a large door but it didn't even attempt to find the door.
Now for the stairs, this seems to always work. But I would like something a bit more reliable.
Here's how I'm finding the stairs:

Procedure FindStairs1;
begin
MakeCompass('N');
SetAngle(SRL_ANGLE_HIGH);

If FindObjCustom(x, y, ['-up'], [5261641], 2) then
begin
Wait(randomRange(100, 250));
ClickMouse2(Mouse_Left);
If DidRedclick then
Wait(RandomRange(3000, 4000));
exit end else exit;
end;

Well that's that! I'm wondering if anyone would suggest the best option for me to finding the doors and the stairs and maybe something to setup to where it will keep trying to find it and complete the task before moving on? Thanks in advance!

ineedbot

2014-07-27 16:02:48

Well it appears you are available to using reflection, so what I do for doors is that I check if 'R_GetObjectAt(3, closedDoorObjectTile).ID' doesn't equal 0. Meaning that the door is closed and needs to be opened. Then I use R_OpenDoor(closedDoorObjectTile, whichDirectionDoorIsToTile); to open the door.

For extra failsafes I check if the player is within the area of which the door encompasses, and checks if needing to open the door is even needed.

Also, it sounds like you are going up and down stairs, so you should check to see what 'plane' you are on with R_GetPlane, to make sure you are on the right plane.

Success

2014-07-27 16:44:57

From: ineedbot
Well it appears you are available to using reflection, so what I do for doors is that I check if 'R_GetObjectAt(3, closedDoorObjectTile).ID' doesn't equal 0. Meaning that the door is closed and needs to be opened. Then I use R_OpenDoor(closedDoorObjectTile, whichDirectionDoorIsToTile); to open the door.

For extra failsafes I check if the player is within the area of which the door encompasses, and checks if needing to open the door is even needed.

Also, it sounds like you are going up and down stairs, so you should check to see what 'plane' you are on with R_GetPlane, to make sure you are on the right plane.


Now looking at that, I would think it would work. But with my little lack of knowledge for reflection on this certain thing. I need a bit more help if your willing. I looked into R_GetPlane and how it checks out which level your on. For my script I'm 2 underground and then the door is on normal ground which would be plane 0? I'm wondering how would I set this up to work?
Also if you will, explain how to find the closedDoorObjectTile and whichDirectionDoorIsToTile.
Like how do I know rather to put N or S? Is it by which direction the door opens up to or what?
Here's a few pics of the stairs and the door if it helps any:
[ATTACH=CONFIG]23691[/ATTACH]

Success

2014-07-27 16:49:44

Or if you could throw a script my way that uses these, I can go in and tweak it so I can learn how to set this up by myself?

ineedbot

2014-07-27 16:56:28

From: Success
Now looking at that, I would think it would work. But with my little lack of knowledge for reflection on this certain thing. I need a bit more help if your willing. I looked into R_GetPlane and how it checks out which level your on. For my script I'm 2 underground and then the door is on normal ground which would be plane 0? I'm wondering how would I set this up to work?
Also if you will, explain how to find the closedDoorObjectTile and whichDirectionDoorIsToTile.
Like how do I know rather to put N or S? Is it by which direction the door opens up to or what?
Here's a few pics of the stairs and the door if it helps any:
[ATTACH=CONFIG]23691[/ATTACH]

How I check to find the closed door tile, I use the ID Display.simba found in includes/srl-osr/srl/reflection/tools and close the door and find where the ID is (make sure you have debugObjects on true and debugObjectType on 3.)
example:
so in this case, the closed door tile is 2899, 3558, and the door is 'n' of the tile.

From: Success
Or if you could throw a script my way that uses these, I can go in and tweak it so I can learn how to set this up by myself?


My AIO Woodcutter uses opening doors for lumbridge oaks and edgeville yews. you can have a look at that

Success

2014-07-27 17:01:52

From: ineedbot
How I check to find the closed door tile, I use the ID Display.simba found in includes/srl-osr/srl/reflection/tools and close the door and find where the ID is (make sure you have debugObjects on true and debugObjectType on 3.)
example:
so in this case, the closed door tile is 2899, 3558, and the door is 'n' of the tile.



My AIO Woodcutter uses opening doors for lumbridge oaks and edgeville yews. you can have a look at that


God that's perfect! I didn't even know there was this tool.
Thanks man! Wish me luck with this script and future ones, I plan on learning to script better over the next year

Success

2014-07-27 17:06:48

Oh and one last thing. How do you make debugObjects on true and debugObjectType on 3?
I looked at your woodcutter around for these and didn't see them. Like would I need to set this up in my script?
Or are you just talking about while I use the tool?

ineedbot

2014-07-27 17:07:40

From: Success
Oh and one last thing. How do you make debugObjects on true and debugObjectType on 3?
I looked at your woodcutter around for these and didn't see them


Thats on the ID Display.simba script. Makes it so you can change what type of objects you want to debug.

Flight

2014-07-27 20:29:26

Agh, why rely on Reflection for something as simple as object-finding?…

function openTheDoor()

Function openTheDoor(): Boolean;
var
i : Integer;
begin
MakeCompass('N');
SetAngle(SRL_ANGLE_HIGH);

for i:=0 to 2 do
If findObjCustom(x, y, ['pen'], [2012657], 2) then
begin
Wait(randomRange(100, 250));
clickMouse2(Mouse_Left);
result := didRedclick;

if result then
Wait(RandomRange(3000, 4000));
break;
end;

case result of
True : Writeln('Found & clicked the door!');
False: Writeln('Failed to find the door.');
end;
end;
function climbTheStairs()

Function climbTheStairs(): Boolean;
var
i : Integer;
begin
MakeCompass('N');
SetAngle(SRL_ANGLE_HIGH);

for i:=0 to 2 do
If findObjCustom(x, y, ['-up'], [5261641], 2) then
begin
Wait(randomRange(100, 250));
clickMouse2(Mouse_Left);
result := didRedclick;

if result then
Wait(RandomRange(3000, 4000));
break;
end;

case result of
True : Writeln('Found & clicked the stairs!');
False: Writeln('Failed to find the stairs.');
end;
end;

Come on you guys, use color for the easy stuff and use reflection as a last resort.

The Mayor

2014-07-28 00:54:36

From: Flight
Agh, why rely on Reflection for something as simple as object-finding?…

function openTheDoor()

Function openTheDoor(): Boolean;
var
i : Integer;
begin
MakeCompass('N');
SetAngle(SRL_ANGLE_HIGH);

for i:=0 to 2 do
If findObjCustom(x, y, ['pen'], [2012657], 2) then
begin
Wait(randomRange(100, 250));
clickMouse2(Mouse_Left);
result := didRedclick;

if result then
Wait(RandomRange(3000, 4000));
break;
end;

case result of
True : Writeln('Found & clicked the door!');
False: Writeln('Failed to find the door.');
end;
end;
function climbTheStairs()

Function climbTheStairs(): Boolean;
var
i : Integer;
begin
MakeCompass('N');
SetAngle(SRL_ANGLE_HIGH);

for i:=0 to 2 do
If findObjCustom(x, y, ['-up'], [5261641], 2) then
begin
Wait(randomRange(100, 250));
clickMouse2(Mouse_Left);
result := didRedclick;

if result then
Wait(RandomRange(3000, 4000));
break;
end;

case result of
True : Writeln('Found & clicked the stairs!');
False: Writeln('Failed to find the stairs.');
end;
end;

Come on you guys, use color for the easy stuff and use reflection as a last resort.


It's a bit botty to check the upText though, and sometimes it can be really hard to grab a unique colour that works at all distances/compass angles.

In my scripts I usually find the door relative to other objects, which are easy to find. In this example I find the Potters Wheel, and then create a Tbox which is offset from the middle of the potters wheel TPA. The great thing is, it works at any angle (if you take compass angle into account) and at any distance from the door (by taking the distance from the playerPoint to potters wheel TPA into account). This way it's pretty human like.




TPA length < 250 = closed:


Flight

2014-07-28 03:19:59

From: The Mayor
It's a bit botty to check the upText though, and sometimes it can be really hard to grab a unique colour that works at all distances/compass angles.


You should have read his post first. He has no problem finding the door/stairs, he's simply asking advice on how to repeat the procedure until they are clicked, AKA creating a loop within the procedure.

The Mayor

2014-07-28 03:44:30

From: Flight
You should have read his post first. He has no problem finding the door/stairs, he's simply asking advice on how to repeat the procedure until they are clicked, AKA creating a loop within the procedure.


I did read it :) When he said this:

From: Success
it doesn't always pick up the door


It sounded like he had trouble finding the door. And when he said:

From: Success
I'm wondering if anyone would suggest the best option for me to finding the doors


It sounded like he wanted people to suggest ways of finding doors. I just thought he might find it useful.

Bixby Sayz

2014-12-14 21:12:59

From: The Mayor
In my scripts I usually find the door relative to other objects, which are easy to find. In this example I find the Potters Wheel, and then create a Tbox which is offset from the middle of the potters wheel TPA. The great thing is, it works at any angle (if you take compass angle into account) and at any distance from the door (by taking the distance from the playerPoint to potters wheel TPA into account). This way it's pretty human like.


Bit of a grave-dig but would you mind sharing your code for figuring out the relative search box?

The Mayor

2014-12-14 22:02:11

From: Bixby Sayz
Bit of a grave-dig but would you mind sharing your code for figuring out the relative search box?


I can dig out the code if you want, but have a look at Camel's tutorial first