Module:Difficulty 1

local p = {} local function _getLevel( pageName, version ) if not pageName or pageName == '' then return false end -- Setup local level = pageName:match('^Level (%d+)') if not level then return false end local isDreamworld = pageName:match('/Dreamworld') -- Get difficulty for the page local data = mw.loadData( 'Module:Difficulty 1/' .. ( isDreamworld and 'Dreamworld' or 'Reality' ) ) local myDifficulty = data[tonumber(level)] if not myDifficulty then return false end -- Parse difficulty if type( myDifficulty ) == 'string' then return myDifficulty elseif version == 'Facebook' then return myDifficulty[1] elseif version == 'Mobile' then return myDifficulty[2] else return mw.getCurrentFrame:preprocess('\n\n') end end function p.getLevel( frame ) local a = frame.args local pageName = mw.title.getCurrentTitle.text local version = a[2] -- can be absent or invalid --if not pageName then return 'getCurrentTitle returns nil' end --dbg if a[1] and not (a[1] == '') then pageName = a[1] end return _getLevel(pageName, version) or a.default or 'Undetermined' end return p