Editing Module:HousingTable

From Eco - English Wiki

Your changes will be displayed to readers once an authorized user accepts them. (help)

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 2: Line 2:


local Utils = require('Module:Utils')
local Utils = require('Module:Utils')
local ItemUtils = require('Module:UtilsItemTables')
local L = require('Module:Localization')
local L = require('Module:Localization')


Line 11: Line 10:
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">%s</th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">%s</th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">%s</th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">%s</th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">%s</th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">%s</th>
</tr>]]
local TIER_HEADER = [[<table class="wikitable sortable jquery-tablesorter">
<tr>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">%s</th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">%s</th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">%s</th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending">%s</th>
Line 26: Line 19:
     local ItemData = mw.loadData("Module:ItemData")
     local ItemData = mw.loadData("Module:ItemData")


     local returnStr = string.format(HEADER, L.t('Item'), L.t('Room'), L.t('Type'), L.t('Value'), L.t('Dim. Return %'), L.t('Dimensions (X,Y,Z)'))
     local returnStr = string.format(HEADER, L.t('Item'), L.t('Room'), L.t('Type'), L.t('Value'), L.t('Dim. Return %'), L.t('Dimensions'))


     local items = {}
     local items = {}
Line 39: Line 32:


     for _, item in pairs(items) do
     for _, item in pairs(items) do
         returnStr = returnStr .. '<tr><td>[[' .. item.item .. ']]</td><td>' .. item.room .. '</td><td>' .. item.type .. '</td><td>' .. item.value .. '</td><td>' .. item.depreciation * 100 .. '%</td><td>' .. ItemUtils.formatFootprintDimensions(item.dimensions) .. '</td></tr>'
         returnStr = returnStr .. '<tr><td>[[' .. item.item .. ']]</td><td>' .. item.room .. '</td><td>' .. item.type .. '</td><td>' .. item.value .. '</td><td>' .. item.depreciation .. '</td><td>' .. item.dimensions .. '</td></tr>'
     end
     end


     return returnStr .. '</table>'
     return returnStr .. '</table>'


end
function p.blockTiers(frame)
    local args = Utils.normaliseArgs(frame)
    local ItemData = mw.loadData("Module:ItemData")
    local returnStr = string.format(TIER_HEADER, L.t('Block'), L.t('Tier'))
    local items = {}
    for itemName, item in pairs(ItemData.items) do
        if item.group == 'Blocks' and item.materialTier ~= nil then
            table.insert(items, { item = itemName, tier = item.materialTier })
        end
    end
    table.sort(items, compareTiers)
    for _, item in pairs(items) do
        returnStr = returnStr .. '<tr><td>[[' .. item.item .. ']]</td><td>' .. item.tier .. '</td></tr>'
    end
    return returnStr .. '</table>'
end
end


Line 79: Line 48:
     else
     else
         return a.room < b.room
         return a.room < b.room
    end
end
function compareTiers(a, b)
    if a.tier == b.tier then
        return a.item < b.item
    else
        return a.tier < b.tier
     end
     end
end
end


return p
return p
Please note that all contributions to Eco - English Wiki are considered to be released under the CC BY-NC-SA 4.0 (see Eco:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following hCaptcha:

Cancel Editing help (opens in new window)

Template used on this page: