Results 1 to 10 of 10

Thread: incorporating banking and the player form

  1. #1
    Join Date
    Feb 2015
    Posts
    422
    Mentioned
    41 Post(s)
    Quoted
    226 Post(s)

    Default incorporating banking and the player form

    So, I've been trying to learn how the player form works and learning how to incorporate it in my scripts. This is my first question so far.


    Simba Code:
    comboBoxLabels := ['Bank Type', 'Bank Preset'];
    comboBoxDefaults := ['BANK_BOOTH', 'BANK_BUTTON_PRESET_2'];

    setLength(comboBoxItems, length(comboBoxLabels));
    comboBoxItems[0] := ['BANK_NPC_BLUE', 'BANK_NPC_GREY', 'BANK_NPC_GREEN', 'BANK_NPC_DRAYNOR', 'BANK_BOOTH', 'BANK_GE', 'BANK_CHEST_SW', 'BANK_CHEST_SHANTAY', 'BANK_CHEST_DUEL', 'BANK_CHEST_CW', 'BANK_CHEST_GROTTO', 'BANK_TABLE_BURTHORPE', 'BANK_CHEST_LUMBRIDGE', 'BANK_CHEST_PRIFDDINAS', 'BANK_CHEST_BARB_OUTPOST'];
    comboBoxItems[1] := ['BANK_BUTTON_PRESET_1', 'BANK_BUTTON_PRESET_2'];


    I want to incorporate those into lines like bankscreen.open(whichever bank is picked), and bankScreen.clickButton(whichever preset is picked). I looked around in other scripts to see what other people were doing for it, and saw multiple ways which it was done. most of them (using one way or the other) convert the result into numbers (0-13) for banks, which I now know correspond to the banks in the order they are listed in the include, or it is done manually where it converts
    Simba Code:
    'BANK_BOOTH'to BANK_BOOTH
    , and the same thing was done with presets except the numbers were (3-4). I know that the form is supposed to work with custom records, as the scripts that I've looked at have done. I was just wondering if there was a way to convert it automatically, like there is strToInt, but to remove the ' '.

  2. #2
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    @fady; I don't think there is a way to do it automatically. strToInt would probably throw an error because you're turning a string into a constant which is assigned an integer. You might be able to parse out the text and throw it into a case statement, but it would probably be more effort than making a big case statement like you've seen in the other scripts.

    My Recommendation:

    Simba Code:
    //global variables
    var
      bankConst : Integer;

    //inside function
    case boxItem of
    'BANK_NPC_BLUE': bankConst := BANK_NPC_BLUE;
    //etc...
    end;

    Not very descriptive code but you seem to know what I mean if I understand your description properly.

    The random spit-balling idea:

    Simba Code:
    str := between(boxItem, '_', '_'); // Should look between the first two _ in the string
    case str of:
    'NPC':
    begin
    //some sort of string manipulation to grab the last portion of each string (probably another case statement)
    end;
    'CHEST':
    //etc.
    end;

    The more code I write for that idea the worse it seems. Just go with the first idea and pretend I didn't even mention another idea

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  3. #3
    Join Date
    Feb 2015
    Posts
    422
    Mentioned
    41 Post(s)
    Quoted
    226 Post(s)

    Default

    Quote Originally Posted by 3Garrett3 View Post
    @fady; I don't think there is a way to do it automatically. strToInt would probably throw an error because you're turning a string into a constant which is assigned an integer. You might be able to parse out the text and throw it into a case statement, but it would probably be more effort than making a big case statement like you've seen in the other scripts.

    My Recommendation:

    Simba Code:
    //global variables
    var
      bankConst : Integer;

    //inside function
    case boxItem of
    'BANK_NPC_BLUE': bankConst := BANK_NPC_BLUE;
    //etc...
    end;

    Not very descriptive code but you seem to know what I mean if I understand your description properly.

    The random spit-balling idea:

    Simba Code:
    str := between(boxItem, '_', '_'); // Should look between the first two _ in the string
    case str of:
    'NPC':
    begin
    //some sort of string manipulation to grab the last portion of each string (probably another case statement)
    end;
    'CHEST':
    //etc.
    end;

    The more code I write for that idea the worse it seems. Just go with the first idea and pretend I didn't even mention another idea
    Thanks for responding, I'll use case statements then! The second option seems too complicated lol

  4. #4
    Join Date
    May 2012
    Posts
    499
    Mentioned
    23 Post(s)
    Quoted
    228 Post(s)

    Default

    I also had trouble with this. Ashaman assigned his to the numbers of the bankers, but someone else told me that was bad practice as those constants could change.

    How did you end up doing it?

  5. #5
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Quote Originally Posted by lovebotter View Post
    I also had trouble with this. Ashaman assigned his to the numbers of the bankers, but someone else told me that was bad practice as those constants could change.

    How did you end up doing it?
    The case statement Garrett posted is probably the easiest way to do it.

  6. #6
    Join Date
    May 2012
    Posts
    499
    Mentioned
    23 Post(s)
    Quoted
    228 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    The case statement Garrett posted is probably the easiest way to do it.

    Yes, probably, but couldn't the banking procedures be changed to also accept strings? I wouldn't know tbh?
    I always found it rather weird it accepts integers that seem more like a string to me.
    But like you've said before; the banking include is rather messy.

  7. #7
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Quote Originally Posted by lovebotter View Post
    Yes, probably, but couldn't the banking procedures be changed to also accept strings? I wouldn't know tbh?
    I always found it rather weird it accepts integers that seem more like a string to me.
    But like you've said before; the banking include is rather messy.
    Yea it could use strings, but integers are easier to work with when using arrays.

  8. #8
    Join Date
    May 2012
    Posts
    499
    Mentioned
    23 Post(s)
    Quoted
    228 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    Yea it could use strings, but integers are easier to work with when using arrays.
    You think you might be able to add it whenever you update the banking include?
    I dont need banking location in the playerform myself, but suppose some ppl using my scripts would like it..

  9. #9
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Meh, I don't see the issue with a case statement what so ever nothing wrong with it, certainly no need to add banking overloads to accept strings..

    But if you want a piece of wizardy here it is:

    Simba Code:
    const
      BANK_CHEST_SHANTAY = 7;

    const
      playerform_selection = 'BANK_CHEST_SHANTAY';

    var
      bankType: Integer;

    begin
      Writeln(GetGlobal(playerform_selection)); // 7 !

    {
      // or
      bankScreen.open(GetGlobal(playerform_selection));
      // or
      bankType := GetGlobal(playerform_selection);
    }

    end.

  10. #10
    Join Date
    May 2012
    Posts
    499
    Mentioned
    23 Post(s)
    Quoted
    228 Post(s)

    Default

    Quote Originally Posted by Olly View Post
    Meh, I don't see the issue with a case statement what so ever nothing wrong with it, certainly no need to add banking overloads to accept strings..

    But if you want a piece of wizardy here it is:

    Simba Code:
    const
      BANK_CHEST_SHANTAY = 7;

    const
      playerform_selection = 'BANK_CHEST_SHANTAY';

    var
      bankType: Integer;

    begin
      Writeln(GetGlobal(playerform_selection)); // 7 !

    {
      // or
      bankScreen.open(GetGlobal(playerform_selection));
      // or
      bankType := GetGlobal(playerform_selection);
    }

    end.
    That is some serious magic right there! Thanks!

    writeLn(players[currentPlayer].strings[SPF_BANK]);
    writeLn(GetGlobal(players[currentPlayer].strings[SPF_BANK]));

    BANK_CHEST_BARB_OUTPOST
    14

    Pr0n

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
  •