Module:CoinsGE

From RuneRealm Wiki
Jump to navigation Jump to search
Module documentation
This documentation is transcluded from Module:CoinsGE/doc. [edit] [history] [purge]
Module:CoinsGE's function main is invoked by Template:CoinsGE.
Module:CoinsGE requires Module:Coins.
Module:CoinsGE requires Module:Exchange.

This is a wrapper around the Module:Coins module and inspired by the Template:GEP. It combines their functionality to both show the appopriate coins symbol and grab the GE price for the given item.

This module is a helper module to be used by other modules; it may not designed to be invoked directly. See RuneScape:Lua/Helper modules for a full list and more information. For a full list of modules using this helper click here

FunctionTypeUse
_main(item)StringReturns a formatted string with a coins icon and the amount of coins the item is worth in GE. See Template:CoinsGE for examples.

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