Module:ConPrice

-- -- Template:CP -- -- Outputs the price of construction materials as bought from shops --

local p = {}

local prices = { plank             = 100, oak_plank         = 250, teak_plank        = 500, mahogany_plank    = 1500, bronze_nails      = 7, bolt_of_cloth     = 650, limestone_brick   = 21, gold_leaf         = 130000, marble_block      = 325000, magic_stone       = 975000, bagged_dead_tree  = 1000, bagged_plant_1    = 1000, bagged_nice_tree  = 2000, bagged_oak_tree   = 5000, bagged_plant_2    = 5000, thorny_hedge      = 5000, bagged_rosemary   = 5000, bagged_sunflower  = 5000, bagged_willow_tree = 10000, bagged_plant_3    = 10000, nice_hedge        = 10000, bagged_daffodils  = 10000, bagged_marigolds  = 10000, bagged_maple_tree = 15000, small_box_hedge   = 15000, bagged_bluebells  = 15000, bagged_roses      = 15000, bagged_yew_tree   = 20000, topiary_hedge     = 20000, bagged_magic_tree = 50000, tall_fancy_hedge  = 50000, fancy_hedge       = 25000, tall_box_hedge    = 100000, bagged_cactus     = 18000, bagged_evergreen  = 45000, beer              = 3, cider             = 2, asgarnian_ale     = 3, ["greenman's_ale"] = 2, dragon_bitter     = 2 }

local aliases = { nail       = 'bronze_nail', nails      = 'bronze_nail', bronze_nail = 'bronze_nail' }

function p.main( frame ) local args = frame:getParent.args local item = args[1] local multi = args[2] local price = 0

-- force lower case -- replace spaces with underscores item = item:lower:gsub( ' ', '_' )

-- look for known aliases if aliases[item] ~= nil then item = aliases[item] end

-- set price if prices[item] ~= nil then price = prices[item] end

-- apply multiplier if present if multi ~= nil and type( tonumber( multi ) ) == 'number' then price = price * tonumber( multi ) end

return price end

return p