Module:LangVars: Difference between revisions

From Vintage Story Wiki
(Created page with "local p = {} local i18n = { crafting = { itemStone = 'Stone', itemRock = 'Rock', itemLog = 'Log', itemPickaxeHead = 'Pickaxe head', itemAxeHead = 'Axe head', ite...")
 
mNo edit summary
 
(19 intermediate revisions by the same user not shown)
Line 1: Line 1:
local p = {}
local p = {}


local i18n = {
local langVars = {}
crafting = {
function p.processLang(code)
itemStone = 'Stone',
langVars = require( 'Module:LangVars/' .. code ).i18n
itemRock = 'Rock',
return langVars
itemLog = 'Log',
end
itemPickaxeHead = 'Pickaxe head',
 
itemAxeHead = 'Axe head',
function p.link(s)
itemShovelHead = 'Shovel head',
local str = string.lower(s)
},
local out, img = s
any = 'Any',
}
--Tools and tool heads
for i,v in pairs(langVars.toolTypes) do
if str:match(string.lower(v)) 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
return p

Latest revision as of 04:06, 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
	
	--Tools and tool heads
	for i,v in pairs(langVars.toolTypes) do
		if str:match(string.lower(v)) 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