Module:LangVars: Difference between revisions

From Vintage Story Wiki
mNo edit summary
mNo edit summary
Line 11: Line 11:
local out, img = s
local out, img = s
for pre in pairs(langVars.metalPrefixes) do
for i,v in pairs(langVars.toolTypes) do
if str:find(string.lower(pre)) then
if str:match(string.lower(v) .. ' ' .. string.lower(langVars.itemToolHead)) then  
if str:find(string.lower(langVars.itemToolHead)) then
out = s
out = s:match(pre .. '%s(.*)')
img = 'Iron ' .. str
img = 'Iron ' .. string.lower(out)
end
end
end
end
end
--Metal plates
--Metal plates
if string.lower(str):find(string.lower(langVars.itemMetalPlate)) then  
if string.lower(str):find(string.lower(langVars.itemMetalPlate)) then  

Revision as of 03:46, 23 August 2022

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

local p = {}

local langVars = {}
function p.processLang(code)
	langVars = require( 'Module:LangVars/' .. code ).i18n
	return langVars
end

function p.link(s)
	local str = string.lower(s)
	local out, img = s
	
	for i,v in pairs(langVars.toolTypes) do
		if str:match(string.lower(v) .. ' ' .. string.lower(langVars.itemToolHead)) then 
			out = s
			img = 'Iron ' .. str
		end
	end
	--Metal plates
	if string.lower(str):find(string.lower(langVars.itemMetalPlate)) then 
		out = langVars.itemMetalPlate 
		img = 'Iron plate' 
	end
	--Lanterns
	if string.lower(str):find(string.lower(langVars.itemLantern)) then 
		out = langVars.itemLantern 
		img = 'Iron lantern'
	end
	
	return out, img
end

return p