Skip to content

OnPlayerLearnRecipe

The player’s game taught them a recipe - save it, or return false to take it away again.

Called when a player’s character learned an alchemy or blacksmithing recipe in their game - they read a recipe document, or the game taught one its own way - a moment after it happened. recipe is the recipe’s key, kind is "alchemy" or "smithing".

Return false and the recipe is taken away again: the book forgets it (the document stays read). Anything else keeps it.

Not called for the mode’s own GivePlayerRecipe and SetPlayerRecipes, nor for the recipes the character already knew when the player joined.

function OnPlayerLearnRecipe(pid, recipe, kind)
-- ...
end
Parameter Type
pid number the player
recipe string the recipe’s key, "alchemy:1"
kind string "alchemy" or "smithing"

false takes the recipe away again; anything else keeps it

function OnPlayerLearnRecipe(pid, recipe, kind)
local info = GetRecipeInfo(recipe)
SendClientMessage(pid, COLOR_WHITE, "You learned the recipe for " .. info.name .. ".")
saveRecipes(pid) -- GetPlayerRecipes into the mode's database
end

GetPlayerRecipes · SetPlayerRecipes · GivePlayerRecipe · the Recipes group of the index