×
Create a new article
Write your page title here:
We currently have 1 article on Test2 Wiki. Type your article name above or create one of the articles listed here!



    Test2 Wiki

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

    local getArgs = require("Module:Args").getArgs
    local resourceTypes = require("Module:ResourceTypes")
    
    local m = {}
    
    function m.GetImages(f)
    	local baseTypes = {
    		plank = "Wood",
    		slab = "Stone",
    		ingot = "Metal",
    		glass = "Pane"
    	}
    	local exceptions = { --\\ Future proofing
    		bluespruce = "Blue_Spruce"
    	}
    
    	local materials = getArgs(f).Material
    	materials = materials:gsub("<br%s?/>",""); materials = materials:gsub(",%s*","")
    	local imageSize = getArgs(f).ImageSize or "25px"
    	for num, str in materials:gmatch("(%d+)%s*([%a%s]+)") do
    		str = str:gsub("%s",""); local lowerStr = str:lower()
    		if baseTypes[lowerStr] or baseTypes[lowerStr:gsub("e?s?$","")] then
    			local formattedStr = baseTypes[lowerStr] and str or str:gsub("e?s?$","")
    			materials = materials:gsub(num.."%s*"..str, num.." [[File:Base"..formattedStr..".png|"..imageSize.."|link="..(baseTypes[lowerStr] or baseTypes[lowerStr:gsub("e?s?$","")]).."]]<br/>")
    		else
    			local link = exceptions[str:lower()] and exceptions[str:lower()] or nil
    			for index, resourceTable in pairs(resourceTypes) do
    				for _, material in pairs(resourceTable) do
    					if lowerStr == material:lower() then
    						materials = materials:gsub(num.."%s*"..str, num.." [[File:"..material..index..".png|"..imageSize.."|link="..(link or material).."]]<br/>")
    					end
    				end
    			end
    		end
    	end
    	materials = materials:gsub("<br/>$","")
    	return materials
    end
    
    function m.GetMetalSpawns(f)
    	local metalSpawns = require("Module:MetalSpawns")
    	
    	local stones = getArgs(f).Stone or ""
    	local metals = getArgs(f).Metal or ""
    	if metals ~= "" and not metals:match("[<br/>]$") then metals = metals.."<br/>" end
    	
    	for str in stones:gmatch("(%a[%a%s]+)") do
    		if not str:match("<br/>") and metalSpawns[str] then
    			for _,v in pairs(metalSpawns[str]) do
    				if not metals:match(v) then
    					metals = metals.."[["..v.."]]<br/>"
    				end
    			end
    		end
    	end
    	metals = metals:gsub("<br/>$","")
    	return metals
    end
    
    return m
    
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.

    Recent changes

  • Alexender • 2 months ago
  • Fjalon • 2 months ago
  • Fjalon • 2 months ago
  • Fjalon • 2 months ago
  • Cookies help us deliver our services. By using our services, you agree to our use of cookies.