SRL Archive - MSI Tutorials

A How-to Guide for MSI Scripting


Coh3n

2010-06-10 12:21:28

A How-to Guide for MSI Scripting
This guide was last updated on March 17th, 2012


Introduction:
[INDENT]This is going to basically be an "MSI For Dummies" tutorial where you could have almost no scripting experience, and still be able to contribute to MSI. Of course, there will be some more advanced parts that you may not understand, so don't be afraid to ask questions, that's what we're here for. :) I also encourage you to look at the MSI Core to-do List, for a list of everything that's been suggested and what needs to be done.

Since most people learn better with examples, throughout this guide I will be adding a Varrock East Clay Softener script to MSI. Why a Clay Softener? Because it covers everything: new items, new objects, and a new "skill" (not actually a new skill since you don't get experience, but I'm sure you get the point). If you have any questions about any procedures/functions in MSI, please use MSI's Documentation as a reference.

This guide will outline the following:
  1. The easiest way of contributing to MSI.
  2. How to, very easily, create the basic MSI records (TItem, TMSObject, TLocation and TScript).
  3. How to add each of these records to the include.
  4. How to add a new skill to MSI.
  5. How to add a script for an existing skill.
  6. Some useful links.
[/INDENT]


Using github to Contribute to MSI:
[INDENT]The easiest way to contribute to MSI is through github. This allows for anyone to make their own version (repository) of MSI that they can develop on their own and eventually merge (combine) with the main MSI repository. I highly recommend learning how to use git if you plan on contributing to MSI, SRL, Reflection, or Simba in the future. It's an awesome tool that makes developing extremely easy. Beware that it may take a little time to get used to, but I promise you it's worth it.

To get setup to contribute with git, follow these simple steps:
  1. Create a free github account here.
  2. Fork (create your own version of) the MSI repository. You can fork any public repository by clicking the Fork button in the top right of that repository's page. Here is MSI's page, see the Fork button in the top right (you have to be logged in to see it).
  3. You'll notice you now have your very own direct copy of MSI. :)
  4. Now you'll want to setup git on your computer. Windows users have the option to use TortoiseGit, which is a lot like TortoiseSVN if you have past experience with that.
  5. Follow this tutorial to setup git and TortoiseGit on your computer. That guide also briefly explains how to work with TortoiseGit. You can also refer to this guide to help you to use git.
  6. The Putty part of that guide is optional. If you wish you can simple input your Github password each time you're prompted to do so.
  7. Now Clone your MSI repository in your Simba/Includes folder (the latter guide explains how to Clone).
  8. Done!
It's understandable that you may have trouble with git at first. Believe me, I had A LOT, but don't be afraid to post here to send me a PM and I'll be happy to help you out. It just takes some time to get used to. Once you feel like your repository should be merged (i.e. your changes are ready to be made to MSI), you can hit the Pull Request button in the top right of your repository's github page. This will notify the MSI developers, and one of us will merge your changes with the main MSI repository.[/INDENT]


Planning Your Changes:
[INDENT]Before you start furiously scripting for MSI, I highly recommend planning things out, whether you're simply adding a script record or a new skill. This will ensure you don't forget anything, and it can also act as a checklist for when you actually start coding. So, since I'll be adding a Clay Softener for this guide, let's start planning it out.

While answering some of the following questions, you should also think about whether or not MSI already has the methods/records for what you need. How are you going to know this? Well check the include of course! In Globals.simba there are lists of all the records that MSI has. As for the methods, you may need to explore MSI's Documentation to be sure. Now, on the the planning…
  1. What items are used?
    • Clay (record already exists)
    • Soft Clay
    • I need to make a TItem record for these items.
  2. What main screen objects are to be found?
    • Varrock East Bank (record already exists)
    • Fountain
    • I need to make TMSObject records for these objects.
  3. What are the different locations involved?
    • Varrock East Bank (record already exists)
    • Varrock East Fountain
    • I need to make TLocation records for these locations.
  4. Do items need to be withdrawn to be changed into another?
    • Clay needs to be withdrawn to to be turned in to Soft Clay.
    • I need to make a TMaterial record for Clay.
  5. What are the procedures involved in a Clay Softener?
    • Setup the player
    • Withdraw Clay from bank (MSI_Withdraw/MSI_BankWithdraw)
    • Walk to fountain (MSI_Walk)
    • Use Clay with fountain (MSI_UseItemOn)
    • Wait for all the Clay to be softened (MSI_WaitItemGone)
    • Walk back to the bank (MSI_Walk)
    • Deposit the Soft Clay (MSI_Deposit/MSI_BankWithdraw)
    • I need to make a TScript record for Varrock East Clay Softener. This step involves the writing of a few simple procedures.
  6. Is there anything else needed for a Clay Softener?
    • A specific file for a Clay Softener or even better - for Money Making scripts.
    • Print a progress report (Reports.simba, BUT some things need changing)
Now you may notice that the steps involved are pretty vague. The steps that aren't already in MSI may take several procedures to do properly. I don't think this is the case for a Clay Softener, but for other scripts/skill it may be. So now that I've planned everything out, and I have a checklist to follow, it's time to start the actual coding.[/INDENT]


Making Your Changes:
[INDENT]The easiest part of everything that needs to be done is making the records, so I'm going to start with them (this includes the TScript record).?Why is this so easy? Because there are already tons of each type of record in the include, all I have to do is copy/paste and changed what needs to be changed. :)

All the records should have descriptions beside each attribute in Globals.simba if you are ever confused about what to set something to. I will still describe what they are here, but this guide won't be updated as much as the include. So now I'm going to work down my checklist.

Lastly, don't get discouraged by how long these steps are. They're really not long at all, I'm just going to explain them thoroughly so there's no confusion. :)

1. Creating the TItem records
  • Enable the DTM editor extension in Simba, then open it (Tools > DTM Editor).
  • Save an image of the item, then go to Image > Open Image. in the DTM editor, and open the item picture.
  • Pick a main point (a distinct color on the item) and 4 sub-points. The sub points all HAVE to have the color 131072 (the outline of the item).
  • When you're finished, you should have a screen that looks something like this:
  • Now if you look in the procedure MSI_GetDTMPoints, you'll notice a bunch of points for all the different items. Copy one of the items and replace it with the points you just gathered, then add it to the end of the procedure. *HINT* Take a screen shot or write down the points/colors, so you can close the DTM Editor and work with only one Simba.


  • CLAY_SOFT:
    Result := [
    Point(28, 25),
    Point(16, 27),
    Point(27, 13),
    Point(39, 26),
    Point(28, 33)
    ];

    else
    MSI_SubDebug('MSI_GetDTMPoints: Invalid item constant - ' + IntToStr(which));
    end;
    end;
  • Now do the same for the main point's color: add it to the end of the MSI_GetItemColor function.

  • CLAY_SOFT: Result := 802904;
  • There, the hardest part of basically everything is done. Now to make the actual record.
  • Copy one of the item records in MSI_LoadItem, and change the attributes to what you need. Then, add the record to the end of MSI_LoadItem.

  • CLAY_SOFT:
    with MSI_Items[whichItem] do
    begin
    Name := 'Soft Clay'; // Name of the item
    UpText := ['oft clay']; // Uptext
    Stackable := False; // Is it stackable?
    EquipLevel := -1; // Set to -1 if it can't be equipped
    end;
    end;

    Result := (MSI_Items[whichItem].Name <> '');
    end;
  • Last but not least, so MSI will compile, open Globals.simba and add the item constant you made to the end of the item list like so:

  • CLAY_SOFT = 180;

    ITEM_ARRAY_LENGTH = 180; // Change to the highest item constant

2. Creating the TMSObject records
  • First, download AutoColor Aid (ACA), and open it. This tool makes our job 1000x easier.
  • Since I need to find the fountain on the mainscreen, I load Runescape and place my player beside the fountain.
  • Now in ACA, go to Client > Client Window > Find RS. If you get a black screen just try again.
  • Choose CTS (Color tolerance speed) 2 in the bottom right corner.
  • Now click the RS image where object appears. Click several areas to get more colors, you'll notice the colors appear in the list to the right.
  • When you think you've picked enough colors, right click the colors list and choose Delete Duplicates.
  • Now, click Mark Best Color. Your ACA should now look something like this:




  • Now time to fill out the record. Just like for TItem, copy a record from Objects.simba and change the necessary attributes.
  • Once changed, add it to MSI_LoadObject.

  • FOUNTAIN_VE:
    with MSI_Objects[whichObject] do
    begin
    Name := 'Varrock East Fountain'; // Name
    UpText := 'ount'; // Uptext
    Option := 'se'; // Choose option text (se = Use)
    Colors := [14520685]; // The 'Best color' from ACA
    Tol := 12; // Tol from ACA
    Hue := 0.02; // Hue from ACA
    Sat := 2.47; // Sat from ACA
    FindAllColors := False; // MSI_FindObject will only return true if all colors in 'Colors' are found
    W := 50; // Width of the object in pixels
    H := 50; // Height of the object in pixels
    Accuracy := 20; // The minimum amount of colors to be found (gets rid of false objects)
    SearchArea := MSBox; // The box to search for the object (MSBox = main screen box)
    ExcludeSelf := True; // Exclude the character
    RightClickOnly := False; // Only right click
    WaitToMove := True; // Wait for the player to stop moving after the object is clicked
    Track := False; // True if the object disappears after the player is done with it
    AssociatedItems := [CLAY_SOFT]; // Are any items gained from the object (i.e. logs from trees)?
    end;
    end;

    Result := (MSI_Objects[whichObject].Name <> '');
    end;
  • Again, like a TItem, add the constant to Globals.simba.

  • // Fountains
    FOUNTAIN_VE = 110;

    OBJ_ARRAY_LENGTH = 110; // Change to the highest object constant

3. Creating the TLocation records
  • TLocation records are fairly simple. For this script, I need one for the Varrock East Fountain.
  • Simply copy another record, replace what needs to be replaced and add it to the case in MSI_LoadLocation in Locations.simba.
  • If there is more than one sub-location (i.e. a tree that needs to be walked to), increase the length and add another sub-location. You can add as many as needed.
  • IMPORTANT: The tileBox works like this: x1, y1 is the top left of the box while x2, y2 is the bottom right. I suggest walking your player to each point of the box and calling writeln(toStr(getMyPos)); to get that tile.
  • IMPORTANT: You HAVE to set subLocs[0].objects, otherwise it will not work!
  • The entire TLocation record can be found in Globals.simba.

  • LOC_VE_FOUNTAIN:
    with MSI_Locations[loc] do
    begin
    name := 'Varrock East Fountain';
    atBank := false;

    setLength(subLocs, 1);
    with subLocs[0] do
    begin
    name := 'Varrock East Fountain';
    tileBox := intToBox(3235, 3431, 3242, 3438);
    objects := [FOUNTAIN_VE];
    end;
    end;
  • Again, add the constant to Globals.simba, and you're done.

  • // Varrock
    // East
    LOC_VE_TREES = 10;
    LOC_VE_OAKS = 11;
    LOC_VE_BANK = 12;
    LOC_VE_MINE = 13;
    LOC_VE_FOUNTAIN = 14;

    // West
    LOC_VW_BANK = 15;
    LOC_VW_MINE = 16;

4. Creating the TMaterial records
  • An MSI material is defined by an item that is made from other items.
  • For a Clay Softener, the material is Soft Clay that's made from regular Clay.
  • Creating a TMaterial record is exactly the same as a TLocation record.
  • Copy an existing record from Materials.simba, replace with the information you need, and add it to the end of MSI_GetMaterial.

  • MATERIAL_CLAY:
    with Result do
    begin
    Name := 'Clay'; // Name
    Supplies := [TIntegerArray([ORE_CLAY, -1])]; // What is required + the amount (-1 = withdraw all)
    Produces := [CLAY_SOFT]; // Items that are produced
    MemberOnly := False; // Members or F2P
    Level := -1; // Skill level required (since there's no skill for a Clay Softener, set to 1)
    end;
  • Lastly, add the material constant to the constants in Globals.simba.

  • const
    // Fish for cooking
    MATERIAL_SHRIMP = 70;
    MATERIAL_CRAYFISH = 71;
    MATERIAL_SARDINE = 72;
    MATERIAL_HERRING = 73;
    MATERIAL_ANCHOVIE = 74;
    MATERIAL_TROUT = 75;
    MATERIAL_PIKE = 76;
    MATERIAL_SALMON = 77;
    MATERIAL_TUNA = 78;
    MATERIAL_LOBSTER = 79;
    MATERIAL_SWORDFISH = 80;

    // Money making
    MATERIAL_CLAY = 90; // Clay to Soft Clay

5. Creating the TScript record
  • Just like the other records, copy one from Scripts.simba, change what needs to be changed, and add it to MSI_LoadScript.

  • SCRIPT_VE_SOFTENER:
    with MSI_Scripts[whichScript] do
    begin
    Name := 'Varrock East Clay Softener'; // Name of the script
    Constant := SCRIPT_VE_SOFTENER; // The constant you make up
    SkillName := 'N/A'; // The skill involved
    SkillConst := SKILL_NONE; // The skill's constant
    BankType := Bank; // The bank type from the TBank set in Globals.simba
    WhichBank := MSI_BANK_VE; // Which bank the script banks at (don't set if there isn't a bank)
    GetMaterials := True; // True if items need to be withdrawn
    AutoObjects := @MSI_SoftenClay; // See below
    BankObjects := @MSI_BankWithdraw; // See below
    PlayerSetup := @MSI_SetupSoftener; // See below

    with Defaults do
    begin
    Objects := [FOUNTAIN_VE]; // The main screen objects involved (this may need a different name depending on the skill; see TScriptSetup)
    Materials := [MATERIAL_CLAY]; // The materials used
    end;

    with PathInfo do
    begin
    StartLoc := LOC_VE_BANK; // The starting location of the script
    EndLoc := LOC_VE_FOUNTAIN; // The ending location of the script

    // See below for Reflection & SPSAreas fields
    Reflection := [
    TPointArray([Point(3254, 3421), Point(3241, 3434)])
    ];

    SPSAreas := [
    TStringArray(['11_7'])
    ];
    end;
    end;
  • Most attributes are pretty straight forward, but I'll explain some of the more difficult ones.
  • The AutoObjects, BankMaterials, and PlayerSetup attributes are what we call pointers because they're pointed (or set) to another procedure or function. They make customizing scripts a lot easier because each script can be pointed to a different procedure if needed.
  • You'll notice that the above record includes MSI_SoftenClay and MSI_SetupSoftener - these procedures don't exists, yet, I'm going to write them. MSI_BankWithdraw will simply deposit the items in the inventory and withdraw new items if needed, so that's exactly the procedure we need for a Clay Softener.
  • Reflection Path
    • These points are very important, so read carefully:
      1. The starting location and ending location has to be included in the path. In this case, it's Varrock East Bank and Varrock East Fountain.
      2. The path has to start at the bank and finish at the fountain.
      3. The points should be as far apart as possible. If it's a direct path, then there should only be two points, otherwise points should go around fences, walls, etc.
      4. Do not forget to set the offsets in the PathMaker tool.
    • The PathMater Tool will make the path making go much faster, so I highly recommend using it.
    • Here's the path I made for a Varrock East Clay Softener:
    • Notice how there are no "in between" points since it's a direct path.
    • Simply make the path, and enter the points in the record.
    • If your path has an obstacle (i.e. door or ladder) check out the script record for the Crafting Guild Miner. You'll also have to set the Obstacle attributes in the script's record (I'll cover obstacle records later in the guide or you can look at the Crafting Guild Miner record for reference).
    • For SPSAreas, check out this thread. You'll notice that MSI's is a 2D array. This is because there may be different SPS Areas or Surfaces for different parts of the path (i.e. an essence miner).
  • Finally, like all other records, I need to add a constant to the script constants at the top of Globals.simba.

  • // Money Making
    SCRIPT_VE_SOFTENER = 100;

    SCRIPT_ARRAY_LENGTH = 100; // Change to the highest script constant
  • Okay, now the fun part! I finally get to write some real code. :) I have to write MSI_SoftenClay and MSI_SetupSoftener. Keep in mind that there may be several other procedures needed to make these work.

6. Creating the Skill/Script-Specific file
  • The first thing to do is save a "template" file as Money_Making.simba in my MSI/MSI/Skills folder.
  • This "template" file should include the documentation as well as the required functions.
  • Since I've created a new file, this file needs to be included in MSI so everything will compile properly, and the functions in the file can actually be used.
  • Open Setup.simba and add Money_Making.simba to the include list along with all the other skill files.

  • //MSI Skill Files
    {$i MSI/MSI/Skills/Woodcutting.simba}
    {$i MSI/MSI/Skills/Mining.simba}
    {$i MSI/MSI/Skills/Fishing.simba}
    {$i MSI/MSI/Skills/Cooking.simba}
    {$i MSI/MSI/Skills/Magic.simba}
    {$i MSI/MSI/Skills/Money_Making.simba}
  • At this point, it's smart to see if MSI compiles. If not, fix any compiling errors.
  • To test if MSI compiles, simply open RunMe.simba and hit run.
  • Now to write the actual functions. I'm going to take a look at Cooking.simba because Cooking is a similar setup to a ClaySoftener.
  • After looking around Cooking.simba and some other files, I finally came up with this, and made sure it compiled.

  • (*
    Money_Making
    ============

    The Money_Making file holds any procedures/functions that are specific to
    money making scripts. This file will generally hold only the functions that
    are pointed to attributes of the TScript record.

    The source for Money_Making.simba can be found
    `here <https://github.com/SRL/MSI/raw/master/MSI/Core/Money_Making.simba>`_.

    *)

    (*
    MSI_SetupSoftener
    ~~~~~~~~~~~~~~~~~

    .. code-block:: pascal

    function MSI_SetupSoftener(): Boolean;

    Sets the player up to use a Clay Softener script. This procedure is pointed
    to the script's SetupPlayer attribute.

    .. note::

    | Author: Coh3n
    | Last Updated: 27 April 2011 by Coh3n

    Example:

    .. code-block:: pascal

    MSI_Scripts[SCRIPT_VE_SOFTENER].SetupPlayer := @MSI_SetupSoftener;
    *)
    function MSI_SetupSoftener(): Boolean;
    var
    material: TMaterial;
    begin
    if (not loggedIn) then
    exit;

    // MSI_SetupCooking is exactly what we need to setup the Clay Softener
    result := MSI_SetupCooking();
    end;

    (*
    MSI_SoftenAll
    ~~~~~~~~~~~~~

    .. code-block:: pascal

    function MSI_SoftenAll(material: TMaterial): Boolean;

    Returns true if successfully selected the 'material' option from the selection
    screen in the chat box.

    .. note::

    | Author: Coh3n
    | Last Updated: 28 April 2011 by Coh3n

    Example:

    .. code-block:: pascal

    function MSI_SoftenClay(): Boolean;
    begin
    with MSI_Players[CurrentPlayer].Scripts[CurrentScript] do
    Result := MSI_ConvertMaterial(@MSI_SoftenAll, Objects);
    end;
    *)
    function MSI_SoftenAll(material: TMaterial): boolean;
    var
    i, x, y: integer;
    begin
    if (waitFunc(@MSI_CB_DoAllScreen, 50, 5000)) then // Wait for the selection screen to appear
    for i := 0 to high(material.produces) do
    if (findDTM(MSI_Items[material.produces[i]].DTM, x, y, MCX1, MCY1, MCX2, MCY2)) then // Look for the material's DTMs in the chat box
    begin
    MMouse(x, y, -25, 25);
    if (waitUpTextMulti(['Make All', 'ake', 'll'], 500)) then
    begin
    Mouse(x, y, 0, 0, true);
    result := true;
    break;
    end;
    end;

    if (result) then
    MSI_SubDebug('Started to convert material: '+material.name);
    end;

    (*
    MSI_SoftenClay
    ~~~~~~~~~~~~~~

    .. code-block:: pascal

    function MSI_SoftenClay(): Boolean;

    Returns true if all the clay in the player's inventory have been softened. This
    is the procedure that is pointed to the script's AutoObjects attribute.

    .. note::

    | Author: Coh3n
    | Last Updated: 27 April 2011 by Coh3n

    Example:

    .. code-block:: pascal

    MSI_Scripts[SCRIPT_VE_SOFTENER].AutoObjects := @MSI_SoftenClay;
    *)
    function MSI_SoftenClay(): Boolean;
    begin
    with MSI_Players[CurrentPlayer].Scripts[CurrentScript] do
    Result := MSI_ConvertMaterial(@MSI_SoftenAll, Objects); // ConvertMaterial is in Materials.simba
    end;
  • Now, before it will actually work, I need to add the new skill (in this case SKILL_NONE) to the skill case in MSI_SetReportItems and/ore MSI_SetReportInfo in Reports.simba.

  • // MSI_SetReportItems
    SKILL_COOKING, SKILL_NONE: // skills that use materials
    begin
    mat := MSI_GetMaterial(result[i]);
    setLength(items[sIndex][i], length(mat.produces));
    items[sIndex][i] := mat.produces;
    end;

    // MSI_SetReportInfo
    SKILL_COOKING, SKILL_NONE:
    begin
    scripts[j].materials := MSI_SetReportItems(i, j, scripts[j].materials, script.defaults.materials);
    scripts[j].cookingSpot := script.defaults.cookingSpot;
    scripts[j].objects := script.defaults.objects;
    end;
  • So great, now that this is done, if everything was done properly, the Clay Softener will work. Only thing is, we haven't added progress report support yet.

7. Adding to MSI's Progress Report
  • There are several functions/procedures that need to be edited for the progress report to work with a new skill. Here is a list of all the procedures that include a skill case. This means that these procedures need to be updated every time a new skill is updated. Not all of the procedures, however, will need to be updated for every skill.
    1. MSI_BestTool (Skills.simba) - No tools are required for a Clay Softener
    2. MSI_WorstTool (Skills.simba) - No tools are required for a Clay Softener
    3. MSI_AutoInvFull (Skills.simba) - AutoInvFull is used for gatherers, not manipulators
    4. MSI_GetItemExperiences (Items.simba) - No experience is gained from a Clay Softener
    5. MSI_GetPlayerObjects (Objects.simba)
      • Added the objects used for this skill to the case

      • SKILL_NONE:
        objs := Scripts[CurrentScript].Objects;
    6. MSI_ShortReport (Reports.simba)
      • Since there could be more than one script with no skill, I added a nested case in this procedure.

      • SKILL_NONE:
        case Scripts[j].Name of
        SCRIPT_VE_SOFTENER:
        IncEx(totals[TOTAL_SOFTENS], ReportInfo.ItemAmounts[j][k][l]);
        end;
      • TOTAL_SOFTENS must also be added to the list just above the procedure (MSI_ShortReport).
      • Also, the length of 'totals' in the procedure needs to be increased by one to compensate for the addition of TOTAL_SOFTENS.
      • Lastly, 'Clay Softened' needs to be added the the 'labels' array later on in the procedure.
      • If the latter two steps aren't done, the script will result in an Out of range runtime error.
    7. MSI_ProgressReport (Reports.simba)
      • This one is simple, just add SKILL_NONE to the end of the standard report case.

      • SKILL_MINING, SKILL_WOODCUTTING, SKILL_FISHING, SKILL_COOKING, SKILL_NONE:
    8. MSI_SetReportInfo (Reports.simba) - This was taken care of in the last step
  • Now, for a Clay Softener this was extremely simple. Not all scripts/skills will be like this. You'll probably have to look at all the procedures in the above list to make sure what you're adding doesn't apply to them.
  • You also may have noticed that in Reports.simba there is a specific report for Magic. You may have to write one for a different skill. It depends on how it is set up.

8. Testing the newly created script
  • Now, because there wasn't a lot to do for a Clay Softener, I didn't have to do much tweaking. I'm sure that bugs will come up, but before sending a Pull Request to an MSI Developer (see the git part of this tutorial), you should be able to produce a progress report such as this:

  • This progress report was written April 28th, 2011 at 04:53:28 AM
    {----------------------------------------------------------------}
    { MSI Phoenix Short Report }
    {----------------------------------------------------------------}
    { Time Running: 1 Hours, 53 Minutes and 12 Seconds }
    {----------------------------------------------------------------}
    { }
    { Totals: }
    { - Players: 8 }
    { - Player Time: 01h 44m 00s }
    { - Randoms Solved: 0 }
    { - Randoms Failed: 0 }
    { - Loads: 190 }
    { - Clay Softened 2,660 }
    { }
    {----------------------------------------------------------------}
    {----------------------------------------------------------------}

    {----------------------------------------------------------------}
    { MSI Phoenix Player Report }
    {----------------------------------------------------------------}
    { Time Running: 1 Hours, 53 Minutes and 13 Seconds }
    {----------------------------------------------------------------}
    { }
    { Player 0: *********** }
    { Location: Varrock east bank }
    { Time: 12m 04s }
    { Active: False }
    { Reason: Finished total time! }
    { }
    { Script: Varrock East Clay Softener }
    { Time: 12m 04s }
    { Loads: 22 }
    { Item: Soft Clay }
    { Amount: 308 }
    { }
    {----------------------------------------------------------------}
    { }
    { Player 1: *********** }
    { Location: Varrock east bank }
    { Time: 14m 07s }
    { Active: False }
    { Reason: Finished total time! }
    { }
    { Script: Varrock East Clay Softener }
    { Time: 14m 07s }
    { Loads: 26 }
    { Item: Soft Clay }
    { Amount: 364 }
    { }
    {----------------------------------------------------------------}
    { }
    { Player 2: *********** }
    { Location: Varrock east bank }
    { Time: 12m 02s }
    { Active: False }
    { Reason: Finished total time! }
    { }
    { Script: Varrock East Clay Softener }
    { Time: 12m 02s }
    { Loads: 22 }
    { Item: Soft Clay }
    { Amount: 308 }
    { }
    {----------------------------------------------------------------}
    { }
    { Player 3: ********* }
    { Location: Varrock east bank }
    { Time: 11m 51s }
    { Active: False }
    { Reason: Finished total time! }
    { }
    { Script: Varrock East Clay Softener }
    { Time: 11m 51s }
    { Loads: 22 }
    { Item: Soft Clay }
    { Amount: 308 }
    { }
    {----------------------------------------------------------------}
    { }
    { Player 4: ************ }
    { Location: Varrock east bank }
    { Time: 13m 56s }
    { Active: False }
    { Reason: Finished total time! }
    { }
    { Script: Varrock East Clay Softener }
    { Time: 13m 56s }
    { Loads: 26 }
    { Item: Soft Clay }
    { Amount: 364 }
    { }
    {----------------------------------------------------------------}
    { }
    { Player 5: ************ }
    { Location: Varrock east bank }
    { Time: 13m 57s }
    { Active: False }
    { Reason: Finished total time! }
    { }
    { Script: Varrock East Clay Softener }
    { Time: 13m 57s }
    { Loads: 24 }
    { Item: Soft Clay }
    { Amount: 336 }
    { }
    {----------------------------------------------------------------}
    { }
    { Player 6: ************ }
    { Location: Varrock east bank }
    { Time: 13m 09s }
    { Active: False }
    { Reason: Finished total time! }
    { }
    { Script: Varrock East Clay Softener }
    { Time: 13m 09s }
    { Loads: 24 }
    { Item: Soft Clay }
    { Amount: 336 }
    { }
    {----------------------------------------------------------------}
    { }
    { Player 7: *********** }
    { Location: Varrock east bank }
    { Time: 12m 49s }
    { Active: False }
    { Reason: Finished total time! }
    { }
    { Script: Varrock East Clay Softener }
    { Time: 12m 49s }
    { Loads: 24 }
    { Item: Soft Clay }
    { Amount: 336 }
    { }
    {----------------------------------------------------------------}
    {----------------------------------------------------------------}
  • Some tips for testing MSI:
    • If you need to test an individual function, just call that function in RunMe.simba:

    • //MSI_Mainloop;
      MSI_FindItemSlots(ORE_CLAY);
      end.
    • Test without the form. I haven't gone over how to add new things to the form because we are in the process of writing a new form.
  • Testing may take a couple days. You can always push to your repository (see next section) and request others to test it on this thread.

Okay, so that's all the code that needs to be changed to make a Clay Softener work with MSI. If you really think about it, a lot of skills will be just that simple since MSI already has almost every function/procedure that is needed.

Not all MSI's records were covered above, so I will outline how to create those below. They are all (for the most part) just as easy, as creating a TMaterial or TLocation record.[/INDENT]


Creating other MSI records:
[INDENT]MSI uses the following main types throughout the include. There are, of course, several other types, but they can be explained well from MSI's Documentation for Globals.simba.

Here are MSI's main types, most of which have been covered with the Clay Softener:
  1. TItem - A Runescape item found in the inventory or bank.
  2. TMSObject - A Runescape object found on the main screen.
  3. TLocation - A Runescape location.
  4. TMaterial - A Runescape item that is changed into another item.
  5. TAnimation - A player animation (uses 100% color).
  6. TObstacle - A Runescape obstacle (i.e. door, ladder, or wall).
  7. TScript - All the necessary attributes of an MSI script.
All records except TAnimation and TObstacle are covered in a Clay Softener, so I'll explain them both right now. They are both actually exactly the same as a TLocation and TMaterial, they just have their own files.
  • TAnimation
  • Simply copy/paste the new animation in to MSI_GetAnimation located in Animating.simba, and add the constant to Globals.simba. The TAnimation record from Gloabls.simba:

    type
    TAnimation = record
    Name : string;
    MinPixelShift : Integer; // Minimum pixel shift for animation
    MaxPixelShift : Integer; // Maximum pixel shift
    PixelBox : TBox; // Box to check for pixel shift
    Interval : Integer; // How long to check for pixel shift
    MaxTime : Integer; // Gets the average pixel shift from Interval over MaxTime
    WaitTime : Integer; // How long to wait for animation in ms
    end;

    TAnimationArray = array of TAnimation;
    An example declaration from Animating.simba:

    ANIM_CHOPPING:
    with Result do
    begin
    Name := 'Chopping'; // Name
    MinPixelShift := 120; // Minimum pixel shift in 'PixelBox'
    MaxPixelShift := 360; // Maximum pixel shift
    PixelBox := IntToBox(PLBX1, PLBY1, PLBX2, PLBY2); // The box to check for the pixel shift
    Interval := 50; // How long (ms) to check for pixel shift
    MaxTime := 250; // (35 * 5) = 175 (Gets the average pixel shift from 5 tries)
    WaitTime := 700; // (175 * 4) = 700 (Has to fail 4 times to not be animating)
    end;
    The constant additions to Globals.simba.

    const
    ANIM_IDLE = 0;

    ANIM_ALCH_LOW = 10;
    ANIM_ALCH_HIGH = 11;

    ANIM_FISHING = 20;
    ANIM_CHOPPING = 21;
    Basically, the animating functions will return true if the average pixel shift in the box 'PixelBox' during 'Interval' and 'MaxTime' is in range of 'MinPixelShift' and 'MaxPixelShift'. It will keep trying for 'WaitTime'. I hope that made sense. :p Keep in mind that it may take a lot of testing to get an animation just right and I recommend writing a smaller script to get gather pixel shifts so you can make the TAnimation more accurate. An animation aiding script can be found in MSI/DevelopingTools/aid_TAnimation.
  • TObstacle
  • Again, just add the record to MSI_LoadObstacle in Obstacles.simba, and add a new constant to Globals.simba. Here is the actual record (from Globals.simba):

    TObstacle = record
    Name : string;
    Constant : Integer; // Obstacle constant
    Symbol : String; // A possible symbol for or near the obstacle
    MirText : TStringArray; // Text that may appear in the chat box
    ObjConst : Integer; // Object constant
    ObjMir : Integer; // Object's mirror constant
    ObjMirArea : TBox; // Obstacle's mirror search area
    MirAction : TMouseOption; // What to do if the object is found on the MS
    Camera : TVariantArray; // Changes the camera angle and height
    end;
    And here a couple examples from Obstacles.simba:

    OBS_LADDER_MG_DOWN:
    with result do
    begin
    Name := 'OBS_LADDER_MG_DOWN';
    ObjConst := LADDER_MG_DOWN;
    ObjMir := LADDER_MG_UP;
    ObjMirArea := intToBox(MSCX - 85, MSCY - 85, MSCX + 85, MSCY + 85);
    MirAction := moNothing;
    Camera := ['n', true];
    end;

    OBS_RUINS_AIR:
    with result do
    begin
    Name := 'OBS_RUINS_AIR';
    Symbol := 'Runecrafting';
    ObjConst := RUINS_AIR;
    ObjMir := PORTAL_AIR;
    ObjMirArea := MSBox;
    MirAction := moNothing;
    Camera := ['n', true];
    end;
    The addition of the proper constant (Ctrl + F for "TObstacle" to find the constants in the file):

    const
    OBS_LADDER_MG_DOWN = 10;
    // other obstacle constants here

    OBS_RUINS_AIR = 50;
    // other obstacle constants here
    Keep in mind that you may have to create some TMSObject records if you're creating a new obstacle.
There they are. That's the last of the main MSI records. Not too difficult is it? :rolleyes: If there's something you don't understand I encourage you to take a look at MSI's Documentation for better explanations and examples of each of MSI's functions and procedures.
[/INDENT]


Adding a location/script for an existing skill:
[INDENT]This is actually much easier than you may think. All that has to be done is creating the TScript record, and since the skill exists, the functions already exist! So simply follow the steps for creating a TScript record above, and you're good to go. :)[/INDENT]


Creating an MSI Extra:
[INDENT]An MSI Extra is a completely separate file that includes functions/procedures that can be called sometime within MSI. For example, Bobzilla69 made a CharacterStats extension that will get a players stats and save it to a file so it can be opened in HTML format. An extra can be anything from a world walker to some advanced antiban that someone needs testing. Of course, the users will be able to choose which they want to use by simply commenting/uncommenting defines at the top of RunMe.simba.

For a detailed guide on exactly how to create an MSI Extra, please visit this tutorial.[/INDENT]


Useful links:
[INDENT]There is going to be some of this guide that you probably won't understand, so here is a few useful links that may help you to understand a little better.
  1. Introduction to git. If you want to be an active developer for MSI, I strongly recommend you get used to git. Now that I'm used to it, I'll never use anything else.
  2. MSI's Documentation is very useful if you want descriptions and examples of one of MSI's procedures or functions.
  3. The MSI Phoenix SVN section has a lot of development discussions that you may want to take a look at.
  4. If you just want to contribute on a smaller scale than a new skill, I encourage you to check out the MSI Core to-do List. I'm sure you can find something on there that catches your interest.
[/INDENT]


Conclusion:
[INDENT]Well that's it. Everything you need to know to contribute to MSI. You will, of course, learn several things the more to contribute, but this is all you need to get started. If there is something that is unclear or you don't understand, don't hesitate to post on this thread and myself or someone else will help you as soon as possible.

You should also know that git can be frustrating if you're new to it, so again, I urge you to post here so we can help you. I am very familiar with git now, so I should be able to help you. Any problems you're having, chances are I've had the exact same problems. You can also make a thread in the MSI Help section. :)

I hope this guide was helpful and I strongly recommend getting involved with MSI. It's a great teamwork environment and it's core has been written and is continually updated for the ease of future updates and additions.
[/INDENT]

Cheers,
The MSI Team

Sir R. M8gic1an

2010-07-04 08:12:29

Please post all comments in original thread, here:
http://villavu.com/forum/showthread.php?t=57305

~RM

Coh3n

2010-09-28 19:34:36

Reopened. :) Please post all comments/suggestions on this thread.

Coh3n

2010-10-08 17:31:13

Updated to reflect the latest changes to the player setup and TScript record.

Coh3n

2010-10-16 17:06:37

Updated with an example path for reflection. Be sure to keep the points relatively close together.

i luffs yeww

2010-10-19 03:11:31

There are some outdated things in here. RunTime for TScripts, for example.

Coh3n

2010-10-19 14:51:23

From: i luffs yeww
There are some outdated things in here. RunTime for TScripts, for example.

Runtime is still used… It just doesn't have to be set in the record.

i luffs yeww

2010-10-19 18:06:07

:o I didn't know. None of the script records had them that I saw.

Coh3n

2010-10-19 18:47:39

From: i luffs yeww
:o I didn't know. None of the script records had them that I saw.

They don't, because they're set during runtime. :p I'll add a sentence to avoid any confusing.

renafox

2010-11-03 05:55:35

I tried to add this to scripts.simba

[PHP] SCRIPT_RM_YEWS_2:
with MSI_Scripts[whichScript] do
begin
Name := 'Rimmington Yews 2';
Constant := SCRIPT_RM_YEWS_2;
SkillName := 'Woodcutting';
SkillConst := SKILL_WOODCUTTING;
BankType := DBox;
WhichBank := DBOX_PS;
AutoObjects := @MSI_ChopInvFull;
PlayerSetup := @MSI_SetupWoodcutting;

with Defaults do
begin
Trees := [TREE_YEW];
Items := [TIntegerArray([LOGS_YEW])];
end;

with PathInfo do
begin
StartLoc := LOC_PS_DBOX;
EndLoc := LOC_RM_YEWS;

Reflection := [
Point(3810, 2595), Point(3796, 2595) ,
Point(3784, 2595), Point(3770, 2592) ,
Point(3757, 2593), Point(3747, 2584) ,
Point(3734, 2587), Point(3723, 2587) ,
Point(3710, 2588), Point(3698, 2590)
];

// ObstaclePoints := [];
// Obstacles := [];
// DoObstacles := [];
end;
end; [/PHP]

and added
[PHP]SCRIPT_RM_YEWS_2 = 24;[/PHP]

to globals.simba



didnt work..


I tried to compile (CRTL + F9) them (globals.simba ,scripts.simba) but it has errors already before i even added the new stuff. So i saved them when i try to run it in the runme.simba
it dont work has error message

[PHP][Error] (65:17): Unknown identifier 'SCRIPT_RM_YEWS_2' at line 64 [/PHP]
in debug box


I think i havnt compiled it yet how do i compile it? I also tried CRTL + F9 on the other .simba files in my MSI folder but all of them cant compile ..

Coh3n

2010-11-03 13:19:00

You don't compile the individual files, you compile RunMe.simba.

If RunMe.simba compiles, you did it right. :)

renafox

2010-11-03 13:45:22

it still shows this message

[PHP][Error] (65:17): Unknown identifier 'SCRIPT_RM_YEWS_2' at line 64[/PHP]

any idea what i did wrong? I did what i did above ^

Coh3n

2010-11-03 21:17:48

Did you add SCRIPT_RM_YEWS_2 to Globals.simba? If so, then you're still not running the right script. If you add the constant and script record then it will work. You may have to save the files before you run RunMe.simba.

renafox

2010-11-03 23:55:36

From: Coh3n
Did you add SCRIPT_RM_YEWS_2 to Globals.simba? If so, then you're still not running the right script. If you add the constant and script record then it will work. You may have to save the files before you run RunMe.simba.


how do i add the constant and script record? sry but i need to make sure if im doing it right..

Coh3n

2010-11-04 02:07:10

From: renafox
how do i add the constant and script record? sry but i need to make sure if im doing it right..

At the top of Globals.simba, there is a list of all the script constants, simply add yours to the list. :)

In Scripts.simba, there is an MSI_LoadScript procedure. Look at how the script records are setup there, and I'm sure you get it. ;)

renafox

2010-11-04 05:38:04

From: Coh3n
At the top of Globals.simba, there is a list of all the script constants, simply add yours to the list. :)

In Scripts.simba, there is an MSI_LoadScript procedure. Look at how the script records are setup there, and I'm sure you get it. ;)


yes thats wwhat i Did it still shows that annoying error..

Coh3n

2010-11-04 09:47:40

From: renafox
yes thats wwhat i Did it still shows that annoying error..

Then, I'm not sure what you're doing. I just did it and it works fine.

Globals.simba:

{==============================================================================\
| Constants |
\==============================================================================}

(**
* All of MSI's suppoted script constants; used in player setup
*)
const
// Woodcutting
SCRIPT_POWER_CHOP = 10;
SCRIPT_VE_TREES = 11;
SCRIPT_VE_OAKS = 12;
SCRIPT_GE_YEWS = 13;
SCRIPT_DB_WILLOWS = 14;
SCRIPT_DB_TREES = 15;
SCRIPT_DB_OAKS = 16;
SCRIPT_RM_YEWS = 17;
SCRIPT_PS_WILLOWS = 18;
SCRIPT_PS_YEWS = 19;
SCRIPT_SV_MAGICS = 20;
SCRIPT_SV_MAPLES = 21;
SCRIPT_SV_YEWS = 22;
SCRIPT_EV_YEWS = 23;
SCRIPT_RM_YEWS_2 = 24;

Scripts.simba

SCRIPT_EV_YEWS:
with MSI_Scripts[whichScript] do
begin
Name := 'Edgeville yews';
Constant := SCRIPT_EV_YEWS;
SkillName := 'Woodcutting';
SkillConst := SKILL_WOODCUTTING;
BankType := Bank;
WhichBank := MSI_BANK_EV;
AutoObjects := @MSI_ChopInvFull;
PlayerSetup := @MSI_SetupWoodcutting;

with Defaults do
begin
Trees := [TREE_YEW];
Items := [TIntegerArray([LOGS_YEW])];
end;

with PathInfo do
begin
StartLoc := LOC_EV_BANK;
EndLoc := LOC_EV_YEWS;

Reflection := [
Point(3093, 3492), Point(3093, 3478),
Point(3087, 3472)
];

// ObstaclePoints := [];
// Obstacles := [];
// DoObstacles := [];
end;
end;

SCRIPT_RM_YEWS_2:
with MSI_Scripts[whichScript] do
begin
Name := 'Rimmington Yews 2';
Constant := SCRIPT_RM_YEWS_2;
SkillName := 'Woodcutting';
SkillConst := SKILL_WOODCUTTING;
BankType := DBox;
WhichBank := DBOX_PS;
AutoObjects := @MSI_ChopInvFull;
PlayerSetup := @MSI_SetupWoodcutting;

with Defaults do
begin
Trees := [TREE_YEW];
Items := [TIntegerArray([LOGS_YEW])];
end;

with PathInfo do
begin
StartLoc := LOC_PS_DBOX;
EndLoc := LOC_RM_YEWS;

Reflection := [
Point(3810, 2595), Point(3796, 2595) ,
Point(3784, 2595), Point(3770, 2592) ,
Point(3757, 2593), Point(3747, 2584) ,
Point(3734, 2587), Point(3723, 2587) ,
Point(3710, 2588), Point(3698, 2590)
];

// ObstaclePoints := [];
// Obstacles := [];
// DoObstacles := [];
end;
end;

{ MINERS ===================================== ]
[============================================= }
Keep in mind those aren't the entire files. You could also post your Globals.simba and Scripts.simba so I can see what you're doing.

renafox

2010-11-21 19:11:35

i wanna make a addy miner script


do i need to add new banks / deposit boxes (are the banks different in colour gonna affect the script)?
and for reflection there isnt any map that is in keldergrim city

Coh3n

2010-11-21 20:39:51

Oo that looks like a good spot. What's the other ore there? Also, you would need a location record for the bank and mine, an object record for the bank, and a record for the actual script. Since Keldagrim isn't on the map, you'll have to use the other path maker written by drags111. It should be in the reflection tools folder.

renafox

2010-11-21 22:03:28

From: Coh3n
Oo that looks like a good spot. What's the other ore there? Also, you would need a location record for the bank and mine, an object record for the bank, and a record for the actual script. Since Keldagrim isn't on the map, you'll have to use the other path maker written by drags111. It should be in the reflection tools folder.


i checked my reflection folder it has the pathmaker by sumilion the one i usually use.
that pathmaker uses the world (surface) map that doesnt have keldergrim

there isnt any pathmaker by drags111 in my reflection folder =/
is there any other dl?

i luffs yeww

2010-11-21 22:16:49

You just have to download the image of Keldagrim from somewhere and get the offsets.

renafox

2010-11-23 01:18:53

how do i get offsets?

Coh3n

2010-11-23 01:21:19

I've attached Drag's pathmather to this post. You can try that out. It's easy to use. :)

renafox

2010-11-23 06:56:16

How do i fill in these stuff in objects.simba


MSI_BANK_KD:
with MSI_Objects[whichObject] do
begin
Name := 'Keldergrim bank';
UpText := 'ooth';
Option := 'uick';
Colors := [2379871]; // ?????
Tol := 5; //?????
Hue := 0.06; //?????
Sat := 1.61; //?????
FindAllColors := False; //?????
W := 40; //?????
H := 40; //?????
Accuracy := 50; //?????
ExcludeSelf := True; //?????
RightClickOnly := True;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := []; //?????
BadColorTolerance := 10; //?????
end;

Coh3n

2010-11-24 01:29:55

Description can be found where the type is listed in Globals.simba. ACA = Autocolor Aid and is found in Simba/Includes/SRL/Scripting Tools. It's a very nifty tool that helps you get all the color information you need. :)

MSI_BANK_KD:
with MSI_Objects[whichObject] do
begin
Name := 'Keldergrim bank';
UpText := 'ooth';
Option := 'uick';
Colors := [2379871]; // Best color found using ACA
Tol := 5; // ACA
Hue := 0.06; // ACA
Sat := 1.61; // ACA
FindAllColors := False; // Look for every color in the Colors array
W := 40; // Width (in pixels) of one booth - better to leave the same as other bank records
H := 40; // Height
Accuracy := 50; // Minimum points to be found - again better to leave the same as other bank records
ExcludeSelf := True; // The rest can be left the same as other bank records
RightClickOnly := True;
Tries := 5;
Anim := False;
WaitToMove := True;
BadColors := [];
BadColorTolerance := 10;
end;

renafox

2010-11-24 04:34:36

i dont seem to have the 'scripting tools' folder in my "Simba/Includes/SRL"

Coh3n

2010-11-24 15:41:34

From: renafox
i dont seem to have the 'scripting tools' folder in my "Simba/Includes/SRL"

Odd. Did you download SRL using the Simba extension? Or SVN?

You can download the program from here. Click the little "Click here" at the bottom (right after it says "Save file to your PC").

renafox

2010-11-24 23:24:57

'The file link that you requested is not valid. Please contact link publisher or try to make a search. '

used simba extension

Coh3n

2010-11-25 01:09:19

From: renafox
'The file link that you requested is not valid. Please contact link publisher or try to make a search. '

used simba extension

ACA comes in SRL when you download it via SVN. You need the open-dev version. You can find a detailed guide here.

As for the download think, I'm not sure. It works fine for me. :unsure:

Coh3n

2011-04-28 10:56:00

I have finally finished updating this guide! It is much much clearer, and outlines how I added a Clay Softener to MSI. Anyone should be able to follow the same steps to add any skill and/or script they wish to MSI. :)

NCDS

2011-04-28 11:16:04

From: Coh3n
I have finally finished updating this guide! It is much much clearer, and outlines how I added a Clay Softener to MSI. Anyone should be able to follow the same steps to add any skill and/or script they wish to MSI. :)


Looks great! :)

Echo_

2011-04-28 12:29:31

MEGA-descriptive tutorial, and easy to understand too. Thanks for updating it :)

Coh3n

2011-04-28 19:00:50

From: Echo_
MEGA-descriptive tutorial, and easy to understand too. Thanks for updating it :)

:)

I'm hoping it will get more people involved.

NCDS

2011-04-28 23:41:13

From: Coh3n
:)

I'm hoping it will get more people involved.


@Everyone, ***HINT!***





:)

Echo_

2011-04-30 08:58:48

From: NCDS
@Everyone, ***HINT!***


I felt like helping out, then I found the MSI todo list :p Here's what I did anyways, just made TItem records for all of the bars in RS.

Items.simba
//MSI_GetDTMPoints

BAR_BRONZE, BAR_IRON, BAR_SILVER, BAR_STEEL,
BAR_GOLD, BAR_MITHRIL, BAR_ADAMANT, BAR_RUNE:
Result := [
Point(15, 10),
Point(1, 17),
Point(17, 22),
Point(29, 6),
Point(12, 2)
];

//MSI_GetItemColor

BAR_BRONZE : Result := 2374992;
BAR_IRON : Result := 5329237;
BAR_SILVER : Result := 11183011;
BAR_STEEL : Result := 8158338;
BAR_GOLD : Result := 2074835;
BAR_MITHRIL : Result := 6439490;
BAR_ADAMANT : Result := 4871497;
BAR_RUNE : Result := 6840656;

//MSI_LoadItem

BAR_BRONZE:
with MSI_Items[whichItem] do
begin
Name := 'Bronze Bar';
StatsName := 'Bronze Bars Melted';
UpText := ['ronze bar'];
Stackable := False;
EquipLevel := -1;
end;

BAR_IRON:
with MSI_Items[whichItem] do
begin
Name := 'Iron Bar';
StatsName := 'Iron Bars Melted';
UpText := ['ron bar'];
Stackable := False;
EquipLevel := -1;
end;

BAR_SILVER:
with MSI_Items[whichItem] do
begin
Name := 'Silver Bar';
StatsName := 'Silver Bars Melted';
UpText := ['ilver bar'];
Stackable := False;
EquipLevel := -1;
end;

BAR_STEEL:
with MSI_Items[whichItem] do
begin
Name := 'Steel Bar';
StatsName := 'Steel Bars Melted';
UpText := ['teel bar'];
Stackable := False;
EquipLevel := -1;
end;

BAR_GOLD:
with MSI_Items[whichItem] do
begin
Name := 'Gold Bar';
StatsName := 'Gold Bars Melted';
UpText := ['old bar'];
Stackable := False;
EquipLevel := -1;
end;

BAR_MITHRIL:
with MSI_Items[whichItem] do
begin
Name := 'Mithril Bar';
StatsName := 'Mithril Bars Melted';
UpText := ['ithril bar'];
Stackable := False;
EquipLevel := -1;
end;

BAR_ADAMANT:
with MSI_Items[whichItem] do
begin
Name := 'Adamant Bar';
StatsName := 'Adamant Bars Melted';
UpText := ['damant bar'];
Stackable := False;
EquipLevel := -1;
end;

BAR_RUNE:
with MSI_Items[whichItem] do
begin
Name := 'Rune Bar';
StatsName := 'Rune Bars Melted';
UpText := ['une bar'];
Stackable := False;
EquipLevel := -1;
end;

Globals.simba
  BAR_BRONZE  = 181;
BAR_IRON = 182;
BAR_SILVER = 183;
BAR_STEEL = 184;
BAR_GOLD = 185;
BAR_MITHRIL = 186;
BAR_ADAMANT = 187;
BAR_RUNE = 188;

ITEM_ARRAY_LENGTH = 188;

NCDS

2011-04-30 14:53:02

From: Echo_
I felt like helping out, then I found the MSI todo list :p Here's what I did anyways, just made TItem records for all of the bars in RS.

Items.simba
//MSI_GetDTMPoints

BAR_BRONZE, BAR_IRON, BAR_SILVER, BAR_STEEL,
BAR_GOLD, BAR_MITHRIL, BAR_ADAMANT, BAR_RUNE:
Result := [
Point(15, 10),
Point(1, 17),
Point(17, 22),
Point(29, 6),
Point(12, 2)
];

//MSI_GetItemColor

BAR_BRONZE : Result := 2374992;
BAR_IRON : Result := 5329237;
BAR_SILVER : Result := 11183011;
BAR_STEEL : Result := 8158338;
BAR_GOLD : Result := 2074835;
BAR_MITHRIL : Result := 6439490;
BAR_ADAMANT : Result := 4871497;
BAR_RUNE : Result := 6840656;

//MSI_LoadItem

BAR_BRONZE:
with MSI_Items[whichItem] do
begin
Name := 'Bronze Bar';
StatsName := 'Bronze Bars Melted';
UpText := ['ronze bar'];
Stackable := False;
EquipLevel := -1;
end;

BAR_IRON:
with MSI_Items[whichItem] do
begin
Name := 'Iron Bar';
StatsName := 'Iron Bars Melted';
UpText := ['ron bar'];
Stackable := False;
EquipLevel := -1;
end;

BAR_SILVER:
with MSI_Items[whichItem] do
begin
Name := 'Silver Bar';
StatsName := 'Silver Bars Melted';
UpText := ['ilver bar'];
Stackable := False;
EquipLevel := -1;
end;

BAR_STEEL:
with MSI_Items[whichItem] do
begin
Name := 'Steel Bar';
StatsName := 'Steel Bars Melted';
UpText := ['teel bar'];
Stackable := False;
EquipLevel := -1;
end;

BAR_GOLD:
with MSI_Items[whichItem] do
begin
Name := 'Gold Bar';
StatsName := 'Gold Bars Melted';
UpText := ['old bar'];
Stackable := False;
EquipLevel := -1;
end;

BAR_MITHRIL:
with MSI_Items[whichItem] do
begin
Name := 'Mithril Bar';
StatsName := 'Mithril Bars Melted';
UpText := ['ithril bar'];
Stackable := False;
EquipLevel := -1;
end;

BAR_ADAMANT:
with MSI_Items[whichItem] do
begin
Name := 'Adamant Bar';
StatsName := 'Adamant Bars Melted';
UpText := ['damant bar'];
Stackable := False;
EquipLevel := -1;
end;

BAR_RUNE:
with MSI_Items[whichItem] do
begin
Name := 'Rune Bar';
StatsName := 'Rune Bars Melted';
UpText := ['une bar'];
Stackable := False;
EquipLevel := -1;
end;

Globals.simba
  BAR_BRONZE  = 181;
BAR_IRON = 182;
BAR_SILVER = 183;
BAR_STEEL = 184;
BAR_GOLD = 185;
BAR_MITHRIL = 186;
BAR_ADAMANT = 187;
BAR_RUNE = 188;

ITEM_ARRAY_LENGTH = 188;

Thanks. :) Smithing was the next skill I planned on doing anyhow. :P

IPwnz

2011-04-30 17:05:16

From: NCDS
Thanks. :) Smithing was the next skill I planned on doing anyhow. :P


Really? That's the one skill I was going to try working on as well! :D Once summer rolls around (2 weeks left) I'll have plenty of time to work on it, we can talk on MSN some more if you like.

NCDS

2011-04-30 21:02:38

From: IPwnz
Really? That's the one skill I was going to try working on as well! :D Once summer rolls around (2 weeks left) I'll have plenty of time to work on it, we can talk on MSN some more if you like.


Should be pretty simple with the functions added for Cooking, as they are all the same. Probably a couple hour process before it's ready for testing, if that.

IPwnz

2011-04-30 21:35:48

From: NCDS
Should be pretty simple with the functions added for Cooking, as they are all the same. Probably a couple hour process before it's ready for testing, if that.


Yeah well you know how testing can go… :D But yeah, I'm just swamped until exams and volleyball are done.

Echo_

2011-05-01 09:14:25

I started a smelting base a while back, I think I deleted it though. It was just cooking with some edits, shouldn't be too hard to rewrite.

I'm interested in MSI now, I'd be happy to help out some more :)

Yago

2011-05-01 16:35:13

I added edgeville to clay softener and its working. Just rying to figure github out…

Onve i upload it can some edit the colors because they work but arent too accurate.

Coh3n

2011-05-01 22:48:51

From: Yago
I added edgeville to clay softener and its working. Just rying to figure github out…

Onve i upload it can some edit the colors because they work but arent too accurate.

Absolutely. :) I can help out with github if you're having any problems.

I'm glad more people are getting involved.

Yago

2011-05-01 23:26:26

From: Coh3n
Absolutely. :) I can help out with github if you're having any problems.

I'm glad more people are getting involved.


I got some help (little but enough) on the IRC … couldn't find you online. I sent a commit. Make sure the color is good because it also sense other colors around it.

The well has black colors on it. I don't mind if you switch to those either. As long as it works:)

Coh3n

2011-05-01 23:29:38

From: Yago
I got some help (little but enough) on the IRC … couldn't find you online. I sent a commit. Make sure the color is good because it also sense other colors around it.

The well has black colors on it. I don't mind if you switch to those either. As long as it works:)

Just saw the pul request, thanks. :)

Rich

2011-05-05 12:15:54

I'm going to have a shot at making a vial filler. Hopefully with the clay softener already there I should understand it a bit better, but we'll see. Don't expect it to be done today :p

Coh3n

2011-05-05 12:34:58

From: Rich
I'm going to have a shot at making a vial filler. Hopefully with the clay softener already there I should understand it a bit better, but we'll see. Don't expect it to be done today :p

Awesome! I was going to add it the same time as the clay softener, but I was hoping someone else would do it.

I'm actually pretty sure all you would need to do is do make the records. Since a Vial filler is exactly the same as a softener (with different items), all the functions/procedures are the same.

Rich

2011-05-05 12:42:04

From: Coh3n
Awesome! I was going to add it the same time as the clay softener, but I was hoping someone else would do it.

I'm actually pretty sure all you would need to do is do make the records. Since a Vial filler is exactly the same as a softener (with different items), all the functions/procedures are the same.
I've never really got involved with MSI, but let's hope that changes. And even I, after reading your guide (great guide BTW) can be fairly sure you're right there. I'm not sure if a new procedure would need to be made, or MSI_SoftenClay would work, when the vials are about to be filled, but I think the clay softening and vial filling menu thingy is the same? I'll start tonight! :D

Coh3n

2011-05-05 12:45:22

From: Rich
I've never really got involved with MSI, but let's hope that changes. And even I, after reading your guide (great guide BTW) can be fairly sure you're right there. I'm not sure if a new procedure would need to be made, or MSI_SoftenClay would work, when the vials are about to be filled, but I think the clay softening and vial filling menu thingy is the same? I'll start tonight! :D

Sounds great! :)

It may be the same, but I have a feeling the uptext will be slightly different, but it's not hard to work around that. It's definitely nothing you can't handle.

Yago

2011-05-05 15:45:40

From: Coh3n
Sounds great! :)

It may be the same, but I have a feeling the uptext will be slightly different, but it's not hard to work around that. It's definitely nothing you can't handle.


Yeah I don't think you have a do all screen that's all. Just wait until all the vials are full or none are empty…

Rich

2011-05-05 16:37:22

From: Yago
Yeah I don't think you have a do all screen that's all. Just wait until all the vials are full or none are empty…
Yup. That's what I've done. Just wondering, would a separate script need to be made for filling Jugs, or is there somewhere I could add an option? Just wondering, because they give profit as well.

EDIT: And bowls, and cups :p

Yago

2011-05-05 16:48:10

From: Rich
Yup. That's what I've done. Just wondering, would a separate script need to be made for filling Jugs, or is there somewhere I could add an option? Just wondering, because they give profit as well.

EDIT: And bowls, and cups :p


Same script just check if they have a do all screen and add the item records…

Edit: Maybe just have a filler script and you choose what to fill. Such as the powerchopper where you choose what to chop.

Rich

2011-05-05 17:03:19

From: Yago
Same script just check if they have a do all screen and add the item records…

Edit: Maybe just have a filler script and you choose what to fill. Such as the powerchopper where you choose what to chop.
Ooooh thanks. I've had a look at the PowerChopper, and now know how I'm going to add the others.

One thing I really can't get the hang of though is git. Will defo need someone to give me a hand with that.

EDIT:

{----------------------------------------------------------------}
{ MSI Phoenix Player Report }
{----------------------------------------------------------------}
{ Time Running: 14 Minutes and 35 Seconds }
{----------------------------------------------------------------}
{ }
{ Player 0: ****** }
{ Location: Varrock east bank }
{ Time: 13m 08s }
{ Active: False }
{ Reason: Finished total loads! }
{ }
{ Script: Varrock East Vial Filler }
{ Time: 13m 08s }
{ Loads: 30 }
{ Item: Vial of water }
{ Amount: 420 }
{ }
{----------------------------------------------------------------}
{----------------------------------------------------------------}
It's running perfectly. I'm going to add the other containers tomorrow, and since I don't have a clue how to use git, I'll just .rar the files.

Yago

2011-05-05 18:26:47

From: Rich
Ooooh thanks. I've had a look at the PowerChopper, and now know how I'm going to add the others.

One thing I really can't get the hang of though is git. Will defo need someone to give me a hand with that.

EDIT:

{----------------------------------------------------------------}
{ MSI Phoenix Player Report }
{----------------------------------------------------------------}
{ Time Running: 14 Minutes and 35 Seconds }
{----------------------------------------------------------------}
{ }
{ Player 0: ****** }
{ Location: Varrock east bank }
{ Time: 13m 08s }
{ Active: False }
{ Reason: Finished total loads! }
{ }
{ Script: Varrock East Vial Filler }
{ Time: 13m 08s }
{ Loads: 30 }
{ Item: Vial of water }
{ Amount: 420 }
{ }
{----------------------------------------------------------------}
{----------------------------------------------------------------}
It's running perfectly. I'm going to add the other containers tomorrow, and since I don't have a clue how to use git, I'll just .rar the files.


I can help you with git. I barely know anything but ill be on IRC now. For the proggie, most fillers and softeners have a vial or clay per hour thing. I think this might have been suggested for progress reports, but it would be nice.

Coh3n

2011-05-05 23:25:26

From: Rich
Ooooh thanks. I've had a look at the PowerChopper, and now know how I'm going to add the others.

One thing I really can't get the hang of though is git. Will defo need someone to give me a hand with that.

EDIT:

{----------------------------------------------------------------}
{ MSI Phoenix Player Report }
{----------------------------------------------------------------}
{ Time Running: 14 Minutes and 35 Seconds }
{----------------------------------------------------------------}
{ }
{ Player 0: ****** }
{ Location: Varrock east bank }
{ Time: 13m 08s }
{ Active: False }
{ Reason: Finished total loads! }
{ }
{ Script: Varrock East Vial Filler }
{ Time: 13m 08s }
{ Loads: 30 }
{ Item: Vial of water }
{ Amount: 420 }
{ }
{----------------------------------------------------------------}
{----------------------------------------------------------------}
It's running perfectly. I'm going to add the other containers tomorrow, and since I don't have a clue how to use git, I'll just .rar the files.
I'm glad you got it working, but please, please don't .rar all the files. I won't be adding them if you do it that way. There's no easy way for me to see exactly what you've changed (I know you could tell me, but I'd like to see for myself). Git really isn't hard, people usually just need help when they start. I can help if you need it, just through me a PM if you need to.

From: Yago
I can help you with git. I barely know anything but ill be on IRC now. For the proggie, most fillers and softeners have a vial or clay per hour thing. I think this might have been suggested for progress reports, but it would be nice.

There's a thread for the progress report stuff.

http://villavu.com/forum/showthread.php?t=60577

Most of the stuff is extremely easy to add (I think).

Rich

2011-05-06 03:11:57

OK. The main problem I was having was that I couldn't actually download git. I'm not sure why :o

Coh3n

2011-05-06 09:59:45

From: Rich
OK. The main problem I was having was that I couldn't actually download git. I'm not sure why :o

What do you mean? Do you get errors or something? What OS are you using?

Rich

2011-05-06 11:56:20

Never mind. I've got git sorted. I've just sent a Pull Request on git, I think? The script now fills vials, jugs, bowls and buckets at VE.

Coh3n

2011-05-06 15:04:18

From: Rich
Never mind. I've got git sorted. I've just sent a Pull Request on git, I think? The script now fills vials, jugs, bowls and buckets at VE.

Looks good, check out the discussion, and I'm assuming you've tested each item?

Rich

2011-05-06 15:05:23

From: Coh3n
Looks good, check out the discussion, and I'm assuming you've tested each item?
Yup. All worked fine.

Coh3n

2011-05-06 15:10:30

From: Rich
Yup. All worked fine.

Great, check this out if you haven't already and continue the discussion there please.

NCDS

2011-05-06 21:51:58

From: Coh3n
Great, check this out if you haven't already and continue the discussion there please.


Looks like your re-write of the how-to guide was successful in getting people active. :) Awesome job!

Yago

2011-05-19 23:20:49

Maybe how to add stats to MSI? unless it happen automatically

NCDS

2011-05-19 23:32:04

From: Yago
Maybe how to add stats to MSI? unless it happen automatically


Stats are all implemented you would only need to add the proper vars if you were to add a new skill or new items/objects.

Yago

2011-05-20 15:31:00

Ok thanks.

Coh3n

2011-05-20 16:22:39

From: Yago
Maybe how to add stats to MSI? unless it happen automatically

Yeah, like NCDS, it's all included, just not explicitly. The stat's are incremented in MSI_AddToProggy (Debug.simba), and the variable names are declared when you create a TItem record.

RAM

2011-06-07 20:06:21

Had some time today, created my own branch and committed some ore colors and tol changes for objects used in Swamp Miner.

Just wanted to say Thanks to everyone involved in SRL and MSI, haven't had much time to do more than leech, er test scripts(tester cup=pro leecher;) lately, great guide here Co3h as well as all the other work you have put in….almost inspires me to want to write something…almost…

~RAM

the smith400

2011-06-08 04:38:53

From: Coh3n



[*]Now if you look in the procedure MSI_GetDTMPoints, you'll notice a bunch of points for all the different items. Copy one of the items and replace it with the points you just gathered, then add it to the end of the procedure. *HINT* Take a screen shot or write down the points/colors, so you can close the DTM Editor and work with only one Simba.


CLAY_SOFT:
Result := [
Point(28, 25),
Point(16, 27),
Point(27, 13),
Point(39, 26),
Point(28, 33)
];

else
MSI_SubDebug('MSI_GetDTMPoints: Invalid item constant - ' + IntToStr(which));
end;
end;
[*]Now do the same for the main point's color: add it to the end of the MSI_GetItemColor function.

CLAY_SOFT: Result := 802904;


Does the colour in: (28, 25, 802904, 0, 1, 0)
Have to match the colour in:

CLAY_SOFT: Result := 802904;
Does it have to be the colour at point (28,25)? Or can it be any other colour?

Coh3n

2011-09-16 14:55:28

From: RAM
Had some time today, created my own branch and committed some ore colors and tol changes for objects used in Swamp Miner.

Just wanted to say Thanks to everyone involved in SRL and MSI, haven't had much time to do more than leech, er test scripts(tester cup=pro leecher;) lately, great guide here Co3h as well as all the other work you have put in….almost inspires me to want to write something…almost…

~RAM
Haha almost… :garfield:

Glad you like the guide. :)

From: the smith400
Does the colour in: (28, 25, 802904, 0, 1, 0)
Have to match the colour in:

CLAY_SOFT: Result := 802904;
Does it have to be the colour at point (28,25)? Or can it be any other colour?

The colors don't have to match, but it's more likely to work if they do. As for the coord of the point, it doesn't have to me (28, 25). Depending on the size of the image you're using, the coordinates will always be different.

What it does is compare each point relative to the other points so they can be at any coordinates. Hope that helps.

E: Updated to reflect latest updates.

Markus

2011-11-07 06:40:36

Wowa, thorough guide! Did this one exist when I tried to script for MSI once? If so I'm a moron.
I'd like to practice a bit, do you have something not too hard (F2P) I can add to MSI? Like some miner/woodcutter, crafting guild maybe?

Edit: Falador yews are still not implemented, right? I'll try to give them a go tonight, just like previous time. Though this time I'll code sober instead of applying for members with a drunken script.

Yago

2011-11-07 14:38:40

Is all this info up-to-date with the new location system and other updates that have gone through?

Edit: I'm trying to see if I can improve some stuff

Coh3n

2011-11-09 02:04:23

From: Markus
Wowa, thorough guide! Did this one exist when I tried to script for MSI once? If so I'm a moron.
I'd like to practice a bit, do you have something not too hard (F2P) I can add to MSI? Like some miner/woodcutter, crafting guild maybe?

Edit: Falador yews are still not implemented, right? I'll try to give them a go tonight, just like previous time. Though this time I'll code sober instead of applying for members with a drunken script.
Yeah Fally Yews would be a good start. And yes, this guide as always been here. ;)

From: Yago
Is all this info up-to-date with the new location system and other updates that have gone through?

Edit: I'm trying to see if I can improve some stuff
It should be, yeah.

Yago

2011-11-09 20:16:28

From: Coh3n
It should be, yeah.


Is the location good with the new compass angle and stuff?

Coh3n

2011-11-10 01:43:24

I don't know what you mean? Do you mean does it work with the new compass angle stuff? Yeah.

Yago

2011-11-10 17:06:21

From: Coh3n
I don't know what you mean? Do you mean does it work with the new compass angle stuff? Yeah.


Dont Worry. Disregard me ;)

PerryP

2011-11-10 17:21:16

First i have to say, what a fantastic community and also a fantastic tutorial!

OnT: I would suggest that the part about Reflection Path be rewritten due to reflection not working, the use of SPS could instead be run through a bit more in depth… If it is as it seems with SPS that the points to click are exact every time i would suggest that you explain a simple system for switching between a few different paths at random just as a extra anti-detection thus giving new scripters a better start.

Will hopefully be able to contribute script-wise in the future but for now i'll keep to ideas, reacquainting myself with scripting and learning the fantastic improvements that has been made since SCAR

Edit: Of course… silly of me not to expect an existing antiban system for walking, nvm that part of the post…

2ond Edit: If one were to write a script that were to walk different paths on the way to and from the bank, i.e a script for mining clay in draynor that where to soften the clay at the waterpump on the way back, how would one handle that? as far as i can see it is a switch with only two values, true and false(true going to LocEnd, false reversing it)? Would it be best to create a obstacle that leaves the path, calls the claysoftening and then goes back to the path(would be quite non-human) or could it be solved in a different way?

Swagger

2011-11-10 17:44:00

Absolutely agree with Perry, fantastic guide. I'll start carefully following the instructions and testing how it works out starting this weekend. I had just started learning Java when Bot Nuke day occurred, but I've heard this is a lot more user-friendly then Java - am I right? Looking forward to being able to create my own scripts, thanks again for the time spent writing this.

Coh3n

2011-11-11 01:49:29

From: PerryP
2ond Edit: If one were to write a script that were to walk different paths on the way to and from the bank, i.e a script for mining clay in draynor that where to soften the clay at the waterpump on the way back, how would one handle that? as far as i can see it is a switch with only two values, true and false(true going to LocEnd, false reversing it)? Would it be best to create a obstacle that leaves the path, calls the claysoftening and then goes back to the path(would be quite non-human) or could it be solved in a different way?
Good question. Right now, I don't think MSI has an easy way of solving this simply because we've never had a script to do something like this. Off the top of my head, you could have a different type of script and the Walking method would be laid out something like this:

function ActivityDuringWalking(): boolean;
begin
with PathToPump do
begin
// declare the TPath here
end;

MSI_WalkPath(PathToPump);
MSI_SoftenClay();

with PathFromPump do
begin
// declare path here
end;

result := MSI_WalkPath(PathFromPump);
end;
Obviously it wouldn't work exactly like that, but that's a general outline. You'd have to compensate for to and from the location + get the right parameters for some functions. But basically, that should work for an alternate walking method. More scripts could come from this idea as well.

And yeah, I'll update the reflection part as soon as I can.

From: dixienormous
Absolutely agree with Perry, fantastic guide. I'll start carefully following the instructions and testing how it works out starting this weekend. I had just started learning Java when Bot Nuke day occurred, but I've heard this is a lot more user-friendly then Java - am I right? Looking forward to being able to create my own scripts, thanks again for the time spent writing this.
It's easier to learn as a beginner in my opinion.

Itankbots

2011-12-09 21:26:36

Is this guide still up-to-date? Im intrested in learning to script. and Of course wanna make sure the guide im learning from is still correct information =p thanks

Coh3n

2011-12-10 00:55:57

From: Itankbots
Is this guide still up-to-date? Im intrested in learning to script. and Of course wanna make sure the guide im learning from is still correct information =p thanks
Everything should be up to date. :)

wardy1100

2011-12-17 04:04:51

hey i added CB bank and Stove to everything but when i went to run it. it came up with a error message
[Error] C:\Simba\Includes\MSI/MSI/Core/Scripts.simba(48:9): Unknown identifier 'SConst' at line 47
Compiling failed.

not a clue whats happened here… i didnt even touch woodcutting haha
any help?

… fixed that error … but its now not finding SCRIPT_POWER_CHOP

bewaredrev

2012-02-07 17:53:06

this weekend will be fun.

edit: could I try and make a script for monkfish fishing area when I get the time to read this

Kyle Undefined

2012-02-07 18:19:12

From: bewaredrev
this weekend will be fun.

edit: could I try and make a script for monkfish fishing area when I get the time to read this


Yes, but please make sure you try to keep everything the way it needs to be, as in the standards, naming conventions, etc :)

Coh3n

2012-02-07 20:41:03

From: bewaredrev
this weekend will be fun.

edit: could I try and make a script for monkfish fishing area when I get the time to read this
Yes, that would be quite simple if you followed this guide. :) That's exactly the kind of thing it was written for.

putonajonny

2012-02-08 17:50:05

I have written this so far, but I am a bit confused, how do I tell the script to go to the tanner tan the hides and then back, did I miss out a step?

//MSI_GetDTMPoints
HIDE_DRAGON_GREEN :
Result := [
Point(110, 23),
Point(123, 21),
Point(112, 36),
Point(97, 24),
Point(109, 10)
];

HIDE_DRAGON_BLUE :
Result := [
Point(65, 93),
Point(65, 78),
Point(78, 91),
Point(67, 106),
Point(50, 94)
];

HIDE_DRAGON_RED :
Result := [
Point(66, 166),
Point(63, 150),
Point(78, 163),
Point(69, 178),
Point(50, 166)
];

HIDE_DRAGON_BLACK :
Result := [
Point(65, 201),
Point(63, 186),
Point(78, 199),
Point(67, 214),
Point(50, 202)
];

HIDE_COW :
Result := [
Point(67, 53),
Point(63, 42),
Point(78, 53),
Point(68, 70),
Point(54, 65)
];

LEATHER_HARD :
Result := [
Point(22, 21),
Point(21, 6),
Point(8, 22),
Point(36, 19),
Point(32, 29)
];

LEATHER_SOFT :
Result := [
Point(23, 53),
Point(21, 44),
Point(12, 49),
Point(26, 70),
Point(36, 55)
];

LEATHER_DRAGON_BLACK :
Result := [
Point(21, 198),
Point(12, 193),
Point(31, 189),
Point(34, 206),
Point(15, 211)
];

LEATHER_DRAGON_GREEN :
Result := [
Point(25, 124),
Point(13, 118),
Point(36, 123),
Point(31, 139),
Point(15, 139)
];

LEATHER_DRAGON_RED :
Result := [
Point(23, 162),
Point(22, 150),
Point(36, 159),
Point(32, 174),
Point(12, 173)
];

LEATHER_DRAGON_BLUE :
Result := [
Point(24, 93),
Point(15, 80),
Point(35, 84),
Point(36, 94),
Point(24, 106)
];

//MSI_GetItemColor
HIDE_DRAGON_GREEN : Result := 604168;
HIDE_DRAGON_BLUE : Result := 4655882;
HIDE_DRAGON_RED : Result := 527419;
HIDE_DRAGON_BLACK : Result := 1842205;
HIDE_COW : Result := 9868957;
LEATHER_HARD : Result := 1844778;
LEATHER_SOFT : Result := 538171;
LEATHER_DRAGON_BLACK : Result := 1842205;
LEATHER_DRAGON_GREEN : Result := 604168;
LEATHER_DRAGON_RED : Result := 527419;
LEATHER_DRAGON_BLUE : Result := 4655882;

//MSI_LoadItem
HIDE_DRAGON_GREEN:
with MSI_Items[whichItem] do
begin
Name := 'Green dragonhide';
UpText := ['reen dragonhide'];
Stackable := False;
EquipLevel := -1;
end;

HIDE_DRAGON_BLUE:
with MSI_Items[whichItem] do
begin
Name := 'Blue dragonhide';
UpText := ['lue dragonhide'];
Stackable := False;
EquipLevel := -1;
end;

HIDE_DRAGON_RED:
with MSI_Items[whichItem] do
begin
Name := 'Red dragonhide';
UpText := ['ed dragonhide'];
Stackable := False;
EquipLevel := -1;
end;

HIDE_DRAGON_BLACk:
with MSI_Items[whichItem] do
begin
Name := 'Black dragonhide';
UpText := ['lack dragonhide'];
Stackable := False;
EquipLevel := -1;
end;

HIDE_COW:
with MSI_Items[whichItem] do
begin
Name := 'Cowhide';
UpText := ['owhide'];
Stackable := False;
EquipLevel := -1;
end;

LEATHER_HARD:
with MSI_Items[whichItem] do
begin
Name := 'Hard leather';
UpText := ['ard leather'];
Stackable := False;
EquipLevel := -1;
end;

LEATHER_SOFT:
with MSI_Items[whichItem] do
begin
Name := 'Soft leather';
UpText := ['oft leather'];
Stackable := False;
EquipLevel := -1;
end;

LEATHER_DRAGON_RED:
with MSI_Items[whichItem] do
begin
Name := 'Red dragon leather';
UpText := ['ed dragon leather'];
Stackable := False;
EquipLevel := -1;
end;

LEATHER_DRAGON_GREEN:
with MSI_Items[whichItem] do
begin
Name := 'Green dragon leather';
UpText := ['reen dragon leather'];
Stackable := False;
EquipLevel := -1;
end;

LEATHER_DRAGON_BLUE:
with MSI_Items[whichItem] do
begin
Name := 'Blue dragon leather';
UpText := ['lue dragon leather'];
Stackable := False;
EquipLevel := -1;
end;

LEATHER_DRAGON_BLACK:
with MSI_Items[whichItem] do
begin
Name := 'Black dragon leather';
UpText := ['lack dragon leather'];
Stackable := False;
EquipLevel := -1;
end;

//Objects
TANNER_ELLIS:
with Result do
begin
Name := 'Al Kharid Tanner Ellis'; // Name
UpTexts := ['llis']; // Uptext
Options := ['rade']; // Choose option text (se = Use)
Colors := [4088462]; // The 'Best color' from ACA
Tol := 17; // Tol from ACA
Hue := 0.10; // Hue from ACA
Sat := 0.63; // Sat from ACA
FindAllColors := False; // MSI_FindObject will only return true if all colors in 'Colors' are found
W := 5; // Width of the object in pixels
H := 10; // Height of the object in pixels
Accuracy := 10; // The minimum amount of colors to be found (gets rid of false objects)
SearchArea := MSBox; // The box to search for the object (MSBox = main screen box)
ExcludeSelf := True; // Exclude the character
RightClickOnly := True; // Only right click
WaitToMove := True; // Wait for the player to stop moving after the object is clicked
Track := True; // True if the object disappears after the player is done with it
AssociatedItems := [LEATHER_HARD, LEATHER_SOFT, LEATHER_DRAGON_BLACK, LEATHER_DRAGON_GREEN, LEATHER_DRAGON_RED, LEATHER_DRAGON_BLUE]; // Are any items gained from the object (i.e. logs from trees)?
end;

//Globals
//Items
HIDE_DRAGON_GREEN = 217;
HIDE_DRAGON_BLUE = 218;
HIDE_DRAGON_RED = 219;
HIDE_DRAGON_BLACK = 220;
HIDE_COW = 221;
LEATHER_HARD = 222;
LEATHER_SOFT = 223;
LEATHER_DRAGON_BLACK = 224;
LEATHER_DRAGON_GREEN = 225;
LEATHER_DRAGON_RED = 226;
LEATHER_DRAGON_BLUE = 227;

//Objects
TANNER_ELLIS = 94;

//Locations
LOC_AK_TANNER = 123;

//Materials
MATERIAL_HIDE_COW_SOFT = 25;
MATERIAL_HIDE_COW_HARD = 26;
MATERIAL_HIDE_DRAGON_GREEN = 27;
MATERIAL_HIDE_DRAGON_BLUE = 28;
MATERIAL_HIDE_DRAGON_RED = 29;
MATERIAL_HIDE_DRAGON_BLACK = 30;

//Scripts
SCRIPT_AK_TANNER_SOFT = 107;
SCRIPT_AK_TANNER_HARD = 108;
SCRIPT_AK_TANNER_BLUE = 109;
SCRIPT_AK_TANNER_RED = 110;
SCRIPT_AK_TANNER_GREEN = 111;
SCRIPT_AK_TANNER_BLACK = 112;



//Locations
LOC_AK_TANNER:
with MSI_Locations[loc] do
begin
name := 'Al Kharid Tanner';
atBank := false;

setLength(subLocs, 1);
with subLocs[0] do
begin
name := 'Al Kharid Tanner';
spsBox := intToBox(4930, 3890, 4945, 3895);
objects := [TANNER_ELLIS];
end;
end;
//Materials
MATERIAL_HIDE_COW_SOFT :
with Result do
begin
Name := 'Cowhide';
Supplies := [TIntegerArray([HIDE_COW, -1])];
Produces := [LEATHER_SOFT];
MemberOnly := False;
Level := 1;
end;

MATERIAL_HIDE_COW_HARD :
with Result do
begin
Name := 'Cowhide';
Supplies := [TIntegerArray([HIDE_COW, -1])];
Produces := [LEATHER_HARD];
MemberOnly := False;
Level := 1;
end;

MATERIAL_HIDE_DRAGON_GREEN :
with Result do
begin
Name := 'Green Dragonhide';
Supplies := [TIntegerArray([HIDE_DRAGON_GREEN, -1])];
Produces := [LEATHER_DRAGON_GREEN];
MemberOnly := True;
Level := 1;
end;

MATERIAL_HIDE_DRAGON_BLUE :
with Result do
begin
Name := 'Blue Dragonhide';
Supplies := [TIntegerArray([HIDE_DRAGON_BLUE, -1])];
Produces := [LEATHER_DRAGON_BLUE];
MemberOnly := True;
Level := 1;
end;

MATERIAL_HIDE_DRAGON_RED :
with Result do
begin
Name := 'Red Dragonhide';
Supplies := [TIntegerArray([HIDE_DRAGON_RED, -1])];
Produces := [LEATHER_DRAGON_RED];
MemberOnly := True;
Level := 1;
end;

MATERIAL_HIDE_DRAGON_BLACK :
with Result do
begin
Name := 'Black Dragonhide';
Supplies := [TIntegerArray([HIDE_DRAGON_BLACK, -1])];
Produces := [LEATHER_DRAGON_RED];
MemberOnly := True;
Level := 1;
end;

//Scripts
SCRIPT_AK_TANNER_SOFT:
with MSI_Scripts[whichScript] do
begin
Name := 'Alkarid Soft Leather Tanner';
Constant := SCRIPT_AK_TANNER_SOFT;
SkillName := 'N/A';
SkillConst := SKILL_NONE;
BankType := Bank;
WhichBank := MSI_BANK_AK;
GetMaterials := True;
AutoObjects := @MSI_TanSoftLeather;
BankObjects := @MSI_BankWithdraw;
PlayerSetup := @MSI_SetupTanner;

with Defaults do
begin
Objects := [TANNER_ELLIS];
Materials := [MATERIAL_HIDE_COW_SOFT];
end;

with PathInfo do
begin
Name := 'LOC_AK_BANK to LOC_AK_TANNER';
StartLoc := LOC_AK_BANK;
EndLoc := LOC_AK_TANNER;
SPSPath := [TPointArray([Point(4915, 3990), Point(4945, 3890)])];
SPSAreas := [TStringArray(['12_9','11_9','12_10'])];
end;
end;

SCRIPT_AK_TANNER_HARD:
with MSI_Scripts[whichScript] do
begin
Name := 'Alkarid Hard Leather Tanner';
Constant := SCRIPT_AK_TANNER_HARD;
SkillName := 'N/A';
SkillConst := SKILL_NONE;
BankType := Bank;
WhichBank := MSI_BANK_AK;
GetMaterials := True;
AutoObjects := @MSI_TanHardLeather;
BankObjects := @MSI_BankWithdraw;
PlayerSetup := @MSI_SetupTanner;

with Defaults do
begin
Objects := [TANNER_ELLIS];
Materials := [MATERIAL_HIDE_COW_HARD];
end;

with PathInfo do
begin
Name := 'LOC_AK_BANK to LOC_AK_TANNER';
StartLoc := LOC_AK_BANK;
EndLoc := LOC_AK_TANNER;
SPSPath := [TPointArray([Point(4915, 3990), Point(4945, 3890)])];
SPSAreas := [TStringArray(['12_9','11_9','12_10'])];
end;
end;

SCRIPT_AK_TANNER_BLUE:
with MSI_Scripts[whichScript] do
begin
Name := 'Alkarid Blue Dragonhide Leather Tanner';
Constant := SCRIPT_AK_TANNER_BLUE;
SkillName := 'N/A';
SkillConst := SKILL_NONE;
BankType := Bank;
WhichBank := MSI_BANK_AK;
GetMaterials := True;
AutoObjects := @MSI_TanBlueLeather;
BankObjects := @MSI_BankWithdraw;
PlayerSetup := @MSI_SetupTanner;

with Defaults do
begin
Objects := [TANNER_ELLIS];
Materials := [MATERIAL_HIDE_DRAGON_BLUE];
end;

with PathInfo do
begin
Name := 'LOC_AK_BANK to LOC_AK_TANNER';
StartLoc := LOC_AK_BANK;
EndLoc := LOC_AK_TANNER;
SPSPath := [TPointArray([Point(4915, 3990), Point(4945, 3890)])];
SPSAreas := [TStringArray(['12_9','11_9','12_10'])];
end;
end;

SCRIPT_AK_TANNER_GREEN:
with MSI_Scripts[whichScript] do
begin
Name := 'Alkarid Green Dragonhide Leather Tanner';
Constant := SCRIPT_AK_TANNER_GREEN;
SkillName := 'N/A';
SkillConst := SKILL_NONE;
BankType := Bank;
WhichBank := MSI_BANK_AK;
GetMaterials := True;
AutoObjects := @MSI_TanGreenLeather;
BankObjects := @MSI_BankWithdraw;
PlayerSetup := @MSI_SetupTanner;

with Defaults do
begin
Objects := [TANNER_ELLIS];
Materials := [MATERIAL_HIDE_DRAGON_GREEN];
end;

with PathInfo do
begin
Name := 'LOC_AK_BANK to LOC_AK_TANNER';
StartLoc := LOC_AK_BANK;
EndLoc := LOC_AK_TANNER;
SPSPath := [TPointArray([Point(4915, 3990), Point(4945, 3890)])];
SPSAreas := [TStringArray(['12_9','11_9','12_10'])];
end;
end;

SCRIPT_AK_TANNER_RED:
with MSI_Scripts[whichScript] do
begin
Name := 'Alkarid Red Dragonhide Leather Tanner';
Constant := SCRIPT_AK_TANNER_RED;
SkillName := 'N/A';
SkillConst := SKILL_NONE;
BankType := Bank;
WhichBank := MSI_BANK_AK;
GetMaterials := True;
AutoObjects := @MSI_TanRedLeather;
BankObjects := @MSI_BankWithdraw;
PlayerSetup := @MSI_SetupTanner;

with Defaults do
begin
Objects := [TANNER_ELLIS];
Materials := [MATERIAL_HIDE_DRAGON_RED];
end;

with PathInfo do
begin
Name := 'LOC_AK_BANK to LOC_AK_TANNER';
StartLoc := LOC_AK_BANK;
EndLoc := LOC_AK_TANNER;
SPSPath := [TPointArray([Point(4915, 3990), Point(4945, 3890)])];
SPSAreas := [TStringArray(['12_9','11_9','12_10'])];
end;
end;

SCRIPT_AK_TANNER_BLACK:
with MSI_Scripts[whichScript] do
begin
Name := 'Alkarid Black Dragonhide Leather Tanner';
Constant := SCRIPT_AK_TANNER_BLACK;
SkillName := 'N/A';
SkillConst := SKILL_NONE;
BankType := Bank;
WhichBank := MSI_BANK_AK;
GetMaterials := True;
AutoObjects := @MSI_TanBlackLeather;
BankObjects := @MSI_BankWithdraw;
PlayerSetup := @MSI_SetupTanner;

with Defaults do
begin
Objects := [TANNER_ELLIS];
Materials := [MATERIAL_HIDE_DRAGON_BLACK];
end;

with PathInfo do
begin
Name := 'LOC_AK_BANK to LOC_AK_TANNER';
StartLoc := LOC_AK_BANK;
EndLoc := LOC_AK_TANNER;
SPSPath := [TPointArray([Point(4915, 3990), Point(4945, 3890)])];
SPSAreas := [TStringArray(['12_9','11_9','12_10'])];
end;
end;


(*
MSI_SetupTanner
~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function MSI_SetupTanner(): Boolean;

Sets the player up to use a Tanner script. This procedure is pointed
to the script's SetupPlayer attribute.

.. note::

| Author: Coh3n
| Last Updated: 27 April 2011 by Coh3n
*)
function MSI_SetupTanner(): Boolean;
begin
//I will write my own but for now this will do.
result := MSI_SetupCooking();
end;

(*
MSI_HideScreen
~~~~~~~~~~~~~

.. code-block:: pascal

function MSI_HideScreen : Boolean;

Returns true if the hide screen is open.

.. note::

| Author: putonajonny
| Last Updated: 08 February 2012 by putonajonny

*)

function MSI_HideScreen : Boolean;
begin
Result := ((GetColor(264, 38) = 2070783) and (GetColor(394, 32) = 2070783) and (GetColor(313, 44) = 0) and (GetColor(423, 37) = 3424329));
end;

(*
MSI_TanHides
~~~~~~~~~~~~~

.. code-block:: pascal

function MSI_TanHides(material: Integer): Boolean;

Returns true if successfully selected the 'material' option from the selection
screen.

.. note::

| Author: putonajonny
| Last Updated: 08 February 2012 by putonajonny

*)
function MSI_TanHides(material: Integer): boolean;
Var
Time : integer;
begin

MarkTime(Time);
Repeat
Wait(200+Random(500));
if(TimeFromMark(Time) > 5000) then
begin
Result := False;
exit;
end;
if(MSI_HideScreen) then
break;
MSI_SubDebug('Hide screen not open');
Until(false);

Case Material of
MATERIAL_HIDE_COW_SOFT : MouseBox(189, 85, 226, 116, 0);
MATERIAL_HIDE_COW_HARD : MouseBox(71, 85, 112, 116, 0);
MATERIAL_HIDE_DRAGON_GREEN : MouseBox(71, 213, 112, 245, 0);
MATERIAL_HIDE_DRAGON_BLUE : MouseBox(189, 213, 226, 245, 0);
MATERIAL_HIDE_DRAGON_RED : MouseBox(298, 213, 336, 245, 0);
MATERIAL_HIDE_DRAGON_BLACK : MouseBox(408, 213, 449, 245, 0);
end;

WaitOption('an All', 500+Random(200));

MarkTime(Time);
Repeat
Wait(200+Random(500));
if(TimeFromMark(Time) > 5000) then
begin
Result := False;
exit;
end;
if(not MSI_HideScreen) then
break;
MSI_SubDebug('Hide screen still open');
Until(false);


end;

(*
MSI_TanHardLeather, MSI_TanSoftLeather, MSI_TanBlueLeather, MSI_TanGreenLeather, MSI_TanRedLeather, MSI_TanBlackLeather
~~~~~~~~~~~~~~

.. code-block:: pascal

function MSI_TanHardLeather(): Boolean;
function MSI_TanSoftLeather(): Boolean;
function MSI_TanBlueLeather(): Boolean;
function MSI_TanGreenLeather(): Boolean;
function MSI_TanRedLeather(): Boolean;
function MSI_TanBlackLeather(): Boolean;

A set of functions that tan different types of leather.

.. note::

| Author: putonajonny
| Last Updated: 08th February 2012 by putonajonny

*)

Function MSI_TanHardLeather : Boolean;
begin
Result := MSI_TanHides(MATERIAL_HIDE_COW_HARD);
end;

Function MSI_TanSoftLeather : Boolean;
begin
Result := MSI_TanHides(MATERIAL_HIDE_COW_SOFT);
end;

Function MSI_TanRedLeather : Boolean;
begin
Result := MSI_TanHides(MATERIAL_HIDE_DRAGON_RED);
end;
Function MSI_TanGreenLeather : Boolean;
begin
Result := MSI_TanHides(MATERIAL_HIDE_DRAGON_GREEN);
end;
Function MSI_TanBlueLeather : Boolean;
begin
Result := MSI_TanHides(MATERIAL_HIDE_DRAGON_BLUE);
end;
Function MSI_TanBlackLeather : Boolean;
begin
Result := MSI_TanHides(MATERIAL_HIDE_DRAGON_BLACK);
end;

Coh3n

2012-02-08 19:34:43

It does it automatically. ;) All you have to do is add the path to the TScript record, which I see that you've done. Few things before you send a pull request, though. You only need one TScript record, not a different one for each type of hide:

SCRIPT_AK_TANNER:
with MSI_Scripts[whichScript] do
begin
Name := 'Alkarid Leather Tanner';
Constant := SCRIPT_AK_TANNER_BLACK;
SkillName := 'N/A';
SkillConst := SKILL_NONE;
BankType := Bank;
WhichBank := MSI_BANK_AK;
GetMaterials := True;
AutoObjects := @MSI_TanLeather;
BankObjects := @MSI_BankWithdraw;
PlayerSetup := @MSI_SetupTanner;

with Defaults do
begin
Objects := [TANNER_ELLIS];
Materials := [MATERIAL_HIDE_COW_SOFT, MATERIAL_HIDE_COW_HARD,
MATERIAL_HIDE_DRAGON_BLUE, MATERIAL_HIDE_DRAGON_GREEN,
MATERIAL_HIDE_DRAGON_RED, MATERIAL_HIDE_DRAGON_BLACK];
end;

with PathInfo do
begin
Name := 'LOC_AK_BANK to LOC_AK_TANNER';
StartLoc := LOC_AK_BANK;
EndLoc := LOC_AK_TANNER;
SPSPath := [TPointArray([Point(4915, 3990), Point(4945, 3890)])];
SPSAreas := [TStringArray(['12_9','11_9','12_10'])];
end;
end;
You also only need one tanning function:

function MSI_TanLeather(): Boolean;
begin
if (not loggedIn) then
exit;

Result := MSI_TanHides(Players[CurrentPlayer].Scripts[CurrentScript].Leather);
end;
Aren't all the hides the same shape? If so, the same DTM points can be used:

LEATHER_DRAGON_GREEN, LEATHER_DRAGON_BLUE, LEATHER_DRAGON_RED, LEATHER_DRAGON_BLACK:
Result := [
Point(24, 93),
Point(15, 80),
Point(35, 84),
Point(36, 94),
Point(24, 106)
];

HIDE_DRAGON_GREEN, HIDE_DRAGON_BLUE, HIDE_DRAGON_RED, HIDE_DRAGON_BLACK:
Result := [
Point(110, 23),
Point(123, 21),
Point(112, 36),
Point(97, 24),
Point(109, 10)
];

LEATHER_SOFT, LEATHER_HARD:
Result := [
Point(23, 53),
Point(21, 44),
Point(12, 49),
Point(26, 70),
Point(36, 55)
];
There needs to be a different color for each item, though, which you've done perfectly. Lastly, I think you missed the section about adding the correct property to the TScriptSetup record. In this cause, you'd have to add "Leather" (as I used in my revised version of MSI_TanLeather).

From what I can see, there isn't anything else you've forgotten (except adding it to the form, but I'll do that). Really, really nice work. :)

putonajonny

2012-02-09 13:18:54

I have done some revisions, thanks for your help, infact all hides and leather have the same shape so I have used one point set for all of them:

//MSI_GetDTMPoints
HIDE_DRAGON_GREEN, HIDE_DRAGON_BLUE, HIDE_DRAGON_RED, HIDE_DRAGON_BLACK,
HIDE_COW, LEATHER_HARD LEATHER_SOFT, LEATHER_DRAGON_BLACK,
LEATHER_DRAGON_GREEN, LEATHER_DRAGON_RED, LEATHER_DRAGON_BLUE :
Result := [Point(18, 18),
Point(15, 4),
Point(21, 32),
Point(7, 13),
Point(31, 23)];

//MSI_GetItemColor
HIDE_DRAGON_GREEN : Result := 604680;
HIDE_DRAGON_BLUE : Result := 4655881;
HIDE_DRAGON_RED : Result := 461623;
HIDE_DRAGON_BLACK : Result := 1776413;
HIDE_COW : Result := 10263715;
LEATHER_HARD : Result := 1779241;
LEATHER_SOFT : Result := 538170;
LEATHER_DRAGON_BLACK : Result := 1776413;
LEATHER_DRAGON_GREEN : Result := 604680;
LEATHER_DRAGON_RED : Result := 527162;
LEATHER_DRAGON_BLUE : Result := 4786954;

//MSI_LoadItem
HIDE_DRAGON_GREEN:
with MSI_Items[whichItem] do
begin
Name := 'Green dragonhide';
UpText := ['reen dragonhide'];
Stackable := False;
EquipLevel := -1;
end;

HIDE_DRAGON_BLUE:
with MSI_Items[whichItem] do
begin
Name := 'Blue dragonhide';
UpText := ['lue dragonhide'];
Stackable := False;
EquipLevel := -1;
end;

HIDE_DRAGON_RED:
with MSI_Items[whichItem] do
begin
Name := 'Red dragonhide';
UpText := ['ed dragonhide'];
Stackable := False;
EquipLevel := -1;
end;

HIDE_DRAGON_BLACk:
with MSI_Items[whichItem] do
begin
Name := 'Black dragonhide';
UpText := ['lack dragonhide'];
Stackable := False;
EquipLevel := -1;
end;

HIDE_COW:
with MSI_Items[whichItem] do
begin
Name := 'Cowhide';
UpText := ['owhide'];
Stackable := False;
EquipLevel := -1;
end;

LEATHER_HARD:
with MSI_Items[whichItem] do
begin
Name := 'Hard leather';
UpText := ['ard leather'];
Stackable := False;
EquipLevel := -1;
end;

LEATHER_SOFT:
with MSI_Items[whichItem] do
begin
Name := 'Soft leather';
UpText := ['oft leather'];
Stackable := False;
EquipLevel := -1;
end;

LEATHER_DRAGON_RED:
with MSI_Items[whichItem] do
begin
Name := 'Red dragon leather';
UpText := ['ed dragon leather'];
Stackable := False;
EquipLevel := -1;
end;

LEATHER_DRAGON_GREEN:
with MSI_Items[whichItem] do
begin
Name := 'Green dragon leather';
UpText := ['reen dragon leather'];
Stackable := False;
EquipLevel := -1;
end;

LEATHER_DRAGON_BLUE:
with MSI_Items[whichItem] do
begin
Name := 'Blue dragon leather';
UpText := ['lue dragon leather'];
Stackable := False;
EquipLevel := -1;
end;

LEATHER_DRAGON_BLACK:
with MSI_Items[whichItem] do
begin
Name := 'Black dragon leather';
UpText := ['lack dragon leather'];
Stackable := False;
EquipLevel := -1;
end;

//Objects
TANNER_ELLIS:
with Result do
begin
Name := 'Al Kharid Tanner Ellis'; // Name
UpTexts := ['llis']; // Uptext
Options := ['rade']; // Choose option text (se = Use)
Colors := [4088462]; // The 'Best color' from ACA
Tol := 17; // Tol from ACA
Hue := 0.10; // Hue from ACA
Sat := 0.63; // Sat from ACA
FindAllColors := False; // MSI_FindObject will only return true if all colors in 'Colors' are found
W := 5; // Width of the object in pixels
H := 10; // Height of the object in pixels
Accuracy := 10; // The minimum amount of colors to be found (gets rid of false objects)
SearchArea := MSBox; // The box to search for the object (MSBox = main screen box)
ExcludeSelf := True; // Exclude the character
RightClickOnly := True; // Only right click
WaitToMove := True; // Wait for the player to stop moving after the object is clicked
Track := True; // True if the object disappears after the player is done with it
AssociatedItems := [LEATHER_HARD, LEATHER_SOFT, LEATHER_DRAGON_BLACK, LEATHER_DRAGON_GREEN, LEATHER_DRAGON_RED, LEATHER_DRAGON_BLUE]; // Are any items gained from the object (i.e. logs from trees)?
end;

//Globals
//Items
HIDE_DRAGON_GREEN = 217;
HIDE_DRAGON_BLUE = 218;
HIDE_DRAGON_RED = 219;
HIDE_DRAGON_BLACK = 220;
HIDE_COW = 221;
LEATHER_HARD = 222;
LEATHER_SOFT = 223;
LEATHER_DRAGON_BLACK = 224;
LEATHER_DRAGON_GREEN = 225;
LEATHER_DRAGON_RED = 226;
LEATHER_DRAGON_BLUE = 227;

//Objects
TANNER_ELLIS = 94;

//Locations
LOC_AK_TANNER = 123;

//Materials
MATERIAL_HIDE_COW_SOFT = 25;
MATERIAL_HIDE_COW_HARD = 26;
MATERIAL_HIDE_DRAGON_GREEN = 27;
MATERIAL_HIDE_DRAGON_BLUE = 28;
MATERIAL_HIDE_DRAGON_RED = 29;
MATERIAL_HIDE_DRAGON_BLACK = 30;

//Scripts
SCRIPT_AK_TANNER_SOFT = 107;
SCRIPT_AK_TANNER_HARD = 108;
SCRIPT_AK_TANNER_BLUE = 109;
SCRIPT_AK_TANNER_RED = 110;
SCRIPT_AK_TANNER_GREEN = 111;
SCRIPT_AK_TANNER_BLACK = 112;

//TScriptSetup
Leather : TIntegerArray;



//Locations
LOC_AK_TANNER:
with MSI_Locations[loc] do
begin
name := 'Al Kharid Tanner';
atBank := false;

setLength(subLocs, 1);
with subLocs[0] do
begin
name := 'Al Kharid Tanner';
spsBox := intToBox(4930, 3890, 4945, 3895);
objects := [TANNER_ELLIS];
end;
end;
//Materials
MATERIAL_HIDE_COW_SOFT :
with Result do
begin
Name := 'Cowhide';
Supplies := [TIntegerArray([HIDE_COW, -1])];
Produces := [LEATHER_SOFT];
MemberOnly := False;
Level := 1;
end;

MATERIAL_HIDE_COW_HARD :
with Result do
begin
Name := 'Cowhide';
Supplies := [TIntegerArray([HIDE_COW, -1])];
Produces := [LEATHER_HARD];
MemberOnly := False;
Level := 1;
end;

MATERIAL_HIDE_DRAGON_GREEN :
with Result do
begin
Name := 'Green Dragonhide';
Supplies := [TIntegerArray([HIDE_DRAGON_GREEN, -1])];
Produces := [LEATHER_DRAGON_GREEN];
MemberOnly := True;
Level := 1;
end;

MATERIAL_HIDE_DRAGON_BLUE :
with Result do
begin
Name := 'Blue Dragonhide';
Supplies := [TIntegerArray([HIDE_DRAGON_BLUE, -1])];
Produces := [LEATHER_DRAGON_BLUE];
MemberOnly := True;
Level := 1;
end;

MATERIAL_HIDE_DRAGON_RED :
with Result do
begin
Name := 'Red Dragonhide';
Supplies := [TIntegerArray([HIDE_DRAGON_RED, -1])];
Produces := [LEATHER_DRAGON_RED];
MemberOnly := True;
Level := 1;
end;

MATERIAL_HIDE_DRAGON_BLACK :
with Result do
begin
Name := 'Black Dragonhide';
Supplies := [TIntegerArray([HIDE_DRAGON_BLACK, -1])];
Produces := [LEATHER_DRAGON_RED];
MemberOnly := True;
Level := 1;
end;

//Scripts
SCRIPT_AK_TANNER:
with MSI_Scripts[whichScript] do
begin
Name := 'Alkarid Soft Leather Tanner';
Constant := SCRIPT_AK_TANNER;
SkillName := 'N/A';
SkillConst := SKILL_NONE;
BankType := Bank;
WhichBank := MSI_BANK_AK;
GetMaterials := True;
AutoObjects := @MSI_TanLeather;
BankObjects := @MSI_BankWithdraw;
PlayerSetup := @MSI_SetupTanner;

with Defaults do
begin
Objects := [TANNER_ELLIS];
Materials := [MATERIAL_HIDE_COW_SOFT, MATERIAL_HIDE_COW_HARD,
MATERIAL_HIDE_DRAGON_BLUE, MATERIAL_HIDE_DRAGON_GREEN,
MATERIAL_HIDE_DRAGON_RED, MATERIAL_HIDE_DRAGON_BLACK];
Leather := [MATERIAL_HIDE_COW_SOFT, MATERIAL_HIDE_COW_HARD,
MATERIAL_HIDE_DRAGON_BLUE, MATERIAL_HIDE_DRAGON_GREEN,
MATERIAL_HIDE_DRAGON_RED, MATERIAL_HIDE_DRAGON_BLACK];

end;

with PathInfo do
begin
Name := 'LOC_AK_BANK to LOC_AK_TANNER';
StartLoc := LOC_AK_BANK;
EndLoc := LOC_AK_TANNER;
SPSPath := [TPointArray([Point(4915, 3990), Point(4945, 3890)])];
SPSAreas := [TStringArray(['12_9','11_9','12_10'])];
end;
end;




(*
MSI_SetupTanner
~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function MSI_SetupTanner(): Boolean;

Sets the player up to use a Tanner script. This procedure is pointed
to the script's SetupPlayer attribute.

.. note::

| Author: Coh3n
| Last Updated: 27 April 2011 by Coh3n
*)
function MSI_SetupTanner(): Boolean;
begin
//I will write my own but for now this will do.
result := MSI_SetupCooking();
end;

(*
MSI_HideScreen
~~~~~~~~~~~~~

.. code-block:: pascal

function MSI_HideScreen : Boolean;

Returns true if the hide screen is open.

.. note::

| Author: putonajonny
| Last Updated: 08 February 2012 by putonajonny

*)

function MSI_HideScreen : Boolean;
begin
Result := ((GetColor(264, 38) = 2070783) and (GetColor(394, 32) = 2070783) and (GetColor(313, 44) = 0) and (GetColor(423, 37) = 3424329));
end;

(*
MSI_TanHides
~~~~~~~~~~~~~

.. code-block:: pascal

function MSI_TanHides(material: Integer): Boolean;

Returns true if successfully selected the 'material' option from the selection
screen.

.. note::

| Author: putonajonny
| Last Updated: 08 February 2012 by putonajonny

*)
function MSI_TanHides(material: Integer): boolean;
Var
Time : integer;
begin

MarkTime(Time);
Repeat
Wait(200+Random(500));
if(TimeFromMark(Time) > 5000) then
begin
Result := False;
exit;
end;
if(MSI_HideScreen) then
break;
MSI_SubDebug('Hide screen not open');
Until(false);

Case Material of
MATERIAL_HIDE_COW_SOFT : MouseBox(189, 85, 226, 116, 0);
MATERIAL_HIDE_COW_HARD : MouseBox(71, 85, 112, 116, 0);
MATERIAL_HIDE_DRAGON_GREEN : MouseBox(71, 213, 112, 245, 0);
MATERIAL_HIDE_DRAGON_BLUE : MouseBox(189, 213, 226, 245, 0);
MATERIAL_HIDE_DRAGON_RED : MouseBox(298, 213, 336, 245, 0);
MATERIAL_HIDE_DRAGON_BLACK : MouseBox(408, 213, 449, 245, 0);
end;

WaitOption('an All', 500+Random(200));

MarkTime(Time);
Repeat
Wait(200+Random(500));
if(TimeFromMark(Time) > 5000) then
begin
Result := False;
exit;
end;
if(not MSI_HideScreen) then
break;
MSI_SubDebug('Hide screen still open');
Until(false);


end;

(*
MSI_TanLeather
~~~~~~~~~~~~~~

.. code-block:: pascal

function MSI_TanLeather(): Boolean;

A function that tans different types of leather.

.. note::

| Author: putonajonny
| Last Updated: 08th February 2012 by putonajonny

*)

function MSI_TanLeather(): Boolean;
begin
if (not loggedIn) then
exit;

Result := MSI_TanHides(MSI_Players[CurrentPlayer].Scripts[CurrentScript].Leather[0]);
end;

Coh3n

2012-02-09 19:22:53

Looking good. :) Few more things (I hope you don't mind :p).

Result := MSI_TanHides(MSI_Players[CurrentPlayer].Scripts[CurrentScript].Leather[0]);
Referencing a specific element in the array (.Leather[0]) has the potential to throw an out of range error (if the length is 0), so you should add a length check:

with MSI_Players[CurrentPlayer] do
if (length(Scripts[CurrentScript].Leather) > 0) then
Result := MSI_TanHides(Scripts[CurrentScript].Leather[0]);
BUT, since .Leather is a TIntegerArray, we'd want the users to have the option to tan multiple hides (i.e. green and red dragonhide), right? So what you could do is add a loop, and look for the hides. If one is found, tan it.

function MSI_TanLeather(): Boolean;
var
i: integer;
mat: TMaterial;
begin
if (not loggedIn) then
exit;

with MSI_Players[CurrentPlayer] do
begin
// make sure the user actually set leather to tan
if (length(Scripts[CurrentScript].Leather) <= 0) then
begin
MSI_Debug('Invalid Leather selection for player '+toStr(CurrentPlayer));
exit;
end;

// loop through the player materials, tanning whichever is found
for i := 0 to high(Scripts[CurrentScript].Leather) do
begin
mat := MSI_GetMaterial(Scripts[CurrentScript].Leather[i]);

// if the leather is found in the inventory (can call Supplies[0] because it's a script defined array, not user, so it will ALWAYS have length of 2)
if (length(MSI_FindItemSlots(Scripts[CurrentScript].Leather[i].Supplies[0])) > 0) then
Result := MSI_TanHides(Scripts[CurrentScript].Leather[i]);
end;
end;
end;
It may look like a lot, but I'm sure you'll get it. Feel free to ask if you don't understand something. You may wonder about banking. Well, MSI_BankWithdraw automatically handles multiple materials, so no matter what the user sets .Leather to, MSI_BankWithdraw will handle it, so you don't need to worry about that. :)

Lastly, I noticed you haven't added "StatsName" to the item records. Is that because there aren't stats variables for these? Just so you know, you don't have to worry about adding any code for stats (except StatsName in the record). It's all taken care of. :)

Again, nice work, keep going!

putonajonny

2012-02-10 11:05:25

Thanks for your help again :P hopefully I can learn from this and then won't need as much help next time, here are the edits, I will get testing and let you know how it goes, I understand all the scripting part, but not how the supplies bit comes into it:

//MSI_GetDTMPoints
HIDE_DRAGON_GREEN, HIDE_DRAGON_BLUE, HIDE_DRAGON_RED, HIDE_DRAGON_BLACK,
HIDE_COW, LEATHER_HARD LEATHER_SOFT, LEATHER_DRAGON_BLACK,
LEATHER_DRAGON_GREEN, LEATHER_DRAGON_RED, LEATHER_DRAGON_BLUE :
Result := [Point(18, 18),
Point(15, 4),
Point(21, 32),
Point(7, 13),
Point(31, 23)];

//MSI_GetItemColor
HIDE_DRAGON_GREEN : Result := 604680;
HIDE_DRAGON_BLUE : Result := 4655881;
HIDE_DRAGON_RED : Result := 461623;
HIDE_DRAGON_BLACK : Result := 1776413;
HIDE_COW : Result := 10263715;
LEATHER_HARD : Result := 1779241;
LEATHER_SOFT : Result := 538170;
LEATHER_DRAGON_BLACK : Result := 1776413;
LEATHER_DRAGON_GREEN : Result := 604680;
LEATHER_DRAGON_RED : Result := 527162;
LEATHER_DRAGON_BLUE : Result := 4786954;

//MSI_LoadItem
HIDE_DRAGON_GREEN:
with MSI_Items[whichItem] do
begin
Name := 'Green dragonhide';
UpText := ['reen dragonhide'];
Stackable := False;
EquipLevel := -1;
end;

HIDE_DRAGON_BLUE:
with MSI_Items[whichItem] do
begin
Name := 'Blue dragonhide';
UpText := ['lue dragonhide'];
Stackable := False;
EquipLevel := -1;
end;

HIDE_DRAGON_RED:
with MSI_Items[whichItem] do
begin
Name := 'Red dragonhide';
UpText := ['ed dragonhide'];
Stackable := False;
EquipLevel := -1;
end;

HIDE_DRAGON_BLACk:
with MSI_Items[whichItem] do
begin
Name := 'Black dragonhide';
UpText := ['lack dragonhide'];
Stackable := False;
EquipLevel := -1;
end;

HIDE_COW:
with MSI_Items[whichItem] do
begin
Name := 'Cowhide';
UpText := ['owhide'];
Stackable := False;
EquipLevel := -1;
end;

LEATHER_HARD:
with MSI_Items[whichItem] do
begin
Name := 'Hard leather';
UpText := ['ard leather'];
Stackable := False;
EquipLevel := -1;
StatsName := 'Hard Leather Tanned';
end;

LEATHER_SOFT:
with MSI_Items[whichItem] do
begin
Name := 'Soft leather';
UpText := ['oft leather'];
Stackable := False;
EquipLevel := -1;
StatsName := 'Soft Leather Tanned';
end;

LEATHER_DRAGON_RED:
with MSI_Items[whichItem] do
begin
Name := 'Red dragon leather';
UpText := ['ed dragon leather'];
Stackable := False;
EquipLevel := -1;
StatsName := 'Red Dragon Leather Tanned';
end;

LEATHER_DRAGON_GREEN:
with MSI_Items[whichItem] do
begin
Name := 'Green dragon leather';
UpText := ['reen dragon leather'];
Stackable := False;
EquipLevel := -1;
StatsName := 'Green Dragon Leather Tanned';
end;

LEATHER_DRAGON_BLUE:
with MSI_Items[whichItem] do
begin
Name := 'Blue dragon leather';
UpText := ['lue dragon leather'];
Stackable := False;
EquipLevel := -1;
StatsName := 'Blue Dragon Leather Tanned';
end;

LEATHER_DRAGON_BLACK:
with MSI_Items[whichItem] do
begin
Name := 'Black dragon leather';
UpText := ['lack dragon leather'];
Stackable := False;
EquipLevel := -1;
StatsName := 'Black Dragon Leather Tanned';
end;

//Objects
TANNER_ELLIS:
with Result do
begin
Name := 'Al Kharid Tanner Ellis'; // Name
UpTexts := ['llis']; // Uptext
Options := ['rade']; // Choose option text (se = Use)
Colors := [4088462]; // The 'Best color' from ACA
Tol := 17; // Tol from ACA
Hue := 0.10; // Hue from ACA
Sat := 0.63; // Sat from ACA
FindAllColors := False; // MSI_FindObject will only return true if all colors in 'Colors' are found
W := 5; // Width of the object in pixels
H := 10; // Height of the object in pixels
Accuracy := 10; // The minimum amount of colors to be found (gets rid of false objects)
SearchArea := MSBox; // The box to search for the object (MSBox = main screen box)
ExcludeSelf := True; // Exclude the character
RightClickOnly := True; // Only right click
WaitToMove := True; // Wait for the player to stop moving after the object is clicked
Track := True; // True if the object disappears after the player is done with it
AssociatedItems := [LEATHER_HARD, LEATHER_SOFT, LEATHER_DRAGON_BLACK, LEATHER_DRAGON_GREEN, LEATHER_DRAGON_RED, LEATHER_DRAGON_BLUE]; // Are any items gained from the object (i.e. logs from trees)?
end;

//Globals
//Items
HIDE_DRAGON_GREEN = 217;
HIDE_DRAGON_BLUE = 218;
HIDE_DRAGON_RED = 219;
HIDE_DRAGON_BLACK = 220;
HIDE_COW = 221;
LEATHER_HARD = 222;
LEATHER_SOFT = 223;
LEATHER_DRAGON_BLACK = 224;
LEATHER_DRAGON_GREEN = 225;
LEATHER_DRAGON_RED = 226;
LEATHER_DRAGON_BLUE = 227;

//Objects
TANNER_ELLIS = 94;

//Locations
LOC_AK_TANNER = 123;

//Materials
MATERIAL_HIDE_COW_SOFT = 25;
MATERIAL_HIDE_COW_HARD = 26;
MATERIAL_HIDE_DRAGON_GREEN = 27;
MATERIAL_HIDE_DRAGON_BLUE = 28;
MATERIAL_HIDE_DRAGON_RED = 29;
MATERIAL_HIDE_DRAGON_BLACK = 30;

//Scripts
SCRIPT_AK_TANNER_SOFT = 107;
SCRIPT_AK_TANNER_HARD = 108;
SCRIPT_AK_TANNER_BLUE = 109;
SCRIPT_AK_TANNER_RED = 110;
SCRIPT_AK_TANNER_GREEN = 111;
SCRIPT_AK_TANNER_BLACK = 112;

//TScriptSetup
Leather : TIntegerArray;



//Locations
LOC_AK_TANNER:
with MSI_Locations[loc] do
begin
name := 'Al Kharid Tanner';
atBank := false;

setLength(subLocs, 1);
with subLocs[0] do
begin
name := 'Al Kharid Tanner';
spsBox := intToBox(4930, 3890, 4945, 3895);
objects := [TANNER_ELLIS];
end;
end;
//Materials
MATERIAL_HIDE_COW_SOFT :
with Result do
begin
Name := 'Cowhide to Soft Leather';
Supplies := [TIntegerArray([HIDE_COW, -1])];
Produces := [LEATHER_SOFT];
MemberOnly := False;
Level := 1;
end;

MATERIAL_HIDE_COW_HARD :
with Result do
begin
Name := 'Cowhide to Hard Leather';
Supplies := [TIntegerArray([HIDE_COW, -1])];
Produces := [LEATHER_HARD];
MemberOnly := False;
Level := 1;
end;

MATERIAL_HIDE_DRAGON_GREEN :
with Result do
begin
Name := 'Green Dragonhide';
Supplies := [TIntegerArray([HIDE_DRAGON_GREEN, -1])];
Produces := [LEATHER_DRAGON_GREEN];
MemberOnly := True;
Level := 1;
end;

MATERIAL_HIDE_DRAGON_BLUE :
with Result do
begin
Name := 'Blue Dragonhide';
Supplies := [TIntegerArray([HIDE_DRAGON_BLUE, -1])];
Produces := [LEATHER_DRAGON_BLUE];
MemberOnly := True;
Level := 1;
end;

MATERIAL_HIDE_DRAGON_RED :
with Result do
begin
Name := 'Red Dragonhide';
Supplies := [TIntegerArray([HIDE_DRAGON_RED, -1])];
Produces := [LEATHER_DRAGON_RED];
MemberOnly := True;
Level := 1;
end;

MATERIAL_HIDE_DRAGON_BLACK :
with Result do
begin
Name := 'Black Dragonhide';
Supplies := [TIntegerArray([HIDE_DRAGON_BLACK, -1])];
Produces := [LEATHER_DRAGON_RED];
MemberOnly := True;
Level := 1;
end;

//Scripts
SCRIPT_AK_TANNER:
with MSI_Scripts[whichScript] do
begin
Name := 'Alkarid Leather Tanner';
Constant := SCRIPT_AK_TANNER;
SkillName := 'N/A';
SkillConst := SKILL_NONE;
BankType := Bank;
WhichBank := MSI_BANK_AK;
GetMaterials := True;
AutoObjects := @MSI_TanLeather;
BankObjects := @MSI_BankWithdraw;
PlayerSetup := @MSI_SetupTanner;

with Defaults do
begin
Objects := [TANNER_ELLIS];
Materials := [MATERIAL_HIDE_COW_SOFT, MATERIAL_HIDE_COW_HARD,
MATERIAL_HIDE_DRAGON_BLUE, MATERIAL_HIDE_DRAGON_GREEN,
MATERIAL_HIDE_DRAGON_RED, MATERIAL_HIDE_DRAGON_BLACK];
Leather := [MATERIAL_HIDE_COW_SOFT, MATERIAL_HIDE_COW_HARD,
MATERIAL_HIDE_DRAGON_BLUE, MATERIAL_HIDE_DRAGON_GREEN,
MATERIAL_HIDE_DRAGON_RED, MATERIAL_HIDE_DRAGON_BLACK];

end;

with PathInfo do
begin
Name := 'LOC_AK_BANK to LOC_AK_TANNER';
StartLoc := LOC_AK_BANK;
EndLoc := LOC_AK_TANNER;
SPSPath := [TPointArray([Point(4915, 3990), Point(4945, 3890)])];
SPSAreas := [TStringArray(['12_9','11_9','12_10'])];
end;
end;




(*
MSI_SetupTanner
~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function MSI_SetupTanner(): Boolean;

Sets the player up to use a Tanner script. This procedure is pointed
to the script's SetupPlayer attribute.

.. note::

| Author: Coh3n
| Last Updated: 27 April 2011 by Coh3n
*)
function MSI_SetupTanner(): Boolean;
Var
DTM : Integer;
begin
Case MSI_Players[CurrentPlayer].Scripts[CurrentScript].Leather[0] of
MATERIAL_HIDE_COW_SOFT : DTM := MSI_LoadDTM(HIDE_COW);
MATERIAL_HIDE_COW_HARD : DTM := MSI_LoadDTM(HIDE_COW);
MATERIAL_HIDE_DRAGON_GREEN : DTM := MSI_LoadDTM(HIDE_DRAGON_GREEN);
MATERIAL_HIDE_DRAGON_BLUE : DTM := MSI_LoadDTM(HIDE_DRAGON_BLUE);
MATERIAL_HIDE_DRAGON_RED : DTM := MSI_LoadDTM(HIDE_DRAGON_RED);
MATERIAL_HIDE_DRAGON_BLACK : DTM := MSI_LoadDTM(HIDE_DRAGON_BLACK);
end;
if(countItems('dtm', DTM, []) > 0) then
begin
MSI_SubDebug('Materials found in inventory');
Result := True;
end;

FreeDTM(DTM);

if(Result) then
exit;

MSI_SubDebug('No materials in invent, assuming they are in your bank');

end;

(*
MSI_HideScreen
~~~~~~~~~~~~~

.. code-block:: pascal

function MSI_HideScreen : Boolean;

Returns true if the hide screen is open.

.. note::

| Author: putonajonny
| Last Updated: 08 February 2012 by putonajonny

*)

function MSI_HideScreen : Boolean;
begin
Result := ((GetColor(264, 38) = 2070783) and (GetColor(394, 32) = 2070783) and (GetColor(313, 44) = 0) and (GetColor(423, 37) = 3424329));
end;

(*
MSI_TanHides
~~~~~~~~~~~~~

.. code-block:: pascal

function MSI_TanHides(material: Integer): Boolean;

Returns true if successfully selected the 'material' option from the selection
screen.

.. note::

| Author: putonajonny
| Last Updated: 08 February 2012 by putonajonny

*)
function MSI_TanHides(material: Integer): boolean;
Var
Time : integer;
begin

MarkTime(Time);
Repeat
Wait(200+Random(500));
if(TimeFromMark(Time) > 5000) then
begin
Result := False;
exit;
end;
if(MSI_HideScreen) then
break;
MSI_SubDebug('Hide screen not open');
Until(false);

Case Material of
MATERIAL_HIDE_COW_SOFT : MouseBox(189, 85, 226, 116, 0);
MATERIAL_HIDE_COW_HARD : MouseBox(71, 85, 112, 116, 0);
MATERIAL_HIDE_DRAGON_GREEN : MouseBox(71, 213, 112, 245, 0);
MATERIAL_HIDE_DRAGON_BLUE : MouseBox(189, 213, 226, 245, 0);
MATERIAL_HIDE_DRAGON_RED : MouseBox(298, 213, 336, 245, 0);
MATERIAL_HIDE_DRAGON_BLACK : MouseBox(408, 213, 449, 245, 0);
end;

WaitOption('an All', 500+Random(200));

MarkTime(Time);
Repeat
Wait(200+Random(500));
if(TimeFromMark(Time) > 5000) then
begin
Result := False;
exit;
end;
if(not MSI_HideScreen) then
break;
MSI_SubDebug('Hide screen still open');
Until(false);


end;

(*
MSI_TanLeather
~~~~~~~~~~~~~~

.. code-block:: pascal

function MSI_TanLeather(): Boolean;

A function that tans different types of leather.

.. note::

| Author: putonajonny
| Last Updated: 10th February 2012 by Coh3n

*)

function MSI_TanLeather(): Boolean;
var
i: integer;
mat: TMaterial;
begin
if (not loggedIn) then
exit;

with MSI_Players[CurrentPlayer] do
begin
// make sure the user actually set leather to tan
if (length(Scripts[CurrentScript].Leather) <= 0) then
begin
MSI_Debug('Invalid Leather selection for player '+toStr(CurrentPlayer));
exit;
end;

// loop through the player materials, tanning whichever is found
for i := 0 to high(Scripts[CurrentScript].Leather) do
begin
mat := MSI_GetMaterial(Scripts[CurrentScript].Leather[i]);

// if the leather is found in the inventory (can call Supplies[0] because it's a script defined array, not user, so it will ALWAYS have length of 2)
if (length(MSI_FindItemSlots(Scripts[CurrentScript].Leather[i].Supplies[0])) > 0) then
Result := MSI_TanHides(Scripts[CurrentScript].Leather[i]);
end;
end;
end;

Edit:
I'm getting this on compiling
[Error] C:\Simba1\Includes\MSI/MSI/Skills/Money_Making.simba(365:70): Semicolon (';') expected at line 364
line 364 is your:
 if (length(MSI_FindItemSlots(Scripts[CurrentScript].Leather[i].Supplies[0])) > 0) then 

This fixes the errors, I got rid of the supplies bit because tbh I don't know what that is about, also the bit about stats would be good if it was added to the example on the guide on the op.

Var
Len : TIntegerArray;


// if the leather is found in the inventory (can call Supplies[0] because it's a script defined array, not user, so it will ALWAYS have length of 2)
Len := MSI_FindItemSlots(Scripts[CurrentScript].Leather[i]);
if (GetArraylength(Len) > 0) then
Result := MSI_TanHides(Scripts[CurrentScript].Leather[i]);
Not sure if this still does what it was supposed to.

Edit3:
I am guessing something I did stopped it working because it just runs to the Tanner then logs out:
[ **** ] ---- Loaded material: Cowhide to Soft Leather
[ **** ] ---- Loaded material: Cowhide to Hard Leather
[ **** ] ---- Loaded material: Blue Dragonhide
[ **** ] ---- Loaded material: Green Dragonhide
[ **** ] ---- Loaded material: Red Dragonhide
[ **** ] ---- Loaded material: Black Dragonhide
[ **** ] ---- Player[0].Script[0].ReportInfo.Items := [[[223], [222], [227], [225], [226], [226]]]
[ **** ] ---- Loaded material: Rune essence
[ **** ] ---- Player[1].Script[0].ReportInfo.Items := [[[160, 161, 162, 163, 164, 165]]]
[ **** ] ---- Player[3].Script[0].ReportInfo.Items := [[[45], [47]]]
[ **** ] -- MSI_SetupSPS: Surface: Runescape Surface, Areas: ['12_9', '11_9', '12_10']
[ **** ] -- MSI_SetupPlayer
[ **** ] ------ Players Found: 2
[ **** ] ------ Scanning for randoms...
[ **** ] ---- MSI_SetPlayerLoc
[ **** ] ------ MSI_AtLocation
[ **** ] ---------- MSI_GetMyPos(): (4915, 3995)
[ **** ] -------- Checking sub-location: Al Kharid Bank
[ **** ] ---------- MSI_BoxToMM(): (618, 61, 637, 103)
[ **** ] -------- Player is at Al Kharid Bank
[ **** ] ------ MSI_AtLocation: True
[ **** ] ------ Player's location: Al Kharid Bank
[ **** ] ---- MSI_SetPlayerLoc: True
[ **** ] ------ Materials found in inventory
[ **** ] -- MSI_SetupPlayer: True
[ **** ] -- MSI_Walk
[ **** ] ---- Player's Location = Al Kharid Bank
[ **** ] ---- MSI_AtLocation
[ **** ] -------- MSI_GetMyPos(): (4915, 3995)
[ **** ] ------ Checking sub-location: Al Kharid Tanner
[ **** ] ------ Player not at Al Kharid Tanner
[ **** ] ---- MSI_AtLocation: False
[ **** ] ------ Players Found: 1
[ **** ] ------ Scanning for randoms...
[ **** ] ---- MSI_WalkPath: LOC_AK_BANK to LOC_AK_TANNER
[ **** ] -------- MSI_PathFromLoc: [(4937, 3892)]
[ **** ] ------ Walking attempts: 1
[ **** ] ------ MSI_SetupSPS: Surface: Runescape Surface, Areas: ['12_9', '11_9', '12_10']
[ **** ] ------ MSI_WalkTPA
[ **** ] -------- Path: [(4915, 3990), (4945, 3890)]
[ **** ] ---------- MSI_PointOnPath: Index = 6
[ **** ] ---------- MSI_PointOnPath: Index = 0
[ **** ] ---------- MSI_PointOnPath: Index = 0
[ **** ] ---------- Current Energy: 100
[ **** ] -------- Next Point: 3 (4934, 3934)
[ **** ] ---------- Players Found: 1
[ **** ] ---------- Average pixel shift: 165
[ **** ] ---------- Flag distance: 64
[ **** ] ---------- Players Found: 1
[ **** ] ---------- Average pixel shift: 302
[ **** ] ---------- Flag distance: 64
[ **** ] ---------- Players Found: 1
[ **** ] ---------- Average pixel shift: 0
[ **** ] ---------- Player animation: Player Idle
[ **** ] ---------- MSI_GetMyPos(): (4925, 3995)
[ **** ] ---------- MSI_PointOnPath: Index = 0
[ **** ] -------- Attempts: 1
[ **** ] -------- Distance: 107
[ **** ] ---------- Current Energy: 95
[ **** ] -------- Next Point: 3 (4934, 3934)
[ **** ] ---------- Players Found: 3
[ **** ] ---------- Average pixel shift: 103
[ **** ] ---------- Flag distance: 58
[ **** ] ---------- Players Found: 3
[ **** ] ---------- Average pixel shift: 208
[ **** ] ---------- Flag distance: 55
[ **** ] ---------- Players Found: 3
[ **** ] ---------- MSI_AntiBan
[ **** ] ---------- Average pixel shift: 144
[ **** ] ---------- Flag distance: 46
[ **** ] ---------- Players Found: 3
[ **** ] ---------- Average pixel shift: 86
[ **** ] ---------- Flag distance: 44
[ **** ] ---------- Players Found: 3
[ **** ] ---------- Average pixel shift: 113
[ **** ] ---------- Flag distance: 42
[ **** ] ---------- Players Found: 0
[ **** ] ---------- Average pixel shift: 107
[ **** ] ---------- Flag distance: 38
[ **** ] ---------- Players Found: 3
[ **** ] ---------- Average pixel shift: 62
[ **** ] ---------- Player animation: Player Idle
[ **** ] ---------- MSI_GetMyPos(): (4940, 3955)
[ **** ] ---------- MSI_PointOnPath: Index = 2
[ **** ] -------- Attempts: 2
[ **** ] -------- Distance: 65
[ **** ] ---------- Current Energy: 85
[ **** ] -------- Next Point: 6 (4945, 3890)
[ **** ] ---------- Players Found: 6
[ **** ] ---------- Average pixel shift: 425
[ **** ] ---------- Flag distance: 55
[ **** ] ---------- Players Found: 5
[ **** ] ---------- Average pixel shift: 259
[ **** ] ---------- Flag distance: 51
[ **** ] ---------- Players Found: 5
[ **** ] ---------- Average pixel shift: 172
[ **** ] ---------- Flag distance: 48
[ **** ] ---------- Players Found: 4
[ **** ] ---------- Average pixel shift: 355
[ **** ] ---------- Flag distance: 46
[ **** ] ---------- Players Found: 4
[ **** ] ---------- Average pixel shift: 205
[ **** ] ---------- Flag distance: 42
[ **** ] ---------- Players Found: 4
[ **** ] ---------- Scanning for randoms...
[ **** ] ---------- Average pixel shift: 409
[ **** ] ---------- Flag distance: 37
[ **** ] ---------- Players Found: 4
[ **** ] ---------- Average pixel shift: 175
[ **** ] ---------- Flag distance: 34
[ **** ] ---------- Players Found: 3
[ **** ] ---------- Average pixel shift: 312
[ **** ] ---------- Flag distance: 29
[ **** ] ---------- Players Found: 4
[ **** ] ---------- Average pixel shift: 220
[ **** ] ---------- Flag distance: 25
[ **** ] ---------- Players Found: 4
[ **** ] ---------- Average pixel shift: 329
[ **** ] ---------- Flag distance: 19
[ **** ] ---------- Players Found: 4
[ **** ] ---------- Average pixel shift: 197
[ **** ] ---------- Flag distance: 17
[ **** ] ---------- Players Found: 3
[ **** ] ---------- Average pixel shift: 420
[ **** ] ---------- Average pixel shift: 373
[ **** ] ---------- Players Found: 3
[ **** ] ---------- Average pixel shift: 332
[ **** ] ---------- Average pixel shift: 362
[ **** ] ---------- Players Found: 2
[ **** ] ---------- Average pixel shift: 287
[ **** ] ---------- Average pixel shift: 160
[ **** ] ---------- Players Found: 2
[ **** ] ---------- Average pixel shift: 293
[ **** ] ---------- Average pixel shift: 244
[ **** ] ---------- Players Found: 2
[ **** ] ---------- Average pixel shift: 125
[ **** ] ---------- Average pixel shift: 80
[ **** ] ---------- Players Found: 2
[ **** ] ---------- Average pixel shift: 81
[ **** ] ---------- Average pixel shift: 76
[ **** ] ---------- Players Found: 1
[ **** ] ---------- Average pixel shift: 51
[ **** ] ---------- Player animation: Player Idle
[ **** ] ---------- MSI_GetMyPos(): (4950, 3885)
[ **** ] ---------- MSI_PointOnPath: Index = 6
[ **** ] -------- Attempts: 1
[ **** ] -------- Distance: 7
[ **** ] ---------- Players Found: 1
[ **** ] ---------- Average pixel shift: 26
[ **** ] ---------- Player animation: Player Idle
[ **** ] ------ MSI_WalkTPA: True
[ **** ] ------ MSI_AtLocation
[ **** ] ---------- MSI_GetMyPos(): (4950, 3885)
[ **** ] -------- Checking sub-location: Al Kharid Tanner
[ **** ] -------- MSI_Relocate (Al Kharid Tanner)
[ **** ] ------------ MSI_GetMyPos(): (4950, 3885)
[ **** ] ------------ Players Found: 1
[ **** ] ------------ Scanning for randoms...
[ **** ] ---------- MSI_WalkTPA
[ **** ] ------------ Path: [(4950, 3885), (4937, 3892)]
[ **** ] -------------- MSI_PointOnPath: Index = 1
[ **** ] -------------- MSI_PointOnPath: Index = 0
[ **** ] -------------- MSI_PointOnPath: Index = 0
[ **** ] -------------- Current Energy: 78
[ **** ] ------------ Next Point: 1 (4937, 3892)
[ **** ] -------------- Players Found: 2
[ **** ] -------------- Average pixel shift: 16
[ **** ] -------------- Player animation: Player Idle
[ **** ] -------------- MSI_GetMyPos(): (4950, 3885)
[ **** ] -------------- MSI_PointOnPath: Index = 0
[ **** ] ------------ Attempts: 1
[ **** ] ------------ Distance: 15
[ **** ] -------------- Players Found: 2
[ **** ] -------------- Average pixel shift: 162
[ **** ] -------------- Flag distance: 13
[ **** ] -------------- Players Found: 2
[ **** ] -------------- Average pixel shift: 325
[ **** ] -------------- Flag distance: 15
[ **** ] -------------- Players Found: 2
[ **** ] -------------- Average pixel shift: 371
[ **** ] -------------- Flag distance: 16
[ **** ] -------------- Players Found: 2
[ **** ] -------------- Average pixel shift: 262
[ **** ] -------------- Flag distance: 16
[ **** ] -------------- Players Found: 2
[ **** ] -------------- Average pixel shift: 323
[ **** ] -------------- Flag distance: 16
[ **** ] -------------- Players Found: 2
[ **** ] -------------- Average pixel shift: 148
[ **** ] -------------- Average pixel shift: 0
[ **** ] -------------- Player animation: Player Idle
[ **** ] ---------- MSI_WalkTPA: True
[ **** ] ---------- Relocating to sub-location: Al Kharid Tanner
[ **** ] ------------ Players Found: 2
[ **** ] ------------ Average pixel shift: 48
[ **** ] ------------ Player animation: Player Idle
[ **** ] -------- MSI_Relocate: True
[ **** ] ------ MSI_AtLocation: True
[ **** ] ---- MSI_WalkPath: True
[ **** ] -- MSI_Walk: True
[ **** ] -- MSI_AutoObjects
[ **** ] ------ Loaded material: Red Dragonhide
[ **** ] -- MSI_AutoObjects: False
[ **** ] -- MSI_UnsetPlayer
[ **** ] ---- Failed to use script: Alkarid Leather Tanner

Coh3n

2012-02-11 03:23:19

You still need that length check in MSI_SetupTanner. And the supplies line I added finds the raw hides in your inventory. Without that line, it would try to tan every hide in the player's Leather array (even if the leather isn't in your inventory).

The compiling error, I used the type wrong. Here's a different version, you may understand it better:

function MSI_TanLeather(): Boolean;
var
i: integer;
mat: TMaterial;
script: TScript;
begin
if (not loggedIn) then
exit;

script := MSI_Players[CurrentPlayer].GetScript();

// make sure the user actually set leather to tan
if (length(script.leather) <= 0) then
begin
MSI_Debug('Invalid Leather selection for player '+toStr(CurrentPlayer));
exit;
end;

// loop through the player materials, tanning whichever is found
for i := 0 to high(script.leather) do
begin
mat := MSI_GetMaterial(script.leather[i]);

// if the leather is found in the inventory (can call Supplies[0] because it's a script defined array, not user, so it will ALWAYS have length of 2)
if (length(MSI_FindItemSlots(mat.supplies[0])) > 0) then
Result := MSI_TanHides(script.leather[i]);
end;
end;
Also, it's walking to the Tanner and doing nothing because you don't tell it to talk to the Tanner! You're missing an MSI_TalkToTanner() procedure. I would add it in something like this:

function MSI_TanLeather(): Boolean;
var
i: integer;
mat: TMaterial;
script: TScript;
begin
if (not loggedIn) then
exit;

script := MSI_Players[CurrentPlayer].GetScript();

// make sure the user actually set leather to tan
if (length(script.leather) <= 0) then
begin
MSI_Debug('Invalid Leather selection for player '+toStr(CurrentPlayer));
exit;
end;

if (MSI_TalkToTanner()) then // we only want to tan if we've talked to the tanner
if (waitFunc(@MSI_HideScreen, 50, 5000)) then // wait for the tanning screen to appear
// loop through the player materials, tanning whichever is found
for i := 0 to high(script.leather) do
begin
mat := MSI_GetMaterial(script.leather[i]);

// if the leather is found in the inventory (can call Supplies[0] because it's a script defined array, not user, so it will ALWAYS have length of 2)
if (length(MSI_FindItemSlots(mat.supplies[0])) > 0) then
Result := MSI_TanHides(script.leather[i]);
end;
end;
Remember, you'll have to write MSI_TalkToTanner. ;)

Lastly, I just noticed this in MSI_TanHides:

MarkTime(Time);
Repeat
Wait(200+Random(500));
if(TimeFromMark(Time) > 5000) then
begin
Result := False;
exit;
end;
if(MSI_HideScreen) then
break;
MSI_SubDebug('Hide screen not open');
Until(false);
It can be shortened to:

// have this BEFORE you click the tanning coords
if (not MSI_HideScreen()) then
exit;

// have this AFTER you click
result := waitFunc(@MSI_HideScreen, 50, 5000);

PatDuffy

2012-02-17 19:49:26

I must say, this guide really did explain everything you could possibly need for learning how to script for MSI :p

I would suggest that you might want to stress for the creation of TLocations, make sure you have the objects listed that you will use in that area in the objects part. I spent 20 minutes changing the SPS Areas for a location trying to get it to work, only to realize I forgot to include [ROCK_IRON] as an object in the area, adding that it worked perfectly.

I Just finished making a Yanille Miner(Currently only Iron) and it's working great! I'm going to try to add the other rocks in that mine, then test it out fully before I think about pushing(or is it pulling, I'm new to Git) the new script.

Status: /~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\
Status: | SRL Randoms Report |
Status: | [url]www.villavu.com[/url] |
Status: |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Status: \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/
{----------------------------------------------------------------}
{ MSI Phoenix Short Report }
{----------------------------------------------------------------}
{ Time Running: 1 Hours, 6 Minutes and 49 Seconds }
{----------------------------------------------------------------}
{ }
{ Totals: }
{ - Players: 1 }
{ - Player Time: 01h 06m 01s }
{ - Loads: 17 }
{ - Experience: 16,660 }
{ - Rocks Mined: 476 }
{ }
{----------------------------------------------------------------}
{----------------------------------------------------------------}

{----------------------------------------------------------------}
{ MSI Phoenix Player Report }
{----------------------------------------------------------------}
{ Time Running: 1 Hours, 6 Minutes and 49 Seconds }
{----------------------------------------------------------------}
{ }
{ Player 0: ******** }
{ Location: Yanille Bank }
{ Time: 01h 06m 01s }
{ Active: True }
{ }
{ Script: Yanille Miner }
{ Time: 01h 06m 01s }
{ Skill: Mining }
{ Exp: 16,660 }
{ Level: 75 }
{ Loads: 17 }
{ Item: Iron ore }
{ Amount: 476 }
{ }
{----------------------------------------------------------------}
{----------------------------------------------------------------}

Kyle Undefined

2012-02-17 19:52:46

You will push your changes to your repo, then when you're one hundred percent done, send a pull request :)

Also, make sure you get the latest MSI and merge your changes before sending a pull ;)

PatDuffy

2012-02-17 19:58:03

From: Kyle Undefined
You will push your changes to your repo, then when you're one hundred percent done, send a pull request :)

Also, make sure you get the latest MSI and merge your changes before sending a pull ;)


That is gibberish to me :p

My repo is the page on Git that I forked from the main MSI? So I push my changes to my own repo, then send a pull request? Also, how do I merge the latest MSI with it so I don't accidently over-right my changes? Sorry for the trouble Kyle ;)

Coh3n

2012-02-19 20:28:22

Nice work, Pat. :) I'll stress that point more in the first post.

E: Fixed. I also fixed the spsBox as x1, y1 is actually the top left, not bottom left.

PatDuffy

2012-02-20 13:38:31

From: Coh3n

E: Fixed. I also fixed the spsBox as x1, y1 is actually the top left, not bottom left.


I thought that seemed odd compared to how boxes work, but I didn't say anything because I thought maybe you wanted MSI to do things differently.

That should fix some problems in the next installment I'm making for MSI :p

Coh3n

2012-02-20 19:56:56

From: PatDuffy
I thought that seemed odd compared to how boxes work, but I didn't say anything because I thought maybe you wanted MSI to do things differently.

That should fix some problems in the next installment I'm making for MSI :p
It was because that's how reflection tiles worked (can't remember why exactly), and I forgot to update when I removed reflection.

Recursive

2012-04-12 14:54:21

I am trying to make a new script; the problem is that I don't know the first place to start for the coding. I know Coh3n made this nice guide, but those all mean nothing to me. I have never done pascal scripting before but I have some knowledge with other scripting languages (I guess +1?). The script I am trying to make is supposed to run to a location, pick up something till the invent is full, then teleport back, bank and repeat. Of course there are other details but those can come later when I actually know the first place to begin coding this thing. And when I pick colors for the object, not all the 4 points have the same colour, so I need help with virtually the very basic fml.

And please when you read this, don't flame cause that's just childish. Explain using plain words, I think I can convert that to scripting language. And please explain procedure for making a script like this in the order it is to be coded.

Coh3n

2012-04-12 18:29:02

From: Chig
I am trying to make a new script; the problem is that I don't know the first place to start for the coding. I know Coh3n made this nice guide, but those all mean nothing to me. I have never done pascal scripting before but I have some knowledge with other scripting languages (I guess +1?). The script I am trying to make is supposed to run to a location, pick up something till the invent is full, then teleport back, bank and repeat. Of course there are other details but those can come later when I actually know the first place to begin coding this thing. And when I pick colors for the object, not all the 4 points have the same colour, so I need help with virtually the very basic fml.

And please when you read this, don't flame cause that's just childish. Explain using plain words, I think I can convert that to scripting language. And please explain procedure for making a script like this in the order it is to be coded.
Well an introduction to the Pascal language would be a good start. I suggest going through this tutorial.

http://villavu.com/forum/showthread.php?t=58935

Recursive

2012-04-12 19:07:20

From: Coh3n
Well an introduction to the Pascal language would be a good start. I suggest going through this tutorial.

http://villavu.com/forum/showthread.php?t=58935


Lol good idea! Guess you need to grow wings to fly