Module:Test

From Fallen London Wiki

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

local p = {}
 
local image_data = mw.loadData('Module:IL/images')

function p.main(frame)
	local quality_item_name = frame.args[1] or frame:getParent().args[1]
	local no_default = frame.args["nodef"] or frame:getParent().args["nodef"]
	
	quality_item_name = quality_item_name:gsub("^%l", string.upper)
	if image_data[quality_item_name] ~= nil then
	    quality_item_name = image_data[quality_item_name]
	elseif no_default then
	    quality_item_name = ""
	else
	    quality_item_name = "Questionsmall.png"
	end
	return quality_item_name
end

function p.test(frame)
	local pargs = frame:getParent().args
	local unlock = pargs["Unlocked with"] or ""
	local lock = pargs["Locked with"] or ""
	local ret = ""
	if unlock:find("{{Lock|") or lock:find("{{Unlock|") then
		if frame.args.preview == "" then
			ret = ret .. '<p><span class="warning">Preview – Warning: Requirement template mismatch detected! (Lock/Unlock in wrong parameter)</span></p>'
		end
		ret = ret .. "[[Category:Requirement template mismatches]]"
	end
	return ret
end

return p