Module:Grid/Item

local p = {}

local g = require("Module:Common") local s = require("Module:Sprite") local cn = require("Module:Grid/Crafting_Square_Numbers")

function p.makeItem(name, amount, img, link, tooltip, top, left, fill) local output = '' .. g.img(img, 32, link, name) .. ' '	if amount > 1 then output = output .. '' .. cn.makeCraftingNumbers(amount, link) .. ' '	end return output end

function p.main(frame) local frame, args = g.getFrameAndArgs(frame) if not g.isGiven(args.name) then return '' end local tooltip = '' if g.isGiven(args.chance) and tonumber(args.chance) then local chance = tonumber(args.chance) if chance < 0 then chance = 0 end if chance > 100 then chance = 100 end tooltip = tooltip .. chance .. '% chance of ' end local amount = 1 if g.isGiven(args.amount) and tonumber(args.amount) then amount = tonumber(args.amount) end if amount > 1 then tooltip = tooltip .. amount .. ' '	elseif g.isGiven(args.liquid) and tonumber(args.liquid) then local liquid = tonumber(args.liquid) * 1000 tooltip = tooltip .. liquid .. 'mB of ' end tooltip = tooltip .. args.name local image = args.image if not g.isGiven(image) then image = 'Grid ' .. args.name .. '.png' end local dict = args.dict if g.isGiven(dict) then tooltip = dict .. ' - ' .. tooltip -- TODO: Replace with image? end local link = args.link if not g.isGiven(link) then if g.isGiven(dict) and ((not g.isGiven(args.dictamount)) or 				tonumber(args.dictamount) > 1) then link = dict else link = args.name end end local top = 0 if g.isGiven(args.top) and tonumber(args.top) then top = tonumber(args.top) end local left = 0 if g.isGiven(args.left) and tonumber(args.left) then left = tonumber(args.left) end return p.makeItem(args.name, amount, image, link, tooltip, top, left, args.fill) end

return p