Results 1 to 11 of 11

Thread: text.scar

  1. #1
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default text.scar

    Okay so this is my first attempt at contributing to SRL, and I wanted to know what you guys think. It's nothing advanced at all, it was just something that I found easier when making a script, as I used the same coding more than once.

    It would be used in situations like opening a door/gate, or climbing a stile/rock wall.

    SCAR Code:
    {*******************************************************************************
    function ClickMouseOption(x, y, rx, ry: Integer; Option: String; UpText, ChooseOpt: TStringArray): Boolean;
    By: Coh3n
    Description: Either clicks the specified option, or right clicks and chooses the
                 option, or random click/right click, and chooses the option.
                 i.e ClickMouseOption(x, y, 4, 4, 'Random', ['Gate'], ['Open']);
    *******************************************************************************}


    function ClickMouseOption(x, y, rx, ry: Integer; Option: String; UpText, ChooseOpt: TStringArray): Boolean;
    begin
      if not InStrArr(Option, ['random', 'right', 'left'], False) then SRL_Warn;
      Result := WaitUpTextMulti(UpText, 100 + Random(400));
      if not Result then SRL_Warn;
      if Option = 'random' then
        case Random(2) of
          0: Option := 'left';
          1: Option := 'right';
        end;
      Mouse(x, y, rx, ry, Option = 'left');
      if Option = 'right' then
        ChooseOptionMulti(ChooseOpt);
    end;

    //Reflection version, basically the same thing.
    function R_ClickMouseOption(x, y, rx, ry: Integer; Option: String; UpText, ChooseOpt: TStringArray): Boolean;
    begin
      if not InStrArr(Option, ['random', 'right', 'left'], False) then SRL_Warn;
      Result := WaitUpTextMulti(UpText, 100 + Random(400));
      if not Result then SRL_Warn;
      if Option = 'random' then
        case Random(2) of
          0: Option := 'left';
          1: Option := 'right';
        end;
      Mouse(x, y, rx, ry, Option = 'left');
      if Option = 'right' then
        R_ChooseActionMulti(ChooseOpt);
    end;

    Thanks to Da 0wner for helping me shorten it A LOT.

    Don't be too hard on me.
    Last edited by Coh3n; 07-15-2009 at 01:29 AM.

  2. #2
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Could be shortened.

    Btw, get on MSN .
    Last edited by Da 0wner; 07-11-2009 at 10:20 AM.

  3. #3
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    You can remove all the lines of Wait(80 + Random(500)), as sufficient wait time is already included in the WaitUpTextMulti.

  4. #4
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by senrath View Post
    You can remove all the lines of Wait(80 + Random(500)), as sufficient wait time is already included in the WaitUpTextMulti.
    Yeah I've got a much shorter version after talking to Kyle, I'll update it soon.

  5. #5
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    if not InStrArr(Option, ['random', 'right', 'left'], False) then Exit;
    It is InStrARRAY, If I'm correct so wouldn't Option be ChooseOption?
    Or is it you check 1 string by an array of strings and it will result true or false.
    ~Hermen

  6. #6
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Don't question my methods Hermen .

    That returns true if it is a valid option. Returns false if it is not.

  7. #7
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Hermen View Post
    It is InStrARRAY, If I'm correct so wouldn't Option be ChooseOption?
    Don't think so, got it straight from the manual + what Da 0wner said.

    EDIT: Added the Reflection version, which is basically the same thing.

  8. #8
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Look up SRL error throwing - rather than just exiting, it should clearly shout at the scripter for being silly not to pass a valid argument. Possibly a numeric argument instead
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  9. #9
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yes, my version had SRL_Warn in it, but he decided not to use .

  10. #10
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Da 0wner View Post
    Yes, my version had SRL_Warn in it, but he decided not to use .
    What?

    Lol, it did?

    Quote Originally Posted by mixster View Post
    Look up SRL error throwing - rather than just exiting, it should clearly shout at the scripter for being silly not to pass a valid argument. Possibly a numeric argument instead
    Thanks, added.
    Last edited by Coh3n; 07-15-2009 at 01:31 AM.

  11. #11
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yep. Doesn't matter, you can add your own in .

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
  •