Results 1 to 8 of 8

Thread: InterSCAR...

  1. #1
    Join Date
    Mar 2006
    Location
    United States, -7:00 GMT
    Posts
    1,790
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default InterSCAR...

    I've ventured into using InterSCAR commands, as they are indeed very, very awesome. Here's my two scripts.

    SCAR Code:
    program GrainPicker1;
    {.include SRL\SRL.scar}


    procedure RunFirst;
    begin
      SendInterSCARMessage('Start', 'StartScript');
      writeln('SENT: Start, StartScript');
      repeat
        wait(1000);
        writeln('Waiting for second client.');
      until(ReadInterSCARMessage('Started') = 'ScriptStarted');
      writeln('READ: Started, ScriptStarted');
      Exit;
    end;

    procedure SearchForGate;
    var
      xx, yy : integer;
    begin
      SendInterSCARMessage('Gate', 'FindGate');
      writeln('SENT: Gate, FindGate');
      repeat
        wait(50);
      until(ReadInterSCARMessage('OK') = 'SearchGate');
      writeln('READ: OK, SearchGate');
      if(FindColorSpiralTolerance(xx, yy, 874111, 133, 143, 266, 202, 10))then
      begin
        MMouse(xx, yy, 2, 2);
        wait(50+random(50));
      end;
    end;


    begin
      SetupSRL;
      RunFirst;
      ActivateClient;
      wait(1000);
      SearchForGate;
    end.

    SCAR Code:
    program GrainPicker2;
    {.include SRL\SRL.scar}


    procedure RunSecond;
    begin
      repeat
        wait(50);
      until(ReadInterSCARMessage('Start') = 'StartScript');
      writeln('READ: Start, StartScript');
      SendInterSCARMessage('Started', 'ScriptStarted');
      writeln('SENT: Started, ScriptStarted');
      Exit;
    end;

    procedure Loop;
    var
      xx, yy : integer;
    begin
      repeat
        if(ReadInterSCARMessage('Gate') = 'FindGate')then
        begin
          writeln('READ: Gate, FindGate');
          SendInterSCARMessage('OK', 'SearchGate');
          writeln('SENT: OK, SearchGate');
          repeat
            if(IsUpText('Close'))then
            begin
              GetMousePos(xx, yy);
              Mouse(xx, yy, 2, 2, True);
              wait(1000);
              SendInterSCARMessage('Found', 'ClickedGate');
              writeln('SENT: Found, ClickedGate');
            end;
          until(False);
        end;
      until(False);
    end;

    begin
      SetupSRL;
      RunSecond;
      Loop;
    end.


    Here's #1's debug box.

    SENT: Start, StartScript
    Waiting for second client.
    Waiting for second client.
    READ: Started, ScriptStarted
    SENT: Gate, FindGate
    READ: OK, SearchGate
    Here's #2's debug box.

    File access error
    SRL Compiled in 234msec.
    READ: Start, StartScript
    SENT: Started, ScriptStarted
    READ: Gate, FindGate
    SENT: OK, SearchGate
    SENT: Found, ClickedGate

    K, so my main question is...what is the File access error for? Thanks!
    (btw, everyone went as planned, clicked it and all.)

    hakuna matata ;)

  2. #2
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    FileAcces is because you most likely once denied access to an SRL Feature.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  3. #3
    Join Date
    Mar 2006
    Location
    United States, -7:00 GMT
    Posts
    1,790
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    Hm. Ok thanks. I'll check into it.


    Alsoo.......Is there a way to free up a channel? I'm a little mad at how when you stop a script and then run it again, the channel info is still inside the script. So is there a clearchannel; type function anywhere? That'd be really nice instead of having to have different' channels. Thanks!

    hakuna matata ;)

  4. #4
    Join Date
    Aug 2006
    Location
    London
    Posts
    2,021
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    you could do SendInterScarMessage(channel,'');
    those messages are just stored in a variable which many programs can access,
    the variable is declared when scar first sends a ISM and are free'd when scar is closed (not when the script ends)
    Join the Official SRL IRC channel. Learn how to Here.

  5. #5
    Join Date
    Mar 2006
    Location
    United States, -7:00 GMT
    Posts
    1,790
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    So I could name everything 'Channel', 'NameHere' and it will get that. Someone said I had to have own seperate channels.....


    And Yakman, I really don't want to close SCAR every time after testing

    hakuna matata ;)

  6. #6
    Join Date
    Aug 2006
    Location
    London
    Posts
    2,021
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Ejjman1 View Post
    And Yakman, I really don't want to close SCAR every time after testing
    then put SendInterScarMessage('YourChannel,''); as your first command after SetupSRL; to clear the value
    Join the Official SRL IRC channel. Learn how to Here.

  7. #7
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Look at how I setup MouseHelper

    SCAR Code:
    program New;

    procedure  SetUpMouseHelper;
    var MSCW, MSCH:integer;
    begin
      if not(ReadInterSCARMessage('MHStatus')='on') then
      begin
        status('MouseHelper set up incorrectly.');
        writeln('MouseHelper set up incorrectly.');
        writeln('Terminating scripts.');
        terminatescript
      end;
      SendInterSCARMessage('MS2MHCommand','null');
      SendInterSCARMessage('MS2MHSetMouseSpeed','end');
      status('Testing MouseHelper set-up');
      SendInterSCARMessage('MH2MSTestResult','qwerty');
      getclientdimensions(MSCW,MSCH);
      SendInterSCARMessage('MS2MHTest',inttostr(MSCW)+'*'+inttostr(MSCH));
      repeat
      wait(5);
      until ((not(ReadInterSCARMessage('MH2MSTestResult')='qwerty')) or (ReadInterSCARMessage('MS2MHTest')='qwerty'));
      if (ReadInterSCARMessage('MH2MSTestResult')='success') then
      begin
        status('MouseHelper set up correctly.');
        writeln('MouseHelper set up correctly.');
      end;
      if ((ReadInterSCARMessage('MH2MSTestResult')='failure') or (ReadInterSCARMessage('MS2MHTest')='qwerty')) then
      begin
        if (ReadInterSCARMessage('MS2MHTest')='qwerty') then SendInterSCARMessage('MS2MHCommand','terminate');
        status('MouseHelper set up incorrectly.');
        writeln('MouseHelper set up incorrectly.');
        writeln('Terminating scripts.');
        terminatescript;
      end;
    end;

    begin
    setupmousehelper;
    activateclient;
    repeat
    wait(10);
    until isfkeydown(12);
    end.

    SCAR Code:
    procedure SetUpMouseHelperMH;
    var MHCW, MHCH, MSCW, MSCH, MSV, iter, SecondsTilMHStop :integer; MHTestString: array of string;
    begin
      SendInterSCARMessage('MHStatus','on');
      SendInterSCARMessage('MS2MHCommand','null');
      SendInterSCARMessage('MS2MHTest','qwerty');
      GetClientDimensions(MHCW,MHCH);
      status('Waiting for Main Script to start');
      writeln('On the Main Script: Set the crosshairs and click run');
      repeat
        wait(5);
      until ((not(ReadInterSCARMessage('MS2MHTest')='qwerty')) or (ReadInterSCARMessage('MS2MHCommand')='terminate'));
      if (ReadInterSCARMessage('MS2MHCommand')='terminate') then
      begin
        status('MouseHelper set up incorrectly.');
        writeln('MouseHelper set up incorrectly.');
        writeln('Terminating scripts.');
        SendInterSCARMessage('MHStatus','off');
        terminatescript;
      end;
      MHTestString:=ExplodeMH('*',ReadInterSCARMessage('MS2MHTest'));
      MSCW:=strtoint(MHTestString[0]);
      MSCH:=strtoint(MHTestString[1]);
      MSV:=strtoint(MHTestString[2]);
      if ((inttostr(MHCW)=inttostr(MSCW))and(inttostr(MHCH)= inttostr(MSCH))and(MSV=MouseHelperVersion))then
      begin
        SendInterSCARMessage('MH2MSTestResult','success');
        status('MouseHelper set up correctly.');
        writeln('MouseHelper set up correctly.');
        activateclient;
      end;
      if not((inttostr(MHCW)=inttostr(MSCW))and(inttostr(MHCH)= inttostr(MSCH)))then
      begin
        cleardebug;
        SendInterSCARMessage('MH2MSTestResult','failure');
        status('MouseHelper set up incorrectly.');
        writeln('MouseHelper set up incorrectly.');
        writeln('Terminating scripts.');
        SendInterSCARMessage('MHStatus','off');
        terminatescript;
      end;
      if not(MSV=MouseHelperVersion) then
      begin
        SendInterSCARMessage('MH2MSTestResult','VersionError');
        SecondsTilMHStop:=21;
        cleardebug;
        repeat
          SecondsTilMHStop:=SecondsTilMHStop-1;
          writeln('This is MouseHelper Version '+inttostr(MouseHelperVersion)+'. The Main Script is using Version '+inttostr(MSV)+'.');
          writeln('Hopefully this will not be a problem, but it may cause errors.');
          writeln('I will continue anyway unless you press F11 twice in '+inttostr(SecondsTilMHStop)+' seconds.');
          iter:=0;
          repeat
            iter:=iter+1;
            wait(5);
          until ((iter=200) or (isfkeydown(11)));
          cleardebug;
        until ((SecondsTilMHStop=0) or (isfkeydown(11)));
        if (SecondsTilMHStop>0) then
        begin
          SendInterSCARMessage('MH2MSTestResult','failure');
          writeln('You pressed F11 to terminate scripts due to non matching versions');
          writeln('Terminating scripts.');
          SendInterSCARMessage('MHStatus','off');
          terminatescript;
        end;
        if (SecondsTilMHStop=0) then
        begin
          SendInterSCARMessage('MH2MSTestResult','success');
          status('Versions do not match but going ahead anyway.');
          writeln('Versions do not match but going ahead anyway.');
          activateclient;
        end;
      end;

    end;

  8. #8
    Join Date
    Mar 2006
    Location
    United States, -7:00 GMT
    Posts
    1,790
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    O..........

    I see. Ty. That makes more sense.

    hakuna matata ;)

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
  •