Module:Price: Difference between revisions

From Roat Pkz
Jump to navigation Jump to search
No edit summary
No edit summary
Tag: Manual revert
 
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
local p = {}


local coins = require('Module:Coins')
local exchange = require('Module:Exchange')


local geprices_data = mw.loadJsonData('Module:GEPrices/data.json')
--
 
-- Module access point
 
--
 
function p._main(target)
function p.main( frame )
-- return target
local args = frame:getParent().args
if not target then
    -- Params and defaults
return 'N/A'
    local geprice = params.defaults{
end
        {args.geprice or args.geprice, ''}
    }
    local itemvalue = ''
    local gemwname = params.default_to(args.gemwname,name)
    local smwname = params.default_to(args.smwname,name)
    local displayname = params.default_to(args.displayname or args.DisplayName,name)
    local image = 'File:' .. params.default_to(args.image or args.Image, name .. '.png')
    local gemw = yesno(args.gemw or 'yes', false)
    local restock = params.default_to(args.restock or args.Restock,-1)
   
    -- Check precached Module:GEPrices/data
    if gemw and geprice == '' then
        local cached_price = geprices_data[gemwname]
        if type(cached_price) == 'number' and cached_price > 0 then
            geprice = cached_price
        end
    end


target = tostring(target)
local amount = exchange._price(target)
return coins._amount(amount)
end


--
-- {{Coins}} access point
--
function p.main(frame)
local args = frame:getParent().args
return p._main(args[1])
end


 
--[[ DEBUG =
 
= p._main('Watering can')
 
= p._main()
end
--]]


return p
return p

Latest revision as of 19:02, 3 April 2024

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

local p = {}

local coins = require('Module:Coins')
local exchange = require('Module:Exchange')

--
-- Module access point
--
function p._main(target)
	-- return target
	if not target then
		return 'N/A'
	end

	target = tostring(target)
	local amount = exchange._price(target)
	return coins._amount(amount)
end

--
-- {{Coins}} access point
--
function p.main(frame)
	local args = frame:getParent().args
	return p._main(args[1])
end

--[[ DEBUG =
= p._main('Watering can')
= p._main()
--]]

return p