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

return p