Changes

no edit summary
Line 132: Line 132:  
             end
 
             end
 
         else
 
         else
             return obj.icon and ([[<span data-sort-value="]] .. (obj._type or '0') .. [=[">[[File:]=] .. Formatting:format_equipment_icon(obj:icon()) .. "]]</span>") or ''
+
        return obj.icon and ([=[[[File:]=] .. Formatting:format_equipment_icon(obj:icon()) .. "]]") or ''
 +
             -- return obj.icon and ([[<span data-sort-value="]] .. (obj._type or '0') .. [=[">[[File:]=] .. Formatting:format_equipment_icon(obj:icon()) .. "]]</span>") or ''
 
         end
 
         end
 
     end,
 
     end,
Line 187: Line 188:  
         end
 
         end
 
     end,
 
     end,
     scrap = function(eq)
+
     scrap_string = function(eq)
 
         local scrap = eq:scrap()
 
         local scrap = eq:scrap()
 
         return string.format("%s/%s/%s/%s", scrap.fuel or 0, scrap.ammo or 0, scrap.steel or 0, scrap.bauxite or 0)
 
         return string.format("%s/%s/%s/%s", scrap.fuel or 0, scrap.ammo or 0, scrap.steel or 0, scrap.bauxite or 0)
Line 230: Line 231:     
local function format_value(key, ship, target)
 
local function format_value(key, ship, target)
    local formatting_function = formatting_functions[key]
+
local keys = mw.text.split(key, "%s*%.%s*")
    if formatting_function then
+
local result = ship
        return formatting_function(ship, target)
+
for _, key in ipairs(keys) do
    end
+
    local formatting_function = formatting_functions[key]
    --[[
+
    if formatting_function then
    if shipCapabilities[key] then
+
        result = formatting_function(result, target)
        local a, b = shipCapabilities[key](shipCapabilities)
+
    else
        return format_lua(b or a)
+
    local lua = result[key] or result['_' .. key]
    end
+
    if type(lua) == "function" then
    ]]--
+
        result = lua(result)
    local lua = ship[key]
+
    else
    if type(lua) == "function" then
+
        result = lua
        return format_lua(lua(ship))
+
    end
    else
+
    end
        return format_lua(lua)
+
if type(result) ~= 'table' then
    end
+
return format_lua(result)
 +
end
 +
    --[[
 +
    if shipCapabilities[key] then
 +
        local a, b = shipCapabilities[key](shipCapabilities)
 +
        return format_lua(b or a)
 +
    end
 +
    ]]--
 +
end
 +
return format_lua(result)
 
end
 
end
   Line 449: Line 459:  
sequence_length = #sequence
 
sequence_length = #sequence
 
        end
 
        end
 +
    elseif prefix == '!' then
 +
    local name = string.sub(arg, 2)
 +
    local obj = Ship(name)
 +
    if not obj:hp() then
 +
    equipment = true
 +
    obj = Equipment(name)
 +
    end
 +
    sequence = {}
 +
    table.insert(sequence, obj)
 +
        sequence_position = 1
 +
sequence_length = 1
 
    elseif arg == "#" or prefix == "?" then
 
    elseif arg == "#" or prefix == "?" then
 
    table.insert(actions, string.sub(arg, 2))
 
    table.insert(actions, string.sub(arg, 2))
Line 459: Line 480:  
   local x = a[sort](a)
 
   local x = a[sort](a)
 
   local y = b[sort](b)
 
   local y = b[sort](b)
 +
  if x == nil then return true end
 +
  if y == nil then return false end
 
   if x < y then return true end
 
   if x < y then return true end
 
   if x > y then return false end
 
   if x > y then return false end
Line 490: Line 513:  
mw.log(interpret({"@base_names", "~is_battleship~true", "?link", sort = "type,id"}))
 
mw.log(interpret({"@base_names", "~is_battleship~true", "?link", sort = "type,id"}))
 
mw.log(interpret({"@base_names", "~class.name~Kagerou Class", "?link", sort = "type,id"}))
 
mw.log(interpret({"@base_names", "~class.name~Kagerou Class", "?link", sort = "type,id"}))
 +
mw.log(interpret({"!Saiun", "?icon"}))
 +
mw.log(interpret({"!Ayanami", "?scrap_string", "?scrap.fuel", "?scrap_fuel", "?_scrap_fuel"}))
 
end
 
end
    +
-- print(p.test())
 
return {
 
return {
 
format = function(frame) return interpret(U.getTemplateArgs(frame).explicit) end,
 
format = function(frame) return interpret(U.getTemplateArgs(frame).explicit) end,
 
test = test,
 
test = test,
 
}
 
}
cssedit, gkautomate
7,064

edits