Hey,
so I always thought if...then...else works like this:
If the condition from if is met, then the code under "then" is executed and not what is included in else.
The "else"-code is only executed when the condition is not met.
Doesn't seem to work that way.
Here is a procedure I wrote; note the underlined part, this seems to be the one that is causing trouble:
Now what I want to happen is that after the gate gets opened or the gate is already open, the rest of the code is skipped with and the procedure ends.Code:Procedure OpenGate; var x, y: Integer; begin if FindObjCustom(x, y, ['Open Gate'], [3622483, 3094077], 3) then begin Writeln('Gate found. Clicking.'); ClickMouse(x, y, mouse_Left); Writeln('OK, clicked on the gate. Waiting for 12 seconds for the process to finish...'); Wait(12000); end else Writeln('Gate not found, is it already open? Checking...'); if FindObjCustom(x, y, ['Close Gate'], [3622483, 3094077], 3) then begin Writeln('Gate is already open! Continuing with walking.') end else Writeln('Something might have gone wrong, no gate in sight, neither open or closed. Teleporting back to Burthorpe.'); LodestoneTeleport('Burthorpe'); end;
What actually happens is that, no matter what the result of the door opening was the failsafe fires...
Using the "Exit;" command I was able to work around the problem for a while but since I reprogrammed the code this is not longer possible, except with labels which you shouldn't use unless it's really necessary, so I need to get this done properly.
Could someone point out my error? Thanks a lot Villavu!



Reply With Quote








