Author Topic: Trouble With Booleans+If/Thens  (Read 259 times)

Offline fearfox20

  • Jr. Member
  • **
  • Posts: 73
  • Rep: 0
    • AOL Instant Messenger - litlebiddlerulz
    • View Profile
    • Email
Trouble With Booleans+If/Thens
« on: August 07, 2010, 09:17:41 am »
The code below is made for a game called Evony. It is supposed to check for two permanent areas of white color to decide whether an account is logged in or not and then from there it is either supposed to Log in and then change "LoggedIn" to true or if its already logged in it should just change the value to true. It also writes in the debug box about whether or not it successfully logged in.
My problem is whenever I run this procedure it always returns "LoggedIn" as false and ignores the color checks.

Code: [Select]
procedure Login;
var
  LoggedIn: Boolean;
  m, n: Integer;
  EmailAddress, Password: String;
begin
  EmailAddress:=('fake@yahoo.com')
  Password:=('fake')
  if FindColor(m, n, 16777215, 58, 319, 76, 335) then
  begin
    LoggedIn:=False;
    wait(100)
    ClickWindMouse(475, 389, 121, 10, true);
    wait(350+random(500))
    sendkeys(EmailAddress);
    wait(350+random(500))
    ClickWindMouse(475, 415, 121, 10, true);
    wait(350+random(500))
    sendkeys(Password);
    wait(350+random(500))
    ClickWindMouse(431, 487, 156, 20, true);
    repeat
      wait(500)
    until FindColor(m, n, 16777215, 378, 529, 478, 538)
    LoggedIn:=True;
  end else
  if FindColor(m, n, 16777215, 378, 529, 478, 538) then
    begin
      LoggedIn:=True;
    end  else
    begin
        LoggedIn:=False;
    end;
  if LoggedIn=True then
  begin
    writeln('We Have Successfully Logged In');
  end else
  begin
    writeln('Failed To Login - Terminating Script');
  end;
end;

EDIT: Figured out my coordinates were off so it wasn't seeing the colors I told it to look for, booleans worked flawlessly.
« Last Edit: August 07, 2010, 09:45:53 am by fearfox20 »

Freddy1990.com

Trouble With Booleans+If/Thens
« on: August 07, 2010, 09:17:41 am »

Offline Freddy

  • Owner
  • *****
  • Posts: 2614
  • Rep: 19
    • MSN Messenger - freddy1990@gmail.com
    • AOL Instant Messenger - Freddy199O
    • View Profile
    • Email
Re: Trouble With Booleans+If/Thens
« Reply #1 on: August 07, 2010, 10:52:19 am »
Hmm, I don't play Evony, so I don't think I can help you with this, sorry =/

Freddy1990.com

Re: Trouble With Booleans+If/Thens
« Reply #1 on: August 07, 2010, 10:52:19 am »

Offline fearfox20

  • Jr. Member
  • **
  • Posts: 73
  • Rep: 0
    • AOL Instant Messenger - litlebiddlerulz
    • View Profile
    • Email
Re: Trouble With Booleans+If/Thens
« Reply #2 on: August 07, 2010, 08:25:27 pm »
That's all sorted out but now I'm having syntax problems. Does scar support "or" with "repeat/until" so you could have two different instances in which the script would stop repeating the loop. What I'm asking is could you have...
Code: [Select]
program Example;
var
  x: integer;

begin
  x:=0;
  repeat
    x:=x+1;
    wait(1000)
  until FindColor(x,y,color,xs,ys,xe,ye) or x=10
end.

I was trying to use it as a simple failsafe in case a page timed out upon loading so the script wouldn't sit there looking for colors indefinitely and I'm pretty sure SCAR supports the "or" statement but I probably have the syntax wrong.
« Last Edit: August 07, 2010, 08:27:07 pm by fearfox20 »

Offline Freddy

  • Owner
  • *****
  • Posts: 2614
  • Rep: 19
    • MSN Messenger - freddy1990@gmail.com
    • AOL Instant Messenger - Freddy199O
    • View Profile
    • Email
Re: Trouble With Booleans+If/Thens
« Reply #3 on: August 08, 2010, 02:28:53 am »
Of course it does, but you have to put comparisons in between brackets...
until FindColor(x,y,color,xs,ys,xe,ye) or (x=10)

Freddy1990.com

Re: Trouble With Booleans+If/Thens
« Reply #3 on: August 08, 2010, 02:28:53 am »