Results 1 to 7 of 7

Thread: Inventory.scar DropItem();

  1. #1
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default Inventory.scar DropItem();

    Just shortened it up a bit...

    Old version:
    SCAR Code:
    {*******************************************************************************
    procedure DropItem(i: Integer);
    By: Lorax
    Description: Drops item at given position (1-28)
    *******************************************************************************}

    function DropItem(i: Integer): Boolean;
    begin
      Result := False;
      if ExistsItem(i) then
      begin
        MouseItem(i, False);
        if (WaitOptionEx('rop', 'action', ClickLeft, 250)) then
        begin
          Result := True;
          Wait(RandomRange(50, 200));
        end;
      end;
    end;
    My version:
    SCAR Code:
    {*******************************************************************************
    procedure DropItem(i: Integer);
    By: Lorax
    Description: Drops item at given position (1-28)
    *******************************************************************************}

    function N_DropItem(i: Integer): Boolean;
    begin
      Result := False;
      if ExistsItem(i) then
      begin
        MouseItem(i, False);
        Result := (WaitOptionEx('rop', 'action', ClickLeft, 250));
      end;
    end;

  2. #2
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    meh sometimes readability isn't such a bad thing. Unless the speed is a huge increase in your fix I don't really see the point :/ It just complicates things and people can't understand it anymore (unless you go and read WaitOptionEx which is time consuming for the lazy )

    none the less, nice
    “Ignorance, the root and the stem of every evil.”

  3. #3
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    No this really doesn't effect much. I've just been going through the include more lately fixing up what I can.

  4. #4
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    You only took the random wait away which I don't think is a good idea?

  5. #5
    Join Date
    Feb 2010
    Location
    England
    Posts
    56
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I agree with marpis,

    fair enough when something is like..

    SCAR Code:
    if a then
    begin
      Result := true;
    end else
    begin
      Result := false;
    end;

    then It'd be much better to simply do..

    SCAR Code:
    Result := a;

    however, the if clause contained 2 expressions, Result assignment and Random wait, so.. while it is a shortened version, it doesn't work the same.

    ...and if you were to just "add it on", like...

    SCAR Code:
    {*******************************************************************************
    procedure DropItem(i: Integer);
    By: Lorax
    Description: Drops item at given position (1-28)
    *******************************************************************************}

    function N_DropItem(i: Integer): Boolean;
    begin
      Result := False;
      if ExistsItem(i) then
      begin
        MouseItem(i, False);
        Result := (WaitOptionEx('rop', 'action', ClickLeft, 250));
        Wait(RandomRange(50, 200));
      end;
    end;

    then it'd wait if WaitOptionEx was true/false, not just true like in the original code

    void_hatred

  6. #6
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Personally in my scripts I take care of random waits and what not on my own so I just didn't think about a wait after the function being necessary. I see where you both are coming from though.

  7. #7
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    Personally in my scripts I take care of random waits and what not on my own so I just didn't think about a wait after the function being necessary. I see where you both are coming from though.
    Most people drop like
    SCAR Code:
    for i := n to 28 do
      DropItem(i);
    Also DropAllExcept, DropAll call DropItem without waiting after it.

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
  •