Module:Test: Difference between revisions

From Roat Pkz
Jump to navigation Jump to search
No edit summary
No edit summary
Line 8: Line 8:
         return nil
         return nil
     end
     end
     return jsonData[itemName] or nil
 
     local price = jsonData[itemName]
    if price then
        return itemName .. ": " .. price
    else
        return "Item not found"
    end
end
end


return test
return test

Revision as of 22:36, 3 April 2024

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

-- Module table
local test = {}

-- Function to get price by item name
function test.getPrice(itemName)
    local jsonData = mw.loadJsonData("Module:GEPrices/data.json")
    if not jsonData then
        return nil
    end

    local price = jsonData[itemName]
    if price then
        return itemName .. ": " .. price
    else
        return "Item not found"
    end
end

return test