Results 1 to 12 of 12

Thread: Why ISN'T IT running

  1. #1
    Join Date
    Mar 2010
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Why ISN'T IT running

    Hi Guys 'n Girls,

    Made these simple SendArrowWait script to solve a maze where the price can be put at 4 spots. You can't see where it is from start and sorta have to try find it by checking all the spots. Anyway, I made the scripts go to the spots and they work decently, with a few failures from time to time as the maze moves JUST a tiny bit sometimes. I can live with that for now though.

    My problem is when I'm trying to combine my procedures it run the Fail and Profit procedures even though the colors in the given sqaure aint 'TRUE'. I will link my script:


    SCAR Code:
    begin
    UpperLeft
    if(FindColor(x, y, 255, 509, 147, 533, 168))then;
                    Begin
                    Fail
                    end;
    if(FindColor(x, y, 3895377, 747, 188, 792, 247))then;
                    Begin
                    Profit
                    end;
    UpperRight
    end.

    Any suggestions?

  2. #2
    Join Date
    Feb 2009
    Posts
    1,447
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    There shouldn't be any semi-colons after "then".
    However, there should be semicolons after profit, fail and UpperLeft.

    Fix:
    SCAR Code:
    begin
      UpperLeft;
      if(FindColor(x, y, 255, 509, 147, 533, 168))then
      Begin
        Fail;
      end;
      if(FindColor(x, y, 3895377, 747, 188, 792, 247))then
      Begin
        Profit;
      end;
      UpperRight;
    end.

  3. #3
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    also, please read up on the coding "standards" that SRL has.

  4. #4
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    And for single actions after an if..then statement, no begin..end is needed.

  5. #5
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by i luffs yeww View Post
    And for single actions after an if..then statement, no begin..end is needed.
    But depending who you ask, and how far into development you are, some would suggest putting begin and end on at all times.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  6. #6
    Join Date
    Mar 2010
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I started scripting 4 weeks ago, so I'm still quite fresh. But thanks for the quick respons. Been reading alot of beginner guides, but seems I ain't done with that yet.

    Thanks for the help it works now. Gonna go spend alot of time perfecting it now.

    +rep TRiLeZ
    Last edited by Mort; 03-13-2010 at 12:14 PM.

  7. #7
    Join Date
    Mar 2010
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Just a small extra question if you guys don't mind. :-)

    If it runs the Profit command I would like it to start the whole script over, but if it doesn't profit after running UpperLeft, UpperRight and Lowers (which means it failed due to hitting an obstacle or something like that) it should only repeat these scripts. So far my combined procedures looks like this:

    SCAR Code:
    begin
      EnterMaze
      UpperLeft;
      if(FindColor(x, y, 255, 509, 147, 533, 168))then
      Begin
        Fail;
      end;
      if(FindColor(x, y, 3895377, 747, 188, 792, 247))then
      Begin
        Profit;
      end;
      wait(500+Random(50));
      UpperRight;
      if(FindColor(x, y, 255, 509, 147, 533, 168))then
      Begin
        Fail;
      end;
      if(FindColor(x, y, 3895377, 747, 188, 792, 247))then
      Begin
        Profit;
      end;
      wait(500+Random(50));
      Lowers;
      if(FindColor(x, y, 255, 509, 147, 533, 168))then
      Begin
        Fail;
      end;
      if(FindColor(x, y, 3895377, 747, 188, 792, 247))then
      Begin
        Profit;
      end;
      wait(500+Random(50));
    end.

    Don't know if this is asking too much, but would be nice if you elitists at Scar could at least point me in the right direction! ;-)

  8. #8
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    You COULD use a goto.. x] haha but I'm pretty sure those are frowned upon. I dunno.

    Other than that, you could just do..

    SCAR Code:
    if(FindColor(blahblahblah))then
      begin
        Profit;
        EnterMaze;
      end;

    (That's assuming EnterMaze is the start procedure. ) Sorry if that's not what you want at all, I'm pretty tired right now.

  9. #9
    Join Date
    Mar 2010
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    EnterMaze is just the first script to run, which is needed to be run after Profit, so I'll get a loop going. If that made any sense xD

    @i luffs yeww: Np mate! :P

  10. #10
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Can you post the whole script?

  11. #11
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Maybe try using a label and goto?

    http://villavu.com/forum/showthread....ght=Label+GoTo

  12. #12
    Join Date
    Mar 2010
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I made a minor modification to the script so EnterMaze will only run if a color is present and then run the EnterMaze after each 'go-to' scripts and have the entire script repeat infinite. Thanks for the help through it all though guys

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
  •