Parade
2012-07-02 23:02:34
So I had an idea for my script. What needs to be done is having a procedure repeat once. I have it walk a path after performing the procedure, so I thought of adding a boolean. If I can make a boolean switch on the first time it does the procedure, the walkpath procedure will check if the boolean is true and repeat the original procedure which will switch the boolean to false the second time. Now this seems convenient if there is a way to switch a boolean with a simple command, otherwise there might be a better way do what I want.
Is there a command for switching a boolean?
x[Warrior]x3500
2012-07-02 23:23:08
testBoolean := not(testBoolean);
Parade
2012-07-02 23:31:06
So using
testBoolean := not(testBoolean);
will set the inverse of testboolean?
Nebula
2012-07-02 23:34:37
Variable := false;
Variable := true;
ex:
program progname;
var
parade: boolean;
procedure procname;
begin
if (parade = false) then
begin
do this;
parade := true;
end;
end;
Set the function to a boolean, and if result := true, result := false
Nebula
2012-07-02 23:38:04
Or you could do this:
if (parade = true) then
parade := false
else
parade = true
Frement
2012-07-02 23:48:01
The most convenient way to switch a boolean is to use:
myVar := not myVar;
Parade
2012-07-03 01:47:42
Thank you, guys. You really help out in a pinch.
Edit: So I changed it just slightly. And I ran into a weird bug. (at least I think It's weird)
[PHP]procedure Banking;
var
trueBank: Boolean;
begin
repeat
trueBank := not(trueBank)
if (FindDTM(GoldOre,x,y,MIX1,MIY1,MIX2,MIY2)) then
begin
wait(500+Random(1000));
if (FindBSpot(x,y)) Then
begin
Writeln('Attempting to deposit Gold Ore ');
ClickMouse2(True);
Wait(RandomRange(2250, 2750));
if (FindDTM(GoldOre, x, y, MSX1, MSY1, MSX2, MSY2)) then
begin
Mouse(x,y,3,3,False);
Wait(RandomRange(700,850));
ChooseOption('ll');
wait(400 + Random(150));
end;
end else
begin
SymbolAccuracy := 0.35
FindSymbol(x,y,'bank');
Mouse(x,y,0,0,true);
Wait(RandomRange(1000,1300));
SymbolAccuracy := 0.80
wait(1500+Random(1000));
Banking;
end;
end;
until(trueBank = False)
GoToGold;
end; [/PHP]
What happens is that it will repeat "GoToGold;" too. I thought that putting "until(trueBank = False)" would repeat everything before it.
It should only repeat the things you put in before it, but you seem to call the 'Banking' procedure again at the bottom of that repeat loop? I think this is where the problem lies as it tries to complete the entire procedure again if that makes sense?
I dont get what u are trying to do? You want it to repeat FindDTM and FindBspot until it banks? then you should just put 'Break;' after the Banking;
The way u reverse the boolean its going to repeat twice and stop (false to true, then to false again)
Parade
2012-07-03 15:04:57
From: riwu
I dont get what u are trying to do? You want it to repeat FindDTM and FindBspot until it banks? then you should just put 'Break;' after the Banking;
The way u reverse the boolean its going to repeat twice and stop (false to true, then to false again)
The way I formed it, it sometimes misclicks and wouldn't bank. It would go back to mine for gold and then back to bank, realizing the inventory is still full. The chance for it misclicking twice was super slim, so I altered my procedure so it would repeat twice to avoid the trip back and forth between gold deposit and bank. I could have it do the same thing with "inc," but that would have taken a little bit more code to do the same thing.
From: p1ng
It should only repeat the things you put in before it, but you seem to call the 'Banking' procedure again at the bottom of that repeat loop? I think this is where the problem lies as it tries to complete the entire procedure again if that makes sense?
Hmm.. That is a good theory. I suppose I could move the symbol clicking to the beginning (because there's no reason for that to repeat anyways) and remove "banking;." Though I have a bit of doubt because it only activates that if the walking to the banking spot doesn't work right and it can't see the bank. But it does only double the walking occasionally.. hmm.. That may mean that the walking might bring it to a spot where it can't see the bank occasionally and the failsafe would activate then which would make complete sense. I'll go check it out.
Edit: Eureka! P1ng, you are a genius! It's so smooth now. :]
Tniffoc
2012-07-03 16:29:17
From: Parade
Thank you, guys. You really help out in a pinch.
Edit: So I changed it just slightly. And I ran into a weird bug. (at least I think It's weird)
[PHP]procedure Banking;
var
trueBank: Boolean;
begin
repeat
trueBank := not(trueBank)
if (FindDTM(GoldOre,x,y,MIX1,MIY1,MIX2,MIY2)) then
begin
wait(500+Random(1000));
if (FindBSpot(x,y)) Then
begin
Writeln('Attempting to deposit Gold Ore ');
ClickMouse2(True);
Wait(RandomRange(2250, 2750));
if (FindDTM(GoldOre, x, y, MSX1, MSY1, MSX2, MSY2)) then
begin
Mouse(x,y,3,3,False);
Wait(RandomRange(700,850));
ChooseOption('ll');
wait(400 + Random(150));
end;
end else
begin
SymbolAccuracy := 0.35
FindSymbol(x,y,'bank');
Mouse(x,y,0,0,true);
Wait(RandomRange(1000,1300));
SymbolAccuracy := 0.80
wait(1500+Random(1000));
Banking;
end;
end;
until(trueBank = False)
GoToGold;
end; [/PHP]
What happens is that it will repeat "GoToGold;" too. I thought that putting "until(trueBank = False)" would repeat everything before it.
Put a semicolon at the end of the "until" line.
That should solve your problem!