Skip to content

OnPlayerCraft

The player started a crafting station - the alchemy table, the anvil or the grindstone.

station is "alchemy" (the alchemy table), "smithing" (the anvil) or "sharpening" (the grindstone - class is the weapon the player chose to sharpen; "" for the others). For a station named with SetCraftCheck this comes before the station starts: the player’s game waits for the answer, and false keeps the station from starting - nothing is used, no ingredient and no time. Without SetCraftCheck it comes after the start and its answer changes nothing.

What a station makes is the game’s own work: a potion, a sword, a horseshoe reach OnPlayerNativeItem as the player’s game makes them (craft for the alchemy table, unmapped for the anvil), where the mode adopts them or has them removed; a forged item’s quality is in GetPlayerInventory (quality) once the player’s game has said it, and OnPlayerInventoryChange follows - save it there; the grindstone’s sharpening is a mend (OnPlayerItemWear). The repair kits (the sewing kit too) are no station: a kit’s repair comes to OnPlayerItemWear as the item’s mend and the kit’s spent charge.

function OnPlayerCraft(pid, station, class)
-- ...
end
Parameter Type
pid number the player
station string "alchemy", "smithing" or "sharpening"
class string the weapon’s class GUID at the grindstone, "" otherwise

false keeps a checked station from starting; anything else lets it start

-- only the guild's members work the anvil
function OnGameModeInit() SetCraftCheck("smithing", true) end
function OnPlayerCraft(pid, station, class)
if station == "smithing" and not smiths[pid] then
ShowNotification(pid, "The smith does not let you near his anvil.")
return false
end
end

SetCraftCheck · OnPlayerNativeItem · OnPlayerItemWear · OnPlayerUseItem · the Items and inventory group of the index