Project Zomboid Lua Docs 29123
Unofficial documentation for Project Zomboid's Lua
Loading...
Searching...
No Matches
Callbacks

umbrella.CraftRecipe_OnCreate

Called when successfully crafting the recipe.

Parameters

Name Type Notes
recipeData CraftRecipeData
character IsoGameCharacter or
nil
Character crafting the recipe. Recipes crafted by a workstation wil pass nil.

umbrella.CraftRecipe_OnFailed

Called when failing to craft the recipe, either because it was cancelled or the conditions are no longer met.

Parameters

Name Type Notes
recipeData CraftRecipeData

umbrella.CraftRecipe_OnStart

Called at the start of crafting the recipe. For recipes crafted in hand or build recipes, called immediately before finishing the recipe. For recipes crafted by crafting stations, called when a character initiates the crafting.

Parameters

Name Type Notes
recipeData CraftRecipeData
character IsoGameCharacter or
nil
Character crafting the recipe. Recipes crafted by a workstation will pass nil.

umbrella.CraftRecipe_OnTest

Determines whether an item can be used in the recipe.

Parameters

Name Type Notes
item InventoryItem Item to test.

Returns

Name Type Notes
test boolean Whether to allow the item in the recipe.

umbrella.CraftRecipe_OnUpdate

Called every tick while crafting the recipe.

Parameters

Name Type Notes
recipeData CraftRecipeData

umbrella.ItemContainer_Comparator

Used by the getBest methods in ItemContainer. These methods will sort all matches using this function, and return the item in first place.

Parameters

Name Type Notes
a InventoryItem The first item being tested.
b InventoryItem The second item being tested.

Returns

Name Type Notes
number This should be positive if a should be prioritised over b, and negative if b should be prioritised.

umbrella.ItemContainer_Predicate

Used by the -Eval methods in ItemContainer. These methods will only consider items that this function returns true for.

Parameters

Name Type Notes
item InventoryItem The item being tested.

Returns

Name Type Notes
allowItem boolean Whether the item is a valid match.

umbrella.Item_AcceptItemFunction

Called when checking if an item is allowed inside a container with this function assigned. The container's OnlyAcceptCategory will be checked first if it has one.

Parameters

Name Type Notes
container ItemContainer The container the item is being added to
item InventoryItem The item being added to the container

Returns

Name Type Notes
acceptItem boolean Whether to allow the item in the container

umbrella.Item_OnCooked

Called when the item is cooked. Not called if the item has a ReplaceOnCooked as the item is destroyed. OnCooked functions cannot be inside tables or the game will not find them.

Parameters

Name Type Notes
item InventoryItem The item being cooked

umbrella.Item_OnCreate

Called when the item is first created, before it is placed into its container. Generally used to initialise items.

Parameters

Name Type Notes
item InventoryItem The item being created

umbrella.Item_OnEat

Called when a player eats the item. Called on the client eating the item only.

Parameters

Name Type Notes
item InventoryItem The item being eaten
character IsoGameCharacter The character eating the item
amount number The fraction of the item that was eaten.

umbrella.Recipe_GetItemTypes

Called by the recipe manager for every recipe source after the lua/server/ folder loads. The ArrayList should be filled with Item objects to include as part of the recipe source.

Parameters

Name Type Notes
outItems ArrayList<Item> An empty ArrayList to be filled with items.

umbrella.Recipe_OnCanPerform

Called when checking if a character is able to perform the recipe - before showing the option to craft it, and every tick during crafting.

Parameters

Name Type Notes
recipe Recipe The recipe being checked
character IsoGameCharacter The character the recipe is being checked for
item InventoryItem or
nil
The item the player right clicked to see this recipe. Null when checking whether to show the recipe in the crafting menu, but will be checked with the item set during crafting.

Returns

Name Type Notes
canPerform boolean Whether to allow the character to craft the recipe

umbrella.Recipe_OnCreate

Called after crafting the recipe.

Parameters

Name Type Notes
sources ArrayList<InventoryItem> The items used to craft the recipe
result InventoryItem The item crafted by the recipe. Passed even if RemoveResultItem is set
character IsoGameCharacter The character who crafted the recipe
item InventoryItem The item used in the crafting action. This is either the item that was right clicked to start the crafting, or the first source item if it was crafted from the recipe menu.
isPrimaryHandItem boolean True if item is equipped in the player's primary hand
isSecondaryHandItem boolean True if item is equipped in the player's secondary hand

umbrella.Recipe_OnGiveXP

Called after crafting the recipe.

Parameters

Name Type Notes
recipe Recipe The recipe that was crafted
sources ArrayList<InventoryItem> The items used to craft the recipe
result InventoryItem The item crafted by the recipe. Passed even if RemoveResultItem is set
character IsoGameCharacter The character who crafted the recipe

umbrella.Recipe_OnTest

Called when checking if an item is allowed to be used in a recipe.

Parameters

Name Type Notes
item InventoryItem The item being checked
result Recipe.Result The result of the recipe

Returns

Name Type Notes
test boolean Whether to allow the item into the recipe

umbrella.VehiclePart_Install_complete

Called after the part is successfully installed.

Parameters

Name Type Notes
vehicle BaseVehicle The vehicle the part belongs to
part VehiclePart The part that was installed

umbrella.VehiclePart_Install_test

Called when testing if the part can be installed.

Parameters

Name Type Notes
vehicle BaseVehicle The vehicle the part belongs to
part VehiclePart The part being tested
character IsoGameCharacter The character using the part

Returns

Name Type Notes
test boolean Whether the part can be installed

umbrella.VehiclePart_Uninstall_complete

Called after the part is successfully uninstalled.

Parameters

Name Type Notes
vehicle BaseVehicle The vehicle the part belongs to
part VehiclePart The part that was uninstalled
item InventoryItem The item that was removed

umbrella.VehiclePart_Uninstall_test

Called when testing if the part can be uninstalled.

Parameters

Name Type Notes
vehicle BaseVehicle The vehicle the part belongs to
part VehiclePart The part being tested
character IsoGameCharacter The character using the part

Returns

Name Type Notes
test boolean Whether the part can be uninstalled

umbrella.VehiclePart_checkEngine

Called every tick while the engine is running. If any part returns false the engine will immediately shut off.

Parameters

Name Type Notes
vehicle BaseVehicle The vehicle the part belongs to
part VehiclePart The part being checked

Returns

Name Type Notes
working boolean Whether the engine should be working

umbrella.VehiclePart_checkOperate

Called every tick while a player is in the driver's seat and able to drive. If any part returns false the player will not be able to control the vehicle.

Parameters

Name Type Notes
vehicle BaseVehicle The vehicle the part belongs to
part VehiclePart The part being checked

Returns

Name Type Notes
operable boolean Whether the vehicle is operable

umbrella.VehiclePart_create

Called when the part is spawned for the first time.

Parameters

Name Type Notes
vehicle BaseVehicle The vehicle the part belongs to
part VehiclePart The part being created

umbrella.VehiclePart_init

Called every time the part loads in or is reset.

Parameters

Name Type Notes
vehicle BaseVehicle The vehicle the part belongs to
part VehiclePart The part being initialised

umbrella.VehiclePart_update

Called regularly to update the part, targeting a rate of every half an in-game minute (1.25 seconds on 1 hour days).

Parameters

Name Type Notes
vehicle BaseVehicle The vehicle the part belongs to
part VehiclePart The part being updated
deltaMinutes number The number of minutes since the last update

umbrella.VehiclePart_use

Called when a character interacts with the vehicle while in the part's area.

Parameters

Name Type Notes
vehicle BaseVehicle The vehicle the part belongs to
part VehiclePart The part being used
character IsoGameCharacter The character using the part