Results 1 to 22 of 22

Thread: DTM to item slot locating

  1. #1
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default DTM to item slot locating

    This is kinda hard for me to explain so I'll give an example.

    In my script, I use FindDTM to determine if I have a certain item within my inventory tab. I want to use that information to determine in which inventory slot it's in in order to use "Dropitem(i)", and "i" being the item's DTM that was located.

    I haven't looked into how SRL determines inventory slots, maybe it's based on a set X/Y parameter, if so then could you not grab the x/y coords of the DTM and match it to the inventory's slot x/y parameter to determine which slot it's in?

    Also, same question but for bitmaps as well.
    Last edited by Flight; 02-25-2011 at 02:49 PM.

  2. #2
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Simba Code:
    procedure DropIt;
    var
      TheDTM, i: Integer;
      Box: TBox;
    begin
      TheDTM := DTMFromString('asdfhiosd');
      for i := 1 to 28 do
      begin
        Box := InvBox(i);
        if FindDTM(TheDTM, Box.X1, Box.Y1, Box.X2, Box.Y2) then
          Break;
      end;
      FreeDTM(TheDTM);
      DropItem(i);
    end;

  3. #3
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Nice, I've never heard of TBox. Thanks bud.

    Edit: "Invalid number of parameters at line 81"
    This is line 81:
    Simba Code:
    if FindDTM(TheDTM, Box.X1, Box.Y1, Box.X2, Box.Y2) then
    I don't get it :/ Am I missing something?
    Last edited by Flight; 02-25-2011 at 03:09 PM.

  4. #4
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Possibly tolerance?
    There used to be something meaningful here.

  5. #5
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    6,136
    Mentioned
    28 Post(s)
    Quoted
    17 Post(s)

    Default

    We also have the function InvBox. It Returns TBox of surrounding Inventory SlotBox
    1-2-3-4
    5-6-7-8
    etc.

    check out inventory.scar located in SRL/core
    SRL is a Library of routines made by the SRL community written for the Program Simba.
    We produce Scripts for the game Runescape.

  6. #6
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by WT-Fakawi View Post
    We also have the function InvBox. It Returns TBox of surrounding Inventory SlotBox
    1-2-3-4
    5-6-7-8
    etc.

    check out inventory.scar located in SRL/core
    Yeah TomTuff had used it to define the "Box" parameters, but why would that be an invalid number of parameters when they're defined already? My logic tells me at the point "Box := InvBox(i);" then the Box.X1,Y1, ect... should be defined already.

  7. #7
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    You are missing 2 parameters, the X and Y variable is missing.

    FindDTM(TheDTM, X, Y, Box.X1, Box.Y1, Box.X2, Box.Y2)

  8. #8
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Ha, leave it to Zyt3x to save the day. Although, that's not the error I'd expect for lack of variables. I thought it would return something like "Type mismatch". Thanks everyone for the help, and I apologize for the stupid questions.

  9. #9
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    6,136
    Mentioned
    28 Post(s)
    Quoted
    17 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    I apologize for the stupid questions.
    there are no stupid questions when you are stuck.
    SRL is a Library of routines made by the SRL community written for the Program Simba.
    We produce Scripts for the game Runescape.

  10. #10
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    Ha, leave it to Zyt3x to save the day. Although, that's not the error I'd expect for lack of variables. I thought it would return something like "Type mismatch". Thanks everyone for the help, and I apologize for the stupid questions.
    Haha, there's nothing to apologize for

    In Simba you can do CTRL + Space to show information about what parameters you need

    I.E typing FindDTM + CTRL + Space will show "function FindDTM(DTM : Integer; var X, Y : Integer; xs, ys, xe, ye : Integer);" (or something similar to that)

  11. #11
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    I wish I knew that a long time ago. :S To find out what parameters I need for a function I just go delete the first "(" following, then retype it to bring up the popup box that shows what variables the function is composed up, and that's what I've been relying on.

  12. #12
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Now I'm having trouble with this error:
    Code:
    ** Warning in InvBox: Incorrect index: 29**
    Warning! You passed a wrong xs to a finder function: -1. That is below 0, thus out of bounds. Setting the value to 0 for now.
    Warning! You passed a wrong ys to a finder function: -1. That is below 0, thus out of bounds. Setting the value to 0 for now.
    Here's the bit of code that's throwing the error:
    Simba Code:
    if (Clicked = True) then
      begin
        for i := 1 to 28 do
        begin
          Box := InvBox(i);
          if FindDTM(DTM,x,y,Box.X1,Box.Y1,Box.X2,Box.Y2) then
            Break;
        end;
        FreeDTM(DTM);
        if(DropItem(i)) then
          Clicked := False;
      end;
    Any ideas of why it's trying to search for outside the 1-28 parameters for #29? Any ways the script works fine minus this error. If you have ideas please lemme know. I'll check back on this in the morning, I've had enough for one night.

  13. #13
    Join Date
    Jan 2011
    Location
    Denver, CO
    Posts
    1,351
    Mentioned
    2 Post(s)
    Quoted
    72 Post(s)

    Default

    You could try using this function instead:
    SCAR Code:
    {*******************************************************************************
    function ExistsItemDTM(dtm: Integer; var x, y: Integer): Boolean;
    By: NCDS
    Description: Checks if the item with dtm is in the inventory. Returns the item's
                 coordinates.
    *******************************************************************************}

  14. #14
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Simba Code:
    if FindDTM(TheDTM, x, y, Box.X1, Box.Y1, Box.X2, Box.Y2) then
      Item:=CoordsToItem(x, y);
    FreeDTM(TheDTM);
    DropItem(Item);

  15. #15
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    Now I'm having trouble with this error:
    Code:
    ** Warning in InvBox: Incorrect index: 29**
    Warning! You passed a wrong xs to a finder function: -1. That is below 0, thus out of bounds. Setting the value to 0 for now.
    Warning! You passed a wrong ys to a finder function: -1. That is below 0, thus out of bounds. Setting the value to 0 for now.
    Here's the bit of code that's throwing the error:
    Simba Code:
    if (Clicked = True) then
      begin
        for i := 1 to 28 do
        begin
          Box := InvBox(i);
          if FindDTM(DTM,x,y,Box.X1,Box.Y1,Box.X2,Box.Y2) then
            Break;
        end;
        FreeDTM(DTM);
        if(DropItem(i)) then
          Clicked := False;
      end;
    Any ideas of why it's trying to search for outside the 1-28 parameters for #29? Any ways the script works fine minus this error. If you have ideas please lemme know. I'll check back on this in the morning, I've had enough for one night.
    The reason why it goes to 29 is because it didn't find the dtm in any of those boxes. Doing what MylesMadness said with a tiny failsafe added to it would work:
    Simba Code:
    if FindDTM(TheDTM, x, y, Box.X1, Box.Y1, Box.X2, Box.Y2) then
      Item:=CoordsToItem(x, y);
    FreeDTM(TheDTM);
    if Item <> 0 then
      DropItem(Item)
    else
      WriteLn('Didn''t find DTM');

  16. #16
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    I'm not really sure why, but having adjusted it like you'd gave in your example it's dropping "all" my items. Never mind, I give up with using conventional methods, I'll create my own dtm locate/drop method. Thanks anyways :/

  17. #17
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    I'm not really sure why, but having adjusted it like you'd gave in your example it's dropping "all" my items. Never mind, I give up with using conventional methods, I'll create my own dtm locate/drop method. Thanks anyways :/
    It's because you don't break from the loop after you drop the item.

  18. #18
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Yeah I had forgotten about the Break; you used in your earlier example script, that's probably why, but I've used some other methods to make this world correctly now and it works perfectly now if I do say so myself. :P

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

    Default

    If you search for something in the whole inventory and want to know which slot it is in, there should be something like CoordToItemSlot., kinda like the reverse of InvBox.

  20. #20
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Yes Boreas I found that function and that's what I'm using now, it works very well, thank you.

    I noticed you're the one who wrote it to. :P

  21. #21
    Join Date
    Nov 2008
    Location
    Melbourne, Australia
    Posts
    2,240
    Mentioned
    3 Post(s)
    Quoted
    11 Post(s)

    Default

    Or you can just right click the DTM and ChooseOption('drop');
    Click here to find out how to get full screen without members! | Click here to check out my Ultimate Bitmap Tutorial! Edited to work with Simba! |

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

    Default

    Quote Originally Posted by Flight View Post
    Yes Boreas I found that function and that's what I'm using now, it works very well, thank you.

    I noticed you're the one who wrote it to. :P
    No problem, I just noticed that Myles already mentioned it heh.

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
  •