SomeGuyFromHere
2012-12-30 18:50:35
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.
:wacko:
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.
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!
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.
:wacko:
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:
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...');
[U][B]if [/B]FindObjCustom(x, y, ['Close Gate'], [3622483, 3094077], 3)
[/U] [U][B]then [/B]begin Writeln('Gate is already open! Continuing with walking.')[/U]
[U]end
[B]else[/B]
Writeln('Something might have gone wrong, no gate in sight, neither open or closed. Teleporting back to Burthorpe.');
LodestoneTeleport('Burthorpe');
end;[/U]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.
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!