Results 1 to 3 of 3

Thread: If Else Statements?

  1. #1
    Join Date
    Jul 2008
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default If Else Statements?

    I know I just posted another question but scar manual really doesn't explain much ><. I got this if else statement and I want it to find 2 different colors. There are 4 different sized boxes that get bigger if it isn't found in one of the smaller boxes. Once it is found I want it to record the color and go straight to my color-clicking script. I thought and If Else statement would work but there seems to be a problem at the second 'end else'. Here is my entire code so far.

    Code:
    program AutoHunter;
    var //set the variables' types
    COLOR1, COLOR2, X, Y, XS1, XE1, YS1, YE1, XS2, YS2, XE2, YE2, XS3, XE3, YS3, YE3, XS4, YS4, XE4, YE4, FOUND : integer;
    
    procedure DefineVariables; //set the variables' values.
    begin
    FOUND := 0;
    COLOR1 := 9688060;
    COLOR2 := 800847;
    X := 0;
    Y := 0;
    XS1 := 462;
    XE1 := 562;
    YS1 := 334;
    YE1 := 434;
    XS2 := 412;
    XE2 := 612;
    YS2 := 284;
    YE2 := 484;
    XS3 := 312;
    XE3 := 712;
    YS3 := 184;
    YE3 := 584;
    XS4 := 212;
    XE4 := 812;
    YS4 := 84;
    YE4 := 684;
    writeln('variables successfully defined'); //*DEBUGGING ELEMENT*//
    end;
    
    procedure FindColor; //Finding the color and recording the coordinates
    begin
    if(FOUND = 0)then //Find COLOR1 in coords XS1 YS1 XE1 YE1
             begin
                  FindColorSpiral(X, Y, COLOR1, XS1, YS1, XE1, YE1);
                  FOUND := 0;
             end else
                  begin
                       FindColorSpiral(X, Y, COLOR2, XS1, YS1, XE1, YE1);
                       FOUND := 0;
                  end else
                      begin
                           FindColorSpiral(X, Y, COLOR1, XS2, YS2, XE2, YE2);
                           FOUND := 0;
                      end else
                             begin
                                  FindColorSpiral(X, Y, COLOR2, XS2, YS2, XE2, YE2);
                                  FOUND := 0;
                             end else
                                    begin
                                         FindColorSpiral(X, Y, COLOR1, XS3, YS3, XE3, YE3);
                                         FOUND := 0;
                                    end else
                                       begin
                                            FindColorSpiral(X, Y, COLOR2, XS3, YS3, XE3, YE3);
                                            FOUND := 0;
                                       end else
                                              begin
                                                   FindColorSpiral(X, Y, COLOR1, XS4, YS4, XE4, YE4);
                                                   FOUND := 0;
    
                                              end else
                                                  begin
                                                       FindColorSpiral(X, Y, COLOR2, XS4, YS4, XE4, YE4);
                                                       FOUND := 0;
                                                  end else
    writeln('no colors found'); //*DEBUGGING ELEMENT*//
    end;
    
    procedure ClickColor;
    begin
    MoveMouseSmooth(X, Y);
    end;
    
    BEGIN
    DefineVariables;
    FindColor;
    ClickColor;
    END.
    Failed when compiling
    Line 47: [Error] (46:5): Identifier expected in script C:\Program Files\SCAR 3.15\Scripts\LuminaryAutoHunter.scar
    I also looked for a switch in scar but there wasn't one. Any help?

  2. #2
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    you are doing else on an else statement. that's why it doesn't work.

    edit: if yu look at it like this you should be able to spot the mistake:

    scar Code:
    procedure FindColor; //Finding the color and recording the coordinates
    begin
      if(FOUND = 0)then //Find COLOR1 in coords XS1 YS1 XE1 YE1
      begin
        FindColorSpiral(X, Y, COLOR1, XS1, YS1, XE1, YE1);
        FOUND := 0;
      end else begin
        FindColorSpiral(X, Y, COLOR2, XS1, YS1, XE1, YE1);
        FOUND := 0;
      end else begin
        FindColorSpiral(X, Y, COLOR1, XS2, YS2, XE2, YE2);
        FOUND := 0;
      end else begin
        FindColorSpiral(X, Y, COLOR2, XS2, YS2, XE2, YE2);
        FOUND := 0;
      end else begin
        FindColorSpiral(X, Y, COLOR1, XS3, YS3, XE3, YE3);
        FOUND := 0;
      end else begin
        FindColorSpiral(X, Y, COLOR2, XS3, YS3, XE3, YE3);
        FOUND := 0;
      end else begin
        FindColorSpiral(X, Y, COLOR1, XS4, YS4, XE4, YE4);
        FOUND := 0;
      end else begin
        FindColorSpiral(X, Y, COLOR2, XS4, YS4, XE4, YE4);
        FOUND := 0;
      end else
        writeln('no colors found'); //*DEBUGGING ELEMENT*//
    end;

    else only works after an if, although you might be thinking of ElseIf if you are familiar with other languages.
    I think what you intend to do is
    If Found = 0 then (check next color)

    for that you would need:

    scar Code:
    if not FindColorSpiral(...) then
      Found := 0;

    and finally, you might wish to use FindColorSpiralTolerance as the colors change in runescape

    happy scripting!

    ~RM
    Last edited by Sir R. M8gic1an; 03-23-2009 at 07:02 PM.

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  3. #3
    Join Date
    Jul 2008
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thank you. I think I'll use a different method though. This one seems a little buggy :S

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •