From b2a291fc4a24a4287a6befa5b7f03a2d1c1c8974 Mon Sep 17 00:00:00 2001 From: aegroto Date: Thu, 31 Aug 2023 00:05:19 +0200 Subject: [PATCH] added documentation --- game_api.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/game_api.txt b/game_api.txt index a2e9c646..c68463f5 100644 --- a/game_api.txt +++ b/game_api.txt @@ -1028,6 +1028,28 @@ Trees * `default.grow_blueberry_bush(pos)` * Grows a blueberry bush at pos + * `default.on_grow_failed(pos)` + * Reset the node timer to 300 seconds, used as default callback when the growth of a sapling fails + + * `default.sapling_growth_defs` + * Table that contains all the definitions for the growable saplings, see `default.register_sapling_growth` + + * `default.register_sapling_growth(name, def)` + * Register a new sapling growth configuration. Useful to add custom sapling and trees to the game in a compact way. + default.register_sapling_growth( + "default:sapling", -- Name of the sapling + { + can_grow = default.can_grow, -- Function called to determine whether the sapling can grow, should return a boolean + on_grow_failed = default.on_grow_failed, -- Function called when the growth fails + grow_callback = function(pos) -- Function called when the growth has success. Conventionally, this should replace the sapling with a tree + default.grow_tree(pos, random(1, 4) == 1) + end + } + ) + * default.grow_sapling(pos) + * Attempt to grow a sapling at the given position. Useful as on_timer callback. + + Carts -----