Module:GetMostExpensiveArmorPiece

From RuneRealm Wiki

This is the current revision of this page, as edited by Alex (talk | contribs) at 00:12, 17 October 2024 (Created page with "-- Module:GetMostExpensiveArmorPiece local p = {} -- Define the equipment slots local slotOptions = {'head', 'cape', 'neck', 'ammo', 'weapon', 'shield', 'body', 'legs', 'hands', 'feet', 'ring', '2h'} function p.getMostExpensiveArmorPiece() local geprices = mw.loadJsonData('Module:GEPrices/data.json') -- Check if the specified slot is valid -- local slotName = slotOptions[slot] -- if not slotName then -- return "Invalid equipment slot" -- end..."). The present address (URL) is a permanent link to this version.

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:GetMostExpensiveArmorPiece/doc

-- Module:GetMostExpensiveArmorPiece

local p = {}

-- Define the equipment slots
local slotOptions = {'head', 'cape', 'neck', 'ammo', 'weapon', 'shield', 'body', 'legs', 'hands', 'feet', 'ring', '2h'}

function p.getMostExpensiveArmorPiece()
	local geprices = mw.loadJsonData('Module:GEPrices/data.json')
    -- Check if the specified slot is valid
    -- local slotName = slotOptions[slot]
    -- if not slotName then
    --     return "Invalid equipment slot"
    -- end
	local slot = 'head'
    local mostExpensiveItem = nil
    local highestPrice = 0

    -- Iterate through all items in the slot
    for _, item in geprices do
        if item.slot == slotName then
            local price = exchange._price(item.name)
            if price > highestPrice then
                highestPrice = price
                mostExpensiveItem = item
            end
        end
    end
end

return p