Jump to content

Module:Crafting

From The Perfect Tower II
Revision as of 15:38, 20 April 2026 by Exe boss (talk | contribs) (Create module for listing Factory crafting recipes at Factory/Recipes, inspired by Minecraft Wiki's “Module:Crafting”)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Backs {{Crafting}}, which shows a Factory crafting recipe as the game's crafting grid, on Factory/Recipes/Crafting (and Factory/Recipes, which includes it). Inspired by Minecraft Wiki's Module:Crafting.

main(frame) reads the template's arguments and passes them to table in Module:Recipe table, with:

  • uiMethod = "crafting": the grid is drawn by crafting in Module:UI;
  • the 32 input slots A1 to H4 (columns A to H, rows 1 to 4) and the output slot Output.

Each slot takes an item, optionally followed by a comma and a count, such as Circuit Plate [T3]; see Module:Factory slot. The other parameters (cost, showName, head, continue, foot, name, class) are handled by Module:Recipe table and Module:UI. Usage is on Template:Crafting.



-- Used to render Factory crafting recipes
-- Inspired by Minecraft Wiki's [[Module:Crafting]]
require("Module:No globals");

local getArgs = require("Module:Arguments").getArgs;
local recipeTable = require("Module:Recipe table").table;

local p = {};

local inputArgs = {
	"A1", "B1", "C1", "D1", "E1", "F1", "G1", "H1",
	"A2", "B2", "C2", "D2", "E2", "F2", "G2", "H2",
	"A3", "B3", "C3", "D3", "E3", "F3", "G3", "H3",
	"A4", "B4", "C4", "D4", "E4", "F4", "G4", "H4",
};

function p.main(frame)
	local args = getArgs(frame, {
		frameOnly = false,
		wrappers = { "Template:Crafting" },
	});

	return recipeTable(args, {
		uiMethod = "crafting",
		inputArgs = inputArgs,
		outputArgs = { "Output" },
	});
end

return p;