Skip to content

craft

The crafts of data/crafts: their groups and recipes, and the resource lists they use.

Source: src/Moongate.Server.Ultima/Modules/CraftModule.cs

craft.get(id) -> table?

The craft of that id as { id, name, skill, sound, groups }: groups is an array of { name, recipes }, a recipe { name, item, graphic, skill_min, skill_max, resources, skills, spell, mana }, resources an array of { resource, amount } (a list of craft.resource or an item template) and skills an array of { skill, min, max } besides the craft's own. graphic is the item's graphic, 0 when its template has none; spell is the key of the spell a recipe asks the crafter to have in a book it carries (empty for none) and mana what a try takes (0 for none). Nil for an unknown id.

A sign that lists the groups of carpentry and how many recipes each holds:

function carpentry_sign.on_use(serial, user)
local carpentry = craft.get("carpentry")
for _, group in ipairs(carpentry.groups) do
mobile.message(user, group.name .. ": " .. #group.recipes .. " recipes")
end
return true
end
ParameterTypeDefault
idstring

Returns table?.

craft.made(actor, craft, item)

Raises the craft_succeeded event for the scripts that listen to it: the crafter's serial, the id of the craft and the serial of the item it made. Called by common/crafting.lua once a craft succeeded; it changes nothing else.

ParameterTypeDefault
actorinteger
craftstring
iteminteger
craft.resource(id) -> table?

The item templates that count for a resource list of data/crafts/resources.toml, such as 'wood', as an array of ids. Nil for an unknown list.

Whether a player carries any of the plain boards carpentry takes:

local function has_wood(user)
for _, template in ipairs(craft.resource("wood") or {}) do
if #item.find(user, template) > 0 then
return true
end
end
return false
end
ParameterTypeDefault
idstring

Returns table?.

Made with ❤️ by Tom

Buy me a coffee