Wynncraft Wiki
Advertisement

Documentation for this module may be created at Module:GetCargoField/doc

local p = {}
local cargo = mw.ext.cargo

function p.Main( frame )
    local tables = frame.args.cargoTable
    local fields = frame.args.cargoTable .. "." .. frame.args.getField
    local args = {
        where = frame.args.cargoTable .. "." .. frame.args.lookupField .. "='" .. frame.args.lookup:gsub("'", "\\\'")  .. "'"
    }
    local results = cargo.query( tables, fields, args )
    if #results >= 1 then
        return results[1][fields]
    end
    return frame.args.default or ""
end

return p
Advertisement