The Wiki for Tale 8 is in read-only mode and is available for archival and reference purposes only. Please visit the current Tale 11 Wiki in the meantime.

If you have any issues with this Wiki, please post in #wiki-editing on Discord or contact Brad in-game.

Module:Infobox

From A Wiki in the Desert
Jump to navigation Jump to search

local p = {}

function p.start( frame ) template = frame:getParent()

infobox = '

\n' infobox = infobox .. '\n' infobox = infobox .. '\n' infobox = infobox .. '\n' if (notempty(template.args["image"])) then infobox = infobox .. '\n' infobox = infobox .. '\n' infobox = infobox .. '\n' end if (notempty(template.args["ibtype"])) then infobox = infobox .. '\n' infobox = infobox .. '\n' infobox = infobox .. '' end return infobox end function p.row( frame ) infobox = '\n' infobox = infobox .. '\n' infobox = infobox .. '\n' infobox = infobox .. '\n' infobox = infobox .. '\n' infobox = infobox .. '\n' ----- infobox = '\n' infobox = infobox .. '\n' infobox = infobox .. '\n' ----- return infobox end function p.stacked( frame ) infobox = '\n' infobox = infobox .. '\n' infobox = infobox .. '\n' infobox = infobox .. '\n' infobox = infobox .. '\n' infobox = infobox .. '\n' return infobox end function p.tabulated( frame ) -- Using "tabulated" because the word "table" is a reserved word in Lua... :( template = frame:getParent() infobox = '\n' infobox = infobox .. '\n' infobox = infobox .. '\n' return infobox end function p.finish( frame ) infobox = '
'

infobox = infobox .. template.args["ibname"] ..

infobox = infobox .. '
'

infobox = infobox .. '[[File:' .. template.args["image"] .. '|250px|' .. template.args["ibname"] .. ']]'

infobox = infobox .. '
'

infobox = infobox .. '(' .. template.args["ibtype"] .. ')'

infobox = infobox .. '
' .. frame.args[1] .. '
' .. frame.args[2] .. '
\n' infobox = infobox .. '' ----- infobox = infobox .. '\n' infobox = infobox .. '\n' infobox = infobox .. '\n' infobox = infobox .. '\n' ----- infobox = infobox .. '
' .. frame.args[1] .. '' .. frame.args[2] .. '
\n' infobox = infobox .. '
' .. frame.args[1] .. '
' .. frame.args[2] .. '
\n' infobox = infobox .. '' infobox = infobox .. '\n' infobox = infobox .. '\n' infobox = infobox .. '\n' colOne = {} colTwo = {} for k, v in pairs( template.args ) do if (string.find(k, frame.args[2], 1, true)) then key = string.sub(k, (#frame.args[2]+1)) colOne[key] = v end end for k, v in pairs( template.args ) do if (string.find(k, frame.args[3], 1, true)) then key = string.sub(k, (string.len(frame.args[3])+1)) colTwo[key] = v end end myTable = {} for k, v in pairs( colOne ) do myTable[v] = tonumber(colTwo[k]) end for k,v in spairs(myTable, function(t,a,b) return t[b] < t[a] end) do infobox = infobox .. '\n' infobox = infobox .. '\n' infobox = infobox .. '\n' infobox = infobox .. '\n' end infobox = infobox .. '
' .. frame.args[1] .. '
' .. k .. '' .. comma_value(v) .. '
\n' infobox = infobox .. '

\n'

return infobox end

function notempty( variable ) if (variable and #variable > 0) then return true else return false end end

function spairs(t, order)

   local keys = {}
   for k in pairs(t) do keys[#keys+1] = k end
   if order then
       table.sort(keys, function(a,b) return order(t, a, b) end)
   else
       table.sort(keys)
   end
   local i = 0
   return function()
       i = i + 1
       if keys[i] then
           return keys[i], t[keys[i]]
       end
   end

end

function comma_value(amount) local formatted = amount while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end end return formatted end

return p