Module:Reality

local p = {} local h = require("Module:HF") local list_of_realities = mw.loadData( 'Module:Disambiguation/Realities' ) local special_names = { "Mojoverse", "Brilliant City", "Otherworld", "Weirdworld", "Unknown Reality", "Unknown" }

function p.test2 local s = '⅓' return tonumber(s) end

function p.test(text) local s = list_of_realities[text] local output = '' if s ~= nil then output = s[3] else return text end return output end

-- separate 'pagename' into name and reality. If reality is not empty, then information about it is returned from 'list_of_realities' function p.lua_get_name_and_reality(pagename) local s_reverse local s_name = pagename local info = {} local s_reality = {} local i   if not h.isempty(pagename) then pagename = string.gsub(pagename,'_',' ') s_reverse = string.reverse(pagename) i = string.find(s_reverse,'( ',1,true)           j = string.find(s_reverse,')',1,true) if not h.isempty(i) then s_name = string.reverse( string.sub(s_reverse, i+2, #s_reverse) ) s_reality = string.reverse( string.sub(s_reverse, j+1, i-1) ) info = p.getRealityInfo({s_reality}) if not h.isempty(info) then s_reality = info else s_reality = '' end end end return s_name, s_reality end

function p.getRealityInfo(frame) local args = getArgs (frame) local reality = args[1] local part = args[2] local info local s2   local s3    local output = '' if not h.isempty(reality) then reality = string.gsub(reality, 'Earth%-', '') info = list_of_realities[reality] if info ~= nil then output = { ['name'] = info[2], ['description'] = info[1], ['type'] = info[3], ['number'] = reality } elseif tonumber(reality) ~= nil or string.match(reality, '^TRN%d+') ~= nil then output = { ['name'] = "Earth-"..reality, ['description'] = "Earth-"..reality, ['type'] = "Comic", ['number'] = reality } --else output = { ['name'] = reality, ['description'] = reality, ['type'] = "Comic" } end end if not h.isempty(part) then part = tonumber(part) if part == 3 then output = output.type elseif part == 2 then output = output.description else output = output.name end end return output end

return p