Page 1 of 2 12 LastLast
Results 1 to 25 of 45

Thread: Bank Browsing- BlackLists

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

    Default Bank Browsing- BlackLists

    Bank Browsing- BlackLists

    Level: Intermediate


    Follow up tutorial (read this first) BlackLists with color

    About B4 and this series of tutorials-

    I am developing a system called B4 (Bank Browser By Boreas) made up of functions for finding, withdrawing, and depositing bank items. It will be fast and efficient, using techniques especially designed for using minimal resources and still getting the job done. One of the features will be only searching for something once, and then remembering where it is. It will also be easy to use, with high level functions like MakeInventory('18 coal, 9 iron'); that will take care of everything. It will also make DTM/bitmap/color creation easier, so you can spend more time scripting. As well as the high level functions like MakeInventory, it will contain many lower level functions that you can combine to make your own personalized higher level functions. This series of tutorials will teach you how to use the functions, and how they work. It is partly a user manual for the B4 system, but it is also a series of scripting tutorial, teaching problem solving, scripting techniques, and ways of thinking. The more you know about how something works, the better you can use it. All of these tutorials will be labeled intermediate or advanced. The material will not be too tricky, but I do expect you to be comfortable with arrays etc. Also, B4 will make banking very easy, but I still want beginner scripters to learn the old fashioned way of doing it. Therefore, these tutorials are for intermediate-advanced scripters who want to spend less time writing banking routines and more time on interesting things, although you may also learn some scripting techniques too.

    About this tutorial-

    BlackLists are lists of black dots, duh. Let me explain. A great way of finding items in the bank and inventory is by making a DTM containing points on the black(65536) outline of the item, because it never changes. (Note a DTM like this will work the same for gold bars and steel bars, because they have the same outline. To make it only work for gold, you will need a point on the gold color, with some tolerance, because it does change. See a DTM tut for more info, as BlackLists don't worry about this.) Ok, so every (type of) item has a black outline which can be used to identify it. This outline is a bunch of points, which have the color 65536. Basically (<<keyword), these points are the BlackList for that item.

    When you look in a bank, and scroll to the top (FixBank) there are 48 visible BankSlots, 6 rows of 8. In B4 these 48 are numbered like in the inventory, reading left to right, top to bottom, 1 to 48. The corners of these BankSlots can be found with a formula, for BlackLists we just need the top left. Each BankSlot is 31 by 31 pixels, 961 pixels. Now, we want to look at the pixels for black(65536), but we don't need all of them. So the question is, which pixels do we look at? For that we need a TPointArray. A TPointArray is an array of TPoints. Each TPoint contains 2 values, the x and y. In this case, they x and y are the distances between the pixel we want to look at, and the top left corner of the box (BankSlot) we are looking in. First we declare a variable to hold our list of points to check.
    SCAR Code:
    var MyList:TPointArray;

    Next we need a function that creates the TPointArray of the points relative to the top left of bankslots we want to look at. The following creates an array with about 385 points, which is 40% of all the points in a bankslot. All the numbers are from 0 to 31, because its relative to the top left corner of the bankslot.

    SCAR Code:
    {*******************************************************************************
    function Create40PercentTPA:TPointArray;
    By: Boreas
    Note: Purely an internal function, used in setup.
    Description: Returns a TPointArray containing the relative (to x1,y1 of a BSlot)
    for 385 points (out of 31*31, hence 40%). Only needs to be done once, to create
    the list of points to check for 65536. Only takes like 15ms, and I didn't
    feel like typing them all out.
    *******************************************************************************}

    function Create40PercentTPA:TPointArray;
    var Counter,hx,hy:integer;
      var TPointsToCheck:array [0..384] of TPoint;
    begin
      repeat
        hy:=15;
        hx:=hx+1;
        repeat
          hy:=hy+1;
          if (((hx mod 4)=0) or ((hy mod 4)=0)) then
          begin
            TPointsToCheck[Counter].x:=hx;
            TPointsToCheck[Counter].y:=hy;
            Counter:=Counter+1;
          end;
        until hy=31;
      until hx=31;
      result:=TPointsToCheck;
    end;

    Oops. It's not 40% or 385 points. It's more like 208 points, 22%. This is because I added the hy:=15;, so that it ignores the part where the yellow amount number is. I will change the name when B4 comes out.

    You can create you own function (see pwnaz0r's max accuracy one on page 2), just make sure to skip the top 15 pixels where the number is. The one above looks like a net, with 7 lines across and 7 lines down, like how a tic-tac-toe(naughts and crosses for UK) board has 2. You can make it slower but more accurate by changing the mod 4 to mode 2, which will give it 15 lines both way. You can do the opposite by changing to 8, giving 3. You could also do something with circles. I chose the net pattern because you can't draw a line (more than 3 pixels long) without catching the net. You don't even need a formula, but doing it by hand can take a while. Basically, you just need a TPointArray containing the points in the BankSlot you want to look at, with the top left being 0,0. More points is more accurate but slower.

    SCAR Code:
    MyList:=Create40PercentTPA;

    Here's how to get the coords of the top left corner of a bankslot. I won't go into how it works, this is just how I do it for B4.
    SCAR Code:
    Tmpx1:=79+((((WhichBankSlot+7)mod 8))*47);
      Tmpy1:=62+((((WhichBankSlot-1)/8))*38);

    So we have a list a points in a BankSlot we want to look at. The next step is to go through the list for an item and check which are black(65536). This is fairly simple, go through the list you created, adding the coords in the TPoints to the top left corner, and check if the color there is black. If it is, add the index of the list to another list, an array of integers. This is faster and simpler than making another TPoint array, because we will need to output the list somehow later.

    SCAR Code:
    {*******************************************************************************
    function CreateItemBlackList(WhichBankSlot:integer;WhichList:TPointArray):array of integer;
    By: Boreas
    Description: Looks at the points in the list for an item, and returns an array
    contatining the indexes of the points that are black.
    Usage: WhichBankSlot-just what it sounds like. WhichList-the TPointArray
    containing positions relative to the x1,y1 of a bankslot which you want to check
    *******************************************************************************}


    function CreateItemBlackList(WhichBankSlot:integer;WhichList:TPointArray):array of integer;
    var Counter,Counter2,Tmpx1,Tmpy1,ListLength:integer;
    var TmpArray:array of integer;
    begin
        Tmpx1:=79+((((WhichBankSlot+7)mod 8))*47);
        Tmpy1:=62+((((WhichBankSlot-1)/8))*38);
      ListLength:=getarraylength(WhichList)-1;
      setarraylength(tmparray,1);
      for Counter:= 0 to ListLength do
      begin

        if GetColor(Tmpx1+WhichList[Counter].x,Tmpy1+WhichList[Counter].y)=65536 then
        begin
          TmpArray[Counter2]:=Counter;
          Counter2:=Counter2+1;
          setarraylength(TmpArray,Counter2+1);

        end;
      end;
      result:=TmpArray;
    end;

    Now, to make a BlackList for an item, just declare an array of integers....
    SCAR Code:
    var tmpList:array of integer;
    put the item in a bankslot (45 for example), and make the TPointArray as discussed before.
    SCAR Code:
    tmplist:=CreateItemBlackList(45,MyList);

    Now tmplist is the BlackList used to identify that type of item. If you create the list during runtime, just use that array of integer. If you want to make it when writing a script, like traditional DTMs, you need to convert it into something you can transfer. For that, you can use
    SCAR Code:
    writeln(intarraytostr(tmplist2));
    IntArrayToStr by Moparisthebest is in SRL/Misc/ArrayLoaders.scar

    This will display a bunch of numbers with spaces between them. To put them back into the usable array, use StrToIntArray. This is like DTMFromString. Once you have the string, remember what item it goes to, and what TPointArray was used to create it (in this case, it was MyList made with Create40PercentTPA), it will only work later if you use the same TPointArray. B4 will make this process easier.

    So now you have the BlackList for an item type, the next step is using that to identify that item type again. You could use the following:
    SCAR Code:
    {*******************************************************************************
    function CheckItemBlackList(WhichBankSlot:integer;WhichBlackList:array of integer;WhichList:TPointArray):boolean;
    By: Boreas
    Description: Returns true if an items blacklist matches the one in the parameters
    *******************************************************************************}

    function CheckItemBlackList(WhichBankSlot:integer;WhichBlackList:array of integer;WhichList:TPointArray):boolean;
    var Counter,Tmpx1,Tmpy1,ListLength:integer;
    var TheBoolean:boolean;
    begin
      Tmpx1:=79+((((WhichBankSlot+7)mod 8))*47);
      Tmpy1:=62+((((WhichBankSlot-1)/8))*38);
      ListLength:=getarraylength(WhichBlackList)-1;
      TheBoolean:=true;
      repeat
        if not(getcolor(Tmpx1+Whichlist[WhichBlacklist[Counter]].x,
           Tmpy1+Whichlist[WhichBlacklist[Counter]].y)=65536) then
           TheBoolean:=false;
        Counter:=Counter+1;
      until ((not(TheBoolean)) or  (Counter=(ListLength+1)));
      result:=TheBoolean;
    end;

    This will look at the integers in the BlackList, match them up to the indexs of the TPoint in the WhichList, look at the corresponding TPoints, and then add those values to the top left of the bankslot you are looking at, and check if the color at those pixels are black.

    That works, however there is another way shown below, that may take a little more time, but is still very fast. The above method runs into the same problem as DTMs, whereas the method below does not. The problem is, if you make a DTM of a unstrung bow, it will be found in a strung bow. The method below creates a BlackList of an item in question, and compares it to the one you made before. Since you are using the exact same method to make the list, they will be exactly the same if they are the same type of item.

    Let's assume tmplist is a BlackList for cut gems you made by looking at diamond. Also assume that there is another cut gem (lets say a sapphire) in spot 46. The script below will make a BlackList for the item in spot 46, in the same way tmplist was made. It will see that they are both cut gems and say yes.
    SCAR Code:
    tmplist2:=CreateItemBlackList(46,MyList);
    if CompareIntArrays(tmplist,tmplist2) then writeln('yes')

    For this you need CompareIntArrays which simply looks at each integer in an array, and if they all match up, returns true.
    SCAR Code:
    {*******************************************************************************
    function CompareIntArrays(FirstIntArray,SecondIntArray:array of integer):boolean;
    By: Boreas
    Description: Returns true both arrays are the same
    ******************************************************************************}

    function CompareIntArrays(FirstIntArray,SecondIntArray:array of integer):boolean;
    var Counter:integer;
    begin
      if not(getarraylength(FirstIntArray)=getarraylength(SecondIntArray)) then
        result:=false;


      if (getarraylength(FirstIntArray)=getarraylength(SecondIntArray)) then
      begin
        result:=true;
        repeat
          if not(FirstIntArray[Counter]=SecondIntArray[Counter]) then
            result:=false;
          Counter:=Counter+1;
        until ((Counter=getarraylength(FirstIntArray)) or (result=false));
      end;
    end;

    Run the following script on the picture below to see it in action.

    SCAR Code:
    program New;
    {.include SRL/SRL.scar}
    var MyList:TPointArray;
    var tmpList,tmpList2:array of integer;


    var t:integer;
    {*******************************************************************************
    function Create40PercentTPA:TPointArray;
    By: Boreas
    Note: Purely an internal function, used in setup.
    Description: Returns a TPointArray containing the relative (to x1,y1 of a BSlot)
    for 385 points (out of 31*31, hence 40%). Only needs to be done once, to create
    the list of points to check for 65536. Only takes like 15ms, and I didn't
    feel like typing them all out.
    *******************************************************************************}

    function Create40PercentTPA:TPointArray;
    var Counter,hx,hy:integer;
      var TPointsToCheck:array [0..384] of TPoint;
    begin
      repeat
        hy:=15;
        hx:=hx+1;
        repeat
          hy:=hy+1;
          if (((hx mod 4)=0) or ((hy mod 4)=0)) then
          begin
            TPointsToCheck[Counter].x:=hx;
            TPointsToCheck[Counter].y:=hy;
            Counter:=Counter+1;
          end;
        until hy=31;
      until hx=31;
      result:=TPointsToCheck;
    end;

    {*******************************************************************************
    function CreateItemBlackList(WhichBankSlot:integer;WhichList:TPointArray):array of integer;
    By: Boreas
    Description: Looks at the points in the list for an item, and returns an array
    contatining the indexes of the points that are black.
    Usage: WhichBankSlot-just what it sounds like. WhichList-the TPointArray
    containing positions relative to the x1,y1 of a bankslot which you want to check
    *******************************************************************************}


    function CreateItemBlackList(WhichBankSlot:integer;WhichList:TPointArray):array of integer;
    var Counter,Counter2,Tmpx1,Tmpy1,ListLength:integer;
    var TmpArray:array of integer;
    begin
        Tmpx1:=79+((((WhichBankSlot+7)mod 8))*47);
        Tmpy1:=62+((((WhichBankSlot-1)/8))*38);
      ListLength:=getarraylength(WhichList)-1;
      setarraylength(tmparray,1);
      for Counter:= 0 to ListLength do
      begin

        if GetColor(Tmpx1+WhichList[Counter].x,Tmpy1+WhichList[Counter].y)=65536 then
        begin
          TmpArray[Counter2]:=Counter;
          Counter2:=Counter2+1;
          setarraylength(TmpArray,Counter2+1);

        end;
      end;
      result:=TmpArray;
    end;
    {*******************************************************************************
    function CheckItemBlackList(WhichBankSlot:integer;WhichBlackList:array of integer;WhichList:TPointArray):boolean;
    By: Boreas
    Description: Returns true if an items blacklist matches the one in the parameters
    *******************************************************************************}

    function CheckItemBlackList(WhichBankSlot:integer;WhichBlackList:array of integer;WhichList:TPointArray):boolean;
    var Counter,Tmpx1,Tmpy1,ListLength:integer;
    var TheBoolean:boolean;
    begin
      Tmpx1:=79+((((WhichBankSlot+7)mod 8))*47);
      Tmpy1:=62+((((WhichBankSlot-1)/8))*38);
      ListLength:=getarraylength(WhichBlackList)-1;
      TheBoolean:=true;
      repeat
        if not(getcolor(Tmpx1+Whichlist[WhichBlacklist[Counter]].x,
           Tmpy1+Whichlist[WhichBlacklist[Counter]].y)=65536) then
           TheBoolean:=false;
        Counter:=Counter+1;
      until ((not(TheBoolean)) or  (Counter=(ListLength+1)));
      result:=TheBoolean;
    end;

    {*******************************************************************************
    function CompareIntArrays(FirstIntArray,SecondIntArray:array of integer):boolean;
    By: Boreas
    Description: Returns true both arrays are the same
    ******************************************************************************}

    function CompareIntArrays(FirstIntArray,SecondIntArray:array of integer):boolean;
    var Counter:integer;
    begin
      if not(getarraylength(FirstIntArray)=getarraylength(SecondIntArray)) then
        result:=false;


      if (getarraylength(FirstIntArray)=getarraylength(SecondIntArray)) then
      begin
        result:=true;
        repeat
          if not(FirstIntArray[Counter]=SecondIntArray[Counter]) then
            result:=false;
          Counter:=Counter+1;
        until ((Counter=getarraylength(FirstIntArray)) or (result=false));
      end;
    end;
    function intArrayToStr(intArray: array of Integer): string;
    var
      i, arrayLength: Integer;
    begin
      arrayLength := GetArrayLength(intArray);
      repeat
        Result := Result + IntToStr(intArray[i]);
        if (not (i = (arrayLength - 1))) then
          Result := Result + ' ';
        i := i + 1;
      until (i = arrayLength)
    end;

    function strToIntArray(intArray: string): array of Integer;
    var
      i, spacePos: Integer;
    begin
      repeat
        SetArrayLength(Result, i + 1);
        spacePos := Pos(' ', intArray);
        if (not (spacePos = 0)) then
        begin
          Result[i] := StrToInt(Copy(intArray, 1, spacePos - 1));
        end
        else
        begin
          Result[i] := StrToInt(Copy(intArray, 1, Length(intArray)));
          break;
        end;
        Delete(intArray, 1, spacePos);
        i := i + 1;
      until (False)
    end;

    begin
    setupsrl;
    t:=getsystemtime;
    MyList:=Create40PercentTPA;
    tmplist:=CreateItemBlackList(45,MyList);
    tmplist2:=CreateItemBlackList(46,MyList);
    //writeln(inttostr(getarraylength(tmplist2)));
    //writeln(intarraytostr(tmplist2));
    if CompareIntArrays(tmplist,tmplist2) then writeln('yes')

    //if (tmplist=tmplist2) then writeln('yes');
    //writeln(inttostr(getsystemtime-t)+'ms');
    {
    if CheckItemBlackList(46,tmplist,mylist) then
    writeln('yes');
    writeln(inttostr(getsystemtime-t));
    }
    end.


    Please note that is a small technique, to be combined with others. It is a very small part of B4, and doesn't do that much without the rest. But I thought I would post it here now so you can use it if you want. Plus, unlike most of B4, this doesn't require any edits to SRL, or lower level supporting functions (because it is one) besides the ones I posted above.

    Please note this tutorial is very rough. If anyone is interested and needs me to clean it up a bit, I will. Any questions, feel free to ask. Since I created it, it's hard for me to explain it, as I was never taught it, so I may have left out important parts lol.

    Hehe I had 3 tuts out and none were about actual scripting, so I had to fix that lol

  2. #2
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Wow, Awesome! Wow... I'm spellbound

    Thanks so much! This will be a big help to the community

    FIRST POST W00T!

    EDIT:
    Ouch! My head hurts! =D
    Interested in C# and Electrical Engineering? This might interest you.

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

    Default

    Thanks for reading

    Please let me know any improvements I can make on the tutorial (appearance and understandability) and the method (efficiency and ease of use), as this will change by the time I release B4.

  4. #4
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Well, I have yet to read it and understand everything, but I'm nowhere near as good a scripter as you, so I wouldn't expect to

    Lookin forward to seeing you release this 'B4', maybe when I'm done with my powercutter, I'll make a banker of some sort...
    Interested in C# and Electrical Engineering? This might interest you.

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

    Default

    If it's hard to understand, it's because I threw it together pretty quickly. Lemme know and I'll fix it.

    I will probably be releasing parts of B4 as I go along, if they are helpful on their own. This way people can make use of them and I can get feedback to refine them before releasing the whole system. Expect more stuff like this because I have more time to script now.

  6. #6
    Join Date
    Nov 2006
    Location
    USA
    Posts
    24
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Works, and thanks =D.

    I'd like to add. You are very clever, people could save memb usage and everything this! Noice, man. YEE.

    EDIT:

    I understand most of it, because WhiteShadow, taught me TPointArrays stuff. But i'll probably need to study those coord math things a bit more.

    P.S - LOLLL I was the person talking to you earlier bechus i was messing with him comp.

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

    Default

    Thanks.

    If you mean
    Tmpx1:=79+((((WhichBankSlot+7)mod 8))*47);
    then look at this

    SCAR Code:
    Players[player].BankSlot[i].row:=((i-1)/8)+1;
        Players[player].BankSlot[i].column:=((i+7)mod 8)+1;
        Players[player].BankSlot[i].x1:=79+((Players[player].Bankslot[i].column-1)*47);
        Players[player].Bankslot[i].y1:=62+((Players[player].Bankslot[i].row-1)*38);
        Players[player].BankSlot[i].x2:=Players[player].Bankslot[i].x1+31;
        Players[player].BankSlot[i].y2:=Players[player].Bankslot[i].y1+31;
    i is slot number
    First it gets the row and column number
    Then it uses the fact the distance between the left edge of 2 adjacent bank slots is 47 (31 is the width with 16 in between)

    The tmpx1 line above is just this condensed.

    Ah ok lol.

  8. #8
    Join Date
    Feb 2007
    Posts
    3,616
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    GREAT tut boreas! very nice. i just have one question though. how can somebody as uber as you at scripting, not have any scripts? lol. cause we could all say you know some of the basics of scar scripting no? :P

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

    Default

    Hehe I like making functions and stuff more. When I'm not busy with B4 and MouseHelper (move mouse and monitor uptext/randoms at the same time), I'll work on a lumbridge script, maybe some other stuff. Most of my scripts are for weird things that are only useful for me, like ring crafter etc, plus I modified a few of other peoples scripts, other than that, I mostly write functions.

    ATM I'm working on another function, and maybe a tutorial to go with it, for combining BlackLists with color, so that you can distinguish between a steel bar and gold bar.

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

    Default

    Boreas, your the man.

    ++rep for dinner?

    hakuna matata ;)

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

    Default

    Hehe thanks, I'll put it on the pizza

  12. #12
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Wow! Simply amazing! I dread the day when your Lumby script comes out gonna make everything else look like crap
    Interested in C# and Electrical Engineering? This might interest you.

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

    Default

    Hehe, won't be for a while. Ran into a problem with FindColorSkipBoxArray. So just B4 for now

  14. #14
    Join Date
    Jan 2007
    Location
    USA
    Posts
    1,782
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    + rep bro nice job explaining

    EDIT : how long have you been working on your lumby script? I think you were still working on it be4 I even came here?

    Join the fastest growing merchanting clan on the the net!

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

    Default

    Around 1st week of jan. Tried a couple techniques for finding doors, found one that I like but it's not working. That's as far as I got lol.

  16. #16
    Join Date
    Jan 2007
    Location
    USA
    Posts
    1,782
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    watcha doin?

    Join the fastest growing merchanting clan on the the net!

  17. #17
    Join Date
    Feb 2006
    Location
    L.A, USA
    Posts
    1,632
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    @juessx - your dead meat foo. Ima eat you.


    lols, that's poon Boreas.

    EDIT: sorry fixd it.

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

    Default

    lol I don't really understand those 2 posts

  19. #19
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Whiteshadow talks funny =)
    Im used to it on MSN ill translate:

    Whiteshadow is just pointing out that he taught JEssux TpointArrays,
    He likes your procedure because it poons
    And i think he fixed something?

    Hooblah!

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

    Default

    Ahhh I see now lol

  21. #21
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Hey, I read the whole thing, and I actually understood it! nice functions, I'm gonna see if I can utilize them in one of my three upcoming scripts =)
    Interested in C# and Electrical Engineering? This might interest you.

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

    Default

    Cool. Check out the other one too, as this isn't much use without it. (except for finding things that there are one type of, chisels, threads, nooby shield, er can't think of anything else but I know there's more)

    Edit:

    Here is an Easy BlackList Maker

    Open up a bank, make sure the items you want to create BlackLists for are in the top 48, make sure its scrolled up all the way, and run

    SCAR Code:
    program New;
    {.include SRL/SRL.scar}

    type
      BlackList = array of integer;

    type
      BlackListNet = array of Tpoint;
    {*******************************************************************************
    function CreateTightNet : BlackListNet;
    By: Boreas
    Note: Purely an internal function, used in setup.
    Description: Same as above but takes a little (not noticeable) longer and is
    more accurate. 38% of the slot. 74% of slot without amount
    *******************************************************************************}

    function CreateTightNet :BlackListNet;
    var Counter,hx,hy:integer;
      var TPointsToCheck:array [0..367] of TPoint;
    begin
      repeat
        hy:=15;
        hx:=hx+1;
        repeat
          hy:=hy+1;
          if (((hx mod 2)=0) or ((hy mod 2)=0)) then
          begin
            TPointsToCheck[Counter].x:=hx;
            TPointsToCheck[Counter].y:=hy;
            Counter:=Counter+1;
          end;
        until hy=31;
      until hx=31;
      result:=TPointsToCheck;
    end;
    {*******************************************************************************
    function CreateItemBlackList(WhichBankSlot:integer;WhichNet:BlackListNet):BlackList;
    By: Boreas
    Description: Looks at the points in the list for an item, and returns an array
    contatining the indexes of the points that are black.
    Usage: WhichBankSlot-just what it sounds like. WhichList-the TPointArray
    containing positions relative to the x1,y1 of a bankslot which you want to check
    *******************************************************************************}

    function CreateItemBlackList(WhichBankSlot:integer;WhichNet:BlackListNet):BlackList;
    var Counter,Counter2,Tmpx1,Tmpy1,ListLength:integer;
    var TmpArray:array of integer;
    begin
        Tmpx1:=79+((((WhichBankSlot+7)mod 8))*47);
        Tmpy1:=62+((((WhichBankSlot-1)/8))*38);
      ListLength:=getarraylength(WhichNet)-1;
      setarraylength(tmparray,1);
      for Counter:= 0 to ListLength do
      begin

        if GetColor(Tmpx1+WhichNet[Counter].x,Tmpy1+WhichNet[Counter].y)=65536 then
        begin
          TmpArray[Counter2]:=Counter;
          Counter2:=Counter2+1;
          setarraylength(TmpArray,Counter2+1);

        end;
      end;
      setarraylength(tmpArray,Counter2);
      result:=TmpArray;
    end;
    {*******************************************************************************
    function GetNameOfItemInBank: string;
    By: Boreas, bases off of Ron's Replace
    Description: Takes item name from uptext in bankscreen, and changes spaces
    to underscores
    *******************************************************************************}

    function GetNameOfItemInBank: string;
    var
      a : LongInt;
      TheString:string;
    begin
      TheString:=GetUptext;
      a := Pos('Withdraw 1 ', TheString);
      if(a = 0)then
      begin
        // Do nothing..
      end else
      begin
        Delete(TheString, a, Length('Withdraw 1 '));
        Insert('', TheString, a);
        a := Pos(' /', TheString);
        delete(thestring,a,Length(TheString));
        repeat
          a := Pos(' ', TheString);
          if a<>0 then
          begin
            Delete(TheString, a, 1);
            Insert('_', TheString, a);
          end;
        until a=0;
        repeat
          a := Pos(chr(39), TheString);
          if a<>0 then
          begin
            Delete(TheString, a, 1);
          end;
        until a=0;

        Result := TheString;
      end;
    end;

    {*******************************************************************************
    function LongTextBreakDown(TheString):string;
    By: Ron and Boreas
    Description: Formats a long string so that it looks like the result of
    DTM to text. Pretty much only useful for BlackList to Text
    *******************************************************************************}


    function LongTextBreakDown(TheString:string):array of string;
    var iter:integer;
    tmpstring:string;
    begin
      tmpstring:=TheString;
      if length(tmpstring) > 62 then
      begin
        setarraylength(result,iter+1);
        result[iter]:=copy(tmpstring, 1, 61)+chr(39)+' +';
        delete(tmpstring, 1, 61);
        while length(tmpstring) > 69 do
        begin
          iter:=iter+1;
          setarraylength(result,iter+1);
          result[iter]:='       '+chr(39)+copy(tmpstring, 1, 53)+chr(39)+' +';
          delete(tmpstring, 1, 53);
        end;
        iter:=iter+1;
        setarraylength(result,iter+1);
        result[iter]:='       '+chr(39)+tmpstring;
      end else
      begin
        setarraylength(result,1);
        result[0]:=tmpstring;
      end;
    end;
    {*******************************************************************************
    procedure WriteBlackList(TheBlackList: BlackList);
    By: Boreas/moparisthebest
    Description: Displays a BlackList as a string in debug box. Basically
    array of integer -> string and DTM editor's DTM to Text put together
    *******************************************************************************}

    procedure WriteBlackList(TheBlackList: BlackList);
    var
      i, arrayLength: Integer;
      mystr,tmpstr,tmpresult:string;
      aos:array of string;
    begin
      arrayLength := GetArrayLength(TheBlackList);
      repeat
        tmpresult := tmpresult + IntToStr(TheBlackList[i]);
        if (not (i = (arrayLength - 1))) then
          tmpresult := tmpresult + ' ';
        i := i + 1;
      until (i = arrayLength)
      mystr:=GetNameOfItemInBank;
      if mystr='' then mystr:='BlackList';
      tmpresult:='  BL_'+mystr+' := LoadBlackListFromString('+chr(39)+tmpresult+chr(39)+');';
      aos:=LongTextBreakDown(tmpresult);
      for i:=0 to getarraylength(aos)-1 do
        writeln(aos[i]);
    end;


    var MyNet:BlackListNet;
    MyList:Blacklist;
    slot1:integer;

    begin
      SetupSRL;
      MyNet:=CreateTightNet;
      writeln('Put mouse over item and press f12');
      repeat
        repeat
          wait(30);
        until ((isfkeydown(12)) or (isfkeydown(11)));
        if not(isfkeydown(11)) then
        begin
          getmousepos(x,y);
          slot1:=(((((y-62) div 38)+1)-1)*8)+(((x-79) div 47)+1);
          MyList:=CreateItemBlackList(slot1,MyNet);
          WriteBlackList(Mylist);
          writeln('Press F12 to do another one');
          writeln('Press F11 to end');
        end;
      until isfkeydown(11);
    end.

    You can use the output with
    SCAR Code:
    {*******************************************************************************
    function LoadBlackListFromString(BlackListString: string): BlackList;
    By: Boreas/moparisthebest
    Description: Loads a BlackList from a string given by WriteBlackList. Basically
    string -> array or integer
    *******************************************************************************}

    function LoadBlackListFromString(BlackListString: string): BlackList;
    var
      i, spacePos: Integer;
    begin
      repeat
        SetArrayLength(Result, i + 1);
        spacePos := Pos(' ', BlackListString);
        if (not (spacePos = 0)) then
        begin
          Result[i] := StrToInt(Copy(BlackListString, 1, spacePos - 1));
        end
        else
        begin
          Result[i] := StrToInt(Copy(BlackListString, 1, Length(BlackListString)));
          break;
        end;
        Delete(BlackListString, 1, spacePos);
        i := i + 1;
      until (False)
    end;
    which will be in the BlackList include I am putting together.

  23. #23
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Nice Stuff =)
    Ima use these in my fletcher maybey =)

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

    Default

    I should have it working for inventory too in the next couple of days

  25. #25
    Join Date
    Feb 2007
    Location
    Toronto, Ontario, Canada
    Posts
    586
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I understand it! *pats self on back* Very nice! This is a very useful tool and I look forward to using it. On the topic of bankbrowsing, is there such thing as a function that scrolls the bank scroller thingy?

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. bank pin
    By ekamjit in forum OSR Help
    Replies: 3
    Last Post: 11-12-2008, 02:06 AM
  2. Bank Browsing- BlackLists with Color
    By Boreas in forum OSR Intermediate Scripting Tutorials
    Replies: 16
    Last Post: 08-26-2007, 02:26 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
  •