SRL Archive - OSR Help

Opening a gate


Athylus

2013-08-20 09:18:07

I'm nearly done with my script, I just have to add some failsafes. I can't think of anything to failsafe opening this gate though. I've looked at tutorials. This is what I could come up with.


procedure FindGate;
var
x, y: integer;
aFound: Extended;
begin
if FindDTMRotated(Gate, x, y, MSX1, MSY1, MSX2, MSY2, -Pi/4, Pi/4, Pi/60, aFound) then
begin
MakeCompass('n');
writeln('We found the gate');
MMouse(x, y, 3, 3);
Mouse(x, y, 0, 0, true);
end else
begin
writeln('The gate is already open');
Exit;
end;
end;

I'd like some advice. Here's what I came up with it. Still gotta test.


procedure FindGate;
var
x, y: integer;
aFound: Extended;
begin
if FindDTMRotated(Gate, x, y, MSX1, MSY1, MSX2, MSY2, -Pi/4, Pi/4, Pi/60, aFound) then
begin
MakeCompass('n');
writeln('We found the gate');
MMouse(x, y, 3, 3);
Mouse(x, y, 0, 0, true);
end else
begin
if FindObjCustom(x, y, ['pen', 'ate'], 123, 15) then
begin
writeln('We found the gate');
MMouse(x, y, 3, 3);
ClickMouse(x, y, mouse_Left);
end;
end;
end;

Even so, what if it can't find the gate, still? I'll have to add in a repeat function… but repeat.. until(?)? Some insight would be greatly appreciated.

Turpinator

2013-08-20 10:42:59

@Flight has a very good post on the same thing for doors as seen here… http://villavu.com/forum/showthread.php?t=104791&p=1255442#post1255442

Athylus

2013-08-21 09:56:49

Thanks! I'll take a look now. Too complicated, hehe. Gonna search up some more stuff. I'd still like advice.