Results 1 to 4 of 4

Thread: Can't figure out how to use If statement (color script)

  1. #1
    Join Date
    Aug 2013
    Posts
    16
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default Can't figure out how to use If statement (color script)

    So I wanted to try a full color herb cleaner, but instead of DTM it would follow a random manually created pattern. Here was the first pattern I tried but no matter how i word it, it keeps getting errors with the "if" statement. Any help or tips would be appreciated!


    begin
    Counter := 1;
    FailSafe := 0;
    a := 580;
    b := 230;
    writeln('Cleaning Herbs')

    repeat
    Writeln('Counter = ' + IntToStr(Counter));
    if (counter = 2, 3, 4, 10, 11, 12, 18, 19, 20, 26, 27, 28) then
    a := a + 40;
    if (counter = 6, 7, 8, 14, 15, 16, 22, 23, 24) then
    a := a - 40;
    if (counter = 5, 9, 13, 17, 21, 25) then
    b := b + 35;
    end;

    x := a;
    y := b;

    writeln('Cleaning Herbs')
    MMouse(x, y, Random(30), Random(30));
    GetMousePos(x, y);
    wait(random(270)+random(70)+random(70)+random(70)) ;
    HoldMouse(x, y, mouse_Left);
    wait(random(150)+random(75)+random(50));
    ReleaseMouse(x, y, mouse_Left);
    wait(random(150));

    Counter := Counter + 1;
    Until(Counter = 29);

    end.

  2. #2
    Join Date
    Jan 2012
    Posts
    1,596
    Mentioned
    78 Post(s)
    Quoted
    826 Post(s)

  3. #3
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    can you please provide more of an explanation as to what you are trying to achieve, ie the pattern than you are trying to follow?

    A few notable problems, Repeat needs an Until() in order to break the loop (unless you are manually breaking it).

    Example:
    Simba Code:
    if herbInSlot then
    begin
      Repeat
        inc(count);
      Until(count = 3);
    end;

    I would look at For..To..Do loops on the tutorial Turpinator linked; will be invaluable.

  4. #4
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    Simba Code:
    if (counter = 2, 3, 4, 10, 11, 12, 18, 19, 20, 26, 27, 28) then

    You can't list numbers like that... (how it even get compiled?)

    The proper statement would be:

    Simba Code:
    if ( (counter=2)or(counter=3)or(cout conter=4)or(counter=10)...  )

    but it's easier to use a function:

    Simba Code:
    if ( IntInArray([2, 3, 4, 10, 11, 12, 18, 19, 20, 26, 27, 28],counter) )

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
  •