Generic Functions - uosagas/assistant GitHub Wiki

Pause

Pauses the script routine for n-milliseconds

Pause(3000) -- Pauses the script for 3 seconds

Import

Imports a script/library to the current script (similar to require)

Example:

Library ItemTypes

--============== Item Types ==============--
-- Author: 3HMonkey
-- Description: Class abstraction of items
-- Usage: Can be referenced by another script
-- Dependencies: None
--========================================--
local ItemTypes = {
    Shields = {
        { ItemType = 0x1b72, Name = "BronzeShields" },
        { ItemType = 0x1b73, Name = "Buckler" },
        { ItemType = 0x1b7b, Name = "MetalShield" },
        { ItemType = 0x1b74, Name = "Metal Kite Shield" },
        { ItemType = 0x1b79, Name = "Tear Kite Shield" },
        { ItemType = 0x1b7a, Name = "WoodenShield" },
        { ItemType = 0x1b76, Name = "HeaterShield" }
    },
    BoneArmor = {
        { ItemType = 0x1451, Name = "Bone Helmet" },
        { ItemType = 0x144f, Name = "Bone Armor" },
        { ItemType = 0x1452, Name = "Bone Leggings" },
        { ItemType = 0x144e, Name = "Bone Arms" },
        { ItemType = 0x1450, Name = "Bone Gloves" }
    },
    Platemail = {
        { ItemType = 0x1408, Name = "Close Helmet" },
        { ItemType = 0x1410, Name = "Platemail Arms" },
        { ItemType = 0x1411, Name = "Platemail Legs" },
        { ItemType = 0x1412, Name = "Plate Helm" },
        { ItemType = 0x1413, Name = "Plate Gorget" },
        { ItemType = 0x1414, Name = "Platemail Gloves" },
        { ItemType = 0x1415, Name = "Plate Chest" },
        { ItemType = 0x140a, Name = "Helmet" },
        { ItemType = 0x140c, Name = "Bascinet" },
        { ItemType = 0x140e, Name = "Norse Helm" }
    },
    Chainmail = {
        { ItemType = 0x13bb, Name = "Chainmail Coif" },
        { ItemType = 0x13be, Name = "Chainmail Leggins" },
        { ItemType = 0x13bf, Name = "Chainmail Tunic" }
    },
    Ringmail = {
        { ItemType = 0x13ee, Name = "Ringmail Sleeves" },
        { ItemType = 0x13eb, Name = "Ringmail Gloves" },
        { ItemType = 0x13ec, Name = "Ringmail Tunic" },
        { ItemType = 0x13f0, Name = "Ringmail Leggins" }
    },
    Studded = {
        { ItemType = 0x13da, Name = "Studded Leggings" },
        { ItemType = 0x13db, Name = "Studded Tunic" },
        { ItemType = 0x13d5, Name = "Studded Gloves" },
        { ItemType = 0x13d6, Name = "Studded Gorget" },
        { ItemType = 0x13dc, Name = "Studded Sleeves" }
    },
    Leather = {
        { ItemType = 0x13c6, Name = "Leather Gloves" },
        { ItemType = 0x13cd, Name = "Leather Sleeves" },
        { ItemType = 0x13cc, Name = "Leather Tunic" },
        { ItemType = 0x13cb, Name = "Leather Pants" },
        { ItemType = 0x13c7, Name = "Leather Gorget" },
        { ItemType = 0x1db9, Name = "Leather Cap" }
    },
    FemaleArmor = {
        { ItemType = 0x1c04, Name = "Female Plate" },
        { ItemType = 0x1c0c, Name = "Female Studded Bustier" },
        { ItemType = 0x1c02, Name = "Female Studded Armor" },
        { ItemType = 0x1c00, Name = "Female Leather Shorts" },
        { ItemType = 0x1c08, Name = "Female Leather Skirt" },
        { ItemType = 0x1c06, Name = "Female Leather Armor" },
        { ItemType = 0x1c0a, Name = "Female Leather Bustier" }
    },
    Fencing = {
        { ItemType = 0xf62, Name = "Spear" },
        { ItemType = 0x1403, Name = "Short Spear" },
        { ItemType = 0xe87, Name = "Pitchfork" },
        { ItemType = 0x1405, Name = "Warfork" },
        { ItemType = 0x1401, Name = "Kryss" },
        { ItemType = 0xf52, Name = "Dagger" }
    },
    Macing = {
        { ItemType = 0x13b0, Name = "War axe" },
        { ItemType = 0xdf0, Name = "Black Staff" },
        { ItemType = 0x1439, Name = "War Hammer" },
        { ItemType = 0x1407, Name = "War Mace" },
        { ItemType = 0xe89, Name = "Quarter Staff" },
        { ItemType = 0x143d, Name = "Hammer Pick" },
        { ItemType = 0x13b4, Name = "Club" },
        { ItemType = 0xe81, Name = "Shepherds Crook" },
        { ItemType = 0x13f8, Name = "Gnarled Staff" },
        { ItemType = 0xf5c, Name = "Mace" },
        { ItemType = 0x143b, Name = "Maul" }
    },
    Swords = {
        { ItemType = 0x13b9, Name = "Viking Sword" },
        { ItemType = 0xf61, Name = "Longsword" },
        { ItemType = 0x1441, Name = "Cutlass" },
        { ItemType = 0x13b6, Name = "Scimitar" },
        { ItemType = 0xec4, Name = "Skinning Knife" },
        { ItemType = 0x13f6, Name = "Butcher Knife" },
        { ItemType = 0xf5e, Name = "Broadsword" },
        { ItemType = 0x13ff, Name = "Katana" },
        { ItemType = 0xec3, Name = "Cleaver" }
    },
    Axes = {
        { ItemType = 0xf43, Name = "Hatchet" },
        { ItemType = 0xf45, Name = "Executioner's Axe" },
        { ItemType = 0xf4d, Name = "Bardiche" },
        { ItemType = 0xf4b, Name = "Double Axe" },
        { ItemType = 0x143e, Name = "Halberd" },
        { ItemType = 0x13fb, Name = "Large Battle Axe" },
        { ItemType = 0x1443, Name = "Two Handed Axe" },
        { ItemType = 0xf47, Name = "Battle Axe" },
        { ItemType = 0xf49, Name = "Axe" },
        { ItemType = 0xe85, Name = "Pickaxe" },
        { ItemType = 0xe86, Name = "Pickaxe" }
    },
    Bows = {
        { ItemType = 0x13fd, Name = "HeavyXbow" },
        { ItemType = 0xf50, Name = "Xbow" },
        { ItemType = 0x13b2, Name = "bow" }
    },
    Reagents = {
        { ItemType = 0x0f8c, Name = "Sulfurous Ash"},
        { ItemType = 0x0f7b, Name = "Blood Moss"},
        { ItemType = 0x0f88, Name = "Nightshade"},
        { ItemType = 0x0f86, Name = "Mandrake Root"},
        { ItemType = 0x0f85, Name = "Ginseng"},
        { ItemType = 0x0f8d, Name = "Spider's Silk"},
        { ItemType = 0x0f84, Name = "Garlic"},
        { ItemType = 0x0f7a, Name = "Black Pearl"}
    }
}
return ItemTypes

Executing script using "Import"

itemTypes = Import('ItemTypesLib')

Messages.Print('=== Accessing Shield Types ===')
for _, shield in ipairs(itemTypes.Shields) do
    Messages.Print(string.format("Shield: %s (0x%04X)", shield.Name, shield.ItemType))
end