Fire Emblem Heroes Wiki
Fire Emblem Heroes Wiki
Template-info.svg Documentation
For Cargo-related utility functions that can be used in other Lua scripts, see Module:CargoUtil.

Lua module to perform certain Cargo actions. If nothing breaks using Cargo's parser functions such as #cargo_query, chances are your code does not need to use this module at all.

The functions in this module are designed to be invoked directly from wikitext.


Performs a Cargo query on one field, and returns a single result. There are two known situations where the standard #cargo_query will fail:

  • The fields parameter is too long.
  • The query returns wikitext that may be stored into Cargo tables.

This function should behave as if #cargo_query is called with the extra arguments limit=1, more results text=, format=list, and no html, except returned wikitext is not immediately expanded. This allows any wikitext generated from the fields argument to be preserved.


  • tables, join on, where, group by, having, order by, offset
Correspond to #cargo_query's parameters of the same name.
  • fields
The single field to query. The function does not check if more than one field is specified.
  • default
The string value to return if the query returns no results. If omitted, returns the empty string.
  • warn
Warning text to display when previewing an edit when no result is returned from the query.
local query1 = function (frame)
	local args = require 'Module:Arguments'.getArgs(frame)
	local result = mw.ext.cargo.query(args.tables, args.fields or '_pageName', {
		join = args['join on'],
		where = args.where,
		groupBy = args['group by'],
		having = args.having,
		orderBy = args['order by'],
		limit = 1,
		offset = args.offset,
	result = result and frame:preprocess(select(2, next(result)))
	if result then
		return result
		mw.addWarning(args.warn or string.format('No result for query with parameters: <code>%s</code>', mw.text.nowiki(
			string.format('tables=%s,fields=%s,join=%s,where=%s,groupBy=%s,having=%s,orderBy=%s,limit=1,offset=%s',args.tables or '', args.fields or '',args['join on'] or '',args.where or '',args['group by'] or '',args.having or '',args['order by'] or '',args.offset or '')
		return args.default or ''

return {query1 = query1}