Module:CustomScript

From adia project
Jump to navigation Jump to search

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

--Conworlds Wiki Custom Language Conversion
--http://conworld.wikia.com/
--Initial wikitext implementation by User:Flaicher
--Lua conversion by User:ChickenBar
--Modified for Conworlds Wiki by User:Vivaporius

local p = {}

local CharData = mw.loadData( 'Module:CustomScript/data' )

function p._kahu( humanwords, size )
    local output_string = {}
    local humanwords = string.lower(humanwords)
    local span = mw.html.create( 'span' )
    if (size == nil or size == '') then size='15' end
    for i=1, string.len(humanwords) do
        local replacement = CharData["kahuChar"][humanwords:sub(i,i)]
        if replacement ~= nil then
            table.insert(output_string,'[[File:'..replacement..'|x'..size..'px|link=]]')
        else
            table.insert(output_string,'  ')
        end
    end
    span    :css( 'font-size', size..'px' )
            :wikitext( table.concat(output_string) )
    return tostring(span)
end

function p.kahu( frame )
    local string_input = frame.args[1]
    local num_input = frame.args[2]
    return p._kahu(string_input, num_input)
    
end

function p._napurai( humanwords, size )
    local output_string = {}
    local humanwords = string.lower(humanwords)
    local span = mw.html.create( 'span' )
    if (size == nil or size == '') then size='14' end
    for i=1, string.len(humanwords) do
        local replacement = CharData["napuraiChar"][humanwords:sub(i,i)]
        if replacement ~= nil then
            table.insert(output_string,'[[File:'..replacement..'|x'..size..'px|link=]]')
        else
            table.insert(output_string,'  ')
        end
    end
    span    :css( 'font-size', size..'px' )
            :wikitext( table.concat(output_string) )
    return tostring(span)
end

function p.napurai( frame )
    local string_input = frame.args[1]
    local num_input = frame.args[2]
    return p._napurai(string_input, num_input)
    
end

return p