Module:Test: Difference between revisions

From Roat Pkz
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
-- Module table
-- This is a Lua module for MediaWiki
local test = {}
-- It provides functionality to calculate percentages of a number


-- Function to get price by item name
-- Create a table to hold the functions
function test.getPrice(itemName)
local Test = {}
    local jsonData = mw.loadJsonData("Module:GEPrices/data.json")
    if not jsonData then
        return nil
    end


     local price = jsonData[itemName]
-- Function to calculate percentages
     if price then
function Test.calculatePercentages(number)
        return itemName .. ": " .. price
     local percentages = {}
     else
     -- Original number
        return "Item not found"
    table.insert(percentages, number)
     end
    -- 10% increase
    table.insert(percentages, number * 1.10)
    -- 20% increase
    table.insert(percentages, number * 1.20)
    -- 30% increase
     table.insert(percentages, number * 1.30)
   
     return percentages
end
end


return test
-- Export the module
return Test

Revision as of 22:42, 3 April 2024

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

-- This is a Lua module for MediaWiki
-- It provides functionality to calculate percentages of a number

-- Create a table to hold the functions
local Test = {}

-- Function to calculate percentages
function Test.calculatePercentages(number)
    local percentages = {}
    -- Original number
    table.insert(percentages, number)
    -- 10% increase
    table.insert(percentages, number * 1.10)
    -- 20% increase
    table.insert(percentages, number * 1.20)
    -- 30% increase
    table.insert(percentages, number * 1.30)
    
    return percentages
end

-- Export the module
return Test