Changes

another item attempt. doesn't work. revert if needed.
Line 10: Line 10:  
local EquipmentGraphicKai = require("Module:EquipmentGraphicKai")
 
local EquipmentGraphicKai = require("Module:EquipmentGraphicKai")
 
local EquipmentCollection = require("Module:Data/Equipment")
 
local EquipmentCollection = require("Module:Data/Equipment")
 +
local ItemCollection = require('Module:Collection/Items')
 
-- local AllEquipmentCollection = require("Module:Collection/EquipmentByApiId")
 
-- local AllEquipmentCollection = require("Module:Collection/EquipmentByApiId")
 
local Development = require("Module:Development")
 
local Development = require("Module:Development")
Line 49: Line 50:  
     equipment = true
 
     equipment = true
 
     return U.imap(EquipmentCollection, function(e) return e._name end)
 
     return U.imap(EquipmentCollection, function(e) return e._name end)
 +
    end,
 +
    item = function()
 +
    item = true
 +
    return U.imap(ItemCollection, function(e) return e._name end)
 
     end,
 
     end,
 
     --[[
 
     --[[
Line 151: Line 156:  
     card = function(obj)
 
     card = function(obj)
 
     if not obj or not obj.lua_name then
 
     if not obj or not obj.lua_name then
     return ' '
+
     if equipment then --attempted to stop equipment from being filtered out, as equip cards weren't showing up. Don't know if this only works for equip and if I broke the original funtion's intention. This may not work at filtering out errors -chocolatecravinghobo
 +
    else
 +
    return ' '
 +
    end
 
     end
 
     end
 
         if obj.hp then
 
         if obj.hp then
Line 188: Line 196:  
         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 231: Line 239:     
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 404: Line 421:  
        for _, e in ipairs(enumerating_function()) do
 
        for _, e in ipairs(enumerating_function()) do
 
        local ship
 
        local ship
        if equipment then
+
        if equipment or item then
 
        ship = Equipment(e)
 
        ship = Equipment(e)
 
        else
 
        else
Line 419: Line 436:  
if type(g) == 'function' then
 
if type(g) == 'function' then
 
obj = g(obj)
 
obj = g(obj)
 +
if type(obj) == 'nil' then
 +
obj = '??'
 +
break
 +
end
 
elseif type(g) == 'table' then
 
elseif type(g) == 'table' then
 
obj = g
 
obj = g
Line 505: Line 526:  
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({"!Saiun", "?icon"}))
 +
mw.log(interpret({"!Ayanami", "?scrap_string", "?scrap.fuel", "?scrap_fuel", "?_scrap_fuel"}))
 +
mw.log(interpret({'@all_names', '~class.name~Akizuki Class', '?api_id', '?banner', '?link', '?japanese_name', '?code_link', '?class_number', '?firepower_max', '?torpedo_max', '?night_battle_power', '?aa_max', '?asw_max', '?los_max', '?luck', '?hp', '?armor_max', '?evasion_max', '?slots', '?fuel', '?ammo', sort = 'class_number,rarity,api_id'}))
 
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,
 
}
 
}
advmod, cssedit, Interface administrators, janitor, Moderators, prechecked, Widget editors
7,932

edits