Results 1 to 4 of 4

Thread: CountItemsDTM(itemdtm: integer);

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

    Default CountItemsDTM(itemdtm: integer);

    I found the CountItems function quite hard to use, in fact, i didnt understand it. I made a simplier one, that only uses dtms (dtms are the only real usable way to find items in inventory in most cases, as we all know)

    It does NOT tell you how many arrows you have or such. It DOES tell you how many logs, bones or lobsters etc you have.


    SCAR Code:
    function CountItemsDTM(itemdtm: Integer) : integer;
    var i : integer;                                  
    Box : TBox;
    begin
     for i:= 1 to 28 do
     begin
      Box:= InvBox(i);
      if ExistsItem(i) then
       begin
        if FindDtm(itemdtm, x, y, Box.x1, Box.y1, Box.x2, Box.y2) then
        Inc(Result);
       end;
     end;
    end;

  2. #2
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    I don't see why this function would be included for various reasons;

    definitely good practice and a good function, useful and simple to understand.

    But, the one that exists in srl already does this, only to a much larger degree. It's a question of reading better, and if you don't understand it you cn always ask for help on how to use it, as there are always helpful people online, either in the help forums or in the IRC channel.

    Also, SRL sort of has a "rule" that if a function is easy and simple enought (and short) to do, it does not really need to be in the include. I mean, you have a perfect use of a TBox there. Kudos. But it is also true that many people, such as yourself, could make that function if they really needed it and did not want to use the one in srl.

    SRL actually used to have CountDTM and CountBMP, it was just replaced by a more global one, so this wold jsut ort of be taking a step back (which is not necssarily bad).


    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  3. #3
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quick tutorial:

    SCAR Code:
    function CountItems(identifier: Integer; identifiertype: string; tol: TIntegerArray): Integer;

    Identifer is the variable that holds the bmp, bitmap mask, dtm or colour of the item you're searching for.
    IdentifierType is the type of identifier obviously, that is 'dtm', 'bmp', 'bmpmask', 'color'.
    Tol is an array of integers that contains information on the tolerance and the contour tolerance (in the case of bitmap masks). The length of this array can range from 0 for dtms (dtms do no need tolerance), 1 for colour and bitmaps where the value is the tolerance of the colour and the bitmap or 2 for bitmap masks where the first value is the bmp tolerance and the second value is the contour tolerance.

    Examples:

    DTMS:
    SCAR Code:
    ItemCount := CountItems(DTM, 'dtm', []); //array length is 0

    Colour:
    SCAR Code:
    ItemCount := CountItems(65536, 'color', [10]);

    Bitmaps:
    SCAR Code:
    ItemCount := CountItem(BMP, 'bmp' , [50]);

    Bitmap Masks:
    SCAR Code:
    ItemCount := CountItem(BMPMask, 'bmpmask', [50, 10]);

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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. CountItemsDTM
    By D1zl3 in forum OSR Help
    Replies: 2
    Last Post: 10-13-2008, 06:31 PM
  2. 'CountItemsDTM'
    By brad734 in forum OSR Help
    Replies: 4
    Last Post: 10-01-2008, 01:21 PM
  3. function SendKeyboard(FKey:Integer; Text:String): Integer;
    By Daniel in forum Research & Development Lounge
    Replies: 4
    Last Post: 07-18-2007, 04:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •