Module:Test

local p = {}

--Hello, world! function p.hello( frame ) return "Hello, world!" end

--https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#table function p.tabletest( frame )

-- Create table t = {} t["foo"] = "foo" t.bar = "bar" t[1] = "one" t[2] = "two" t[3] = "three" t[12] = "the number twelve" t["12"] = "the string twelve" t[true] = "true" t[tonumber] = "yes, even functions may be table keys" t[t] = "yes, a table may be a table key too. Even in itself."

-- This creates a table roughly equivalent to the above t2 = { foo = "foo", bar = "bar", "one", "two", [12] = "the number twelve", ["12"] = "the string twelve", "three", [true] = "true", [tonumber] = "yes, even functions may be table keys", }   t2[t2] = "yes, a table may be a table key too. Even in itself." end

--like Template:HylianALBW/Letter function p.getChar( frame ) local game = frame.args[1] local char = frame.args[2] local size = frame.args[3] char = char:upper --char = string.upper(char) --https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Control_structures --No case-switch in Lua --https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Relational_operators --https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Logical_operators --https://stackoverflow.com/questions/27633331/can-i-check-strings-equality-in-lua#27634079 local letter = char if game == 'SS' then if    char == 'D' or char == 'W' then letter = 'DW' elseif char == 'E' or char == 'K' then letter = 'EK' elseif char == 'O' or char == 'Z' then letter = 'OZ' end elseif game == 'ALBW' then if    char == 'D' or char == 'G' then letter = 'DG' elseif char == 'F' or char == 'R' then letter = 'FR' elseif char == 'J' or char == 'T' then letter = 'JT' elseif char == 'E' or char == 'W' then letter = 'EW' elseif char == 'O' or char == 'Z' then letter = 'OZ' end end local ext = 'png' if game == 'ALBW' then ext = 'svg' end

--https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Concatenation_operator return ' ' end

--like Template:HylianALBW function p.getWord( frame ) -- https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual -- https://www.lua.org/cgi-bin/demo --Precondition: Assumes no spaces in the string --https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Variables --https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Frame_object local game = frame.args[1] local word = frame.args[2] local size = frame.args[3] game = game:upper if game == 'BOTW' then game = 'ALBW' end if size == nil or '' then size = '20' end --https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#table local t = {} --https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#string t[1] = ' ' --https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Length_operator --https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Control_structures local i = 1 repeat --https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Function_calls --https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#string.sub local char = word:sub(i,i) --local char = string.sub(word,i,i) --local char = word.sub(word,i,i) --argument formatted like a frame object: t[i+1] = p.getChar({args={ game, char, size }}) i = i+1 until( i > #word ) t[i+1] = ' ' --https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#table.concat return table.concat(t," ") end

--should return the first arg when #invoked function p.func( frame ) return frame.args[1] end

--should return something when #invoked function p.funcDriver( frame ) --nope--local f.args[1] = "something"

--local f = {} --f.args = {} --f.args[1] = "something"

--local f = {} --f.args = { "something" }

--return p.func( { args = { "something" } } )

---local f = { args = {  } } local f = { args = { "something" } } return p.func( f ) end

--like Template:HylianALBW/Letter function p.getChar( frame ) local game = frame.args[1] local char = frame.args[2] local size = frame.args[3] char = char:upper --char = string.upper(char) --https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Control_structures --No case-switch in Lua --https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Relational_operators --https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Logical_operators --https://stackoverflow.com/questions/27633331/can-i-check-strings-equality-in-lua#27634079 local letter = char if game == 'SS' then if    char == 'D' or char == 'W' then letter = 'DW' elseif char == 'E' or char == 'K' then letter = 'EK' elseif char == 'O' or char == 'Z' then letter = 'OZ' end elseif game == 'ALBW' then if    char == 'D' or char == 'G' then letter = 'DG' elseif char == 'F' or char == 'R' then letter = 'FR' elseif char == 'J' or char == 'T' then letter = 'JT' elseif char == 'E' or char == 'W' then letter = 'EW' elseif char == 'O' or char == 'Z' then letter = 'OZ' end end local ext = 'png' if game == 'ALBW' then ext = 'svg' end

--https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#Concatenation_operator return ' ' end

--v2 ~ like Template:HylianALBW function p.test( frame ) local game = frame.args[1]:upper local word = frame.args[2]:upper local size = frame.args[3] if size == nil or '' then size = '20' end local dict if game == 'BOTW' or game == 'ALBW' then dict = { D = 'DG', G = 'DG', F = 'FR', R = 'FR', J = 'JT', T = 'JT', E = 'EW', W = 'EW', O = 'OZ', Z = 'OZ', }   elseif game == 'SS' then dict = { D = 'DW', W = 'DW', E = 'EK', K = 'EK', O = 'OZ', Z = 'OZ' }   end local ext = 'png' if game == 'ALBW' then ext = 'svg' end --Will store the string parts to concatenate local t = {} table.insert(t, ' ') local i = 1 repeat local letter = word:sub(i,i) if letter == ' ' then table.insert(t, ' ') table.insert(t, ' ') table.insert(t, ' ') else local glyph = letter if dict[letter] ~= nil then glyph = dict[letter] end table.insert(t, ' ') end i = i+1 until( i > #word ) table.insert(t, ' ') return table.concat(t," ") end

--v3 ~ like Template:HylianALBW function p.test2( frame ) local game = frame.args[1]:upper local word = frame.args[2]:upper local size = frame.args[3] if size == nil or '' then size = '20' end local dict if game == 'OOT' or game == 'MM' then game = 'OoT' dict = { A  = 'A', E  = 'E', I  = 'I', O  = 'O', U  = 'U', KA = 'KA', KI = 'KI', KU = 'KU', KE = 'KE', KO = 'KO', GA = 'KA', GI = 'KI', GU = 'KU', GE = 'KE', GO = 'KO', SA = 'SA', SHI = 'SHI', SU = 'SU', SE = 'SE', SO = 'SO', ZA = 'SA', ZI = 'SHI', ZU = 'SU', ZE = 'SE', ZO = 'SO', TA = 'TA', CHI = 'CHI', TSU = 'TSU', TE = 'TE', TO = 'TO', DA = 'TA', DI = 'CHI', DU = 'TSU', DE = 'TE', DO = 'TO', NA = 'NA', NI = 'NI', NU = 'NU', NE = 'NE', NO = 'NO', HA = 'HA', HI = 'HI', HU = 'HU', HE = 'HE', HO = 'HO', PA = 'HA', PI = 'HI', PU = 'HU', PE = 'HE', PO = 'HO', MA = 'MA', MI = 'MI', MU = 'MU', ME = 'ME', MO = 'MO', YA = 'YA', YU = 'YU', YO = 'YO', RA = 'RA', RI = 'RI', RU = 'RU', RE = 'RE', RO = 'RO', WA = 'WA', WO = 'WO ' }   end local ext = 'png' --Will store the string parts to concatenate local t = {} table.insert(t, ' ') local letter = '' local glyph local next_char local i = 1 repeat letter = letter .. word:sub(i,i) repeat next_char = true if letter == ' ' then table.insert(t, ' ') table.insert(t, ' ') table.insert(t, ' ') letter = '' --elseif letter == 'N' then elseif letter == '.' then glyph = 'Kuten' table.insert(t, ' ') letter = '' elseif letter == ',' then glyph = 'Toten' table.insert(t, ' ') letter = '' elseif dict[letter] ~= nil then glyph = dict[letter] table.insert(t, ' ') letter = '' elseif letter:sub(1,1) == 'N' then glyph = 'N'               table.insert(t, '  ') letter = letter:sub(2) next_char = false elseif #letter >= 3 and letter:sub(2,2) == 'Y' then --Note that `letter` isn't used in the for these glyph = letter:sub(1,1) .. 'I'               table.insert(t, '  ') glyph = 'Y' .. letter:sub(3,3) table.insert(t, ' ') letter = letter:sub(4) next_char = false end until(next_char == true) i = i+1 until( i > #word ) table.insert(t, ' ') return table.concat(t," ") end

return p