From a40599dfce18828270ebf7e50a197da9b9bb744a Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Sat, 24 May 2014 19:58:20 -0400 Subject: [PATCH] Update API doc to match changes in the code DEPRECATED: Don't use strings to pass function names to the mapgen code, use an actual function call i.e. my_code(pos) instead. --- API.txt | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/API.txt b/API.txt index 8be6690..02adc79 100644 --- a/API.txt +++ b/API.txt @@ -1,6 +1,6 @@ -This document describes the Plantlife API. +This document describes the Plantlife mod API. -Last revision: 2013-01-30 +Last revision: 2014-05-24 ========= @@ -18,9 +18,9 @@ desired, but they are not really intended for use by other mods and may change at any time. They are briefly described below these main functions, but see init.lua for details. -All functions in plants lib are declared locally to avoid namespace collisions -with other mods. They are accessible via the "plantslib" method, e.g. -plantslib:spawn_on_surfaces() and so forth. +Most functions in plants lib are declared locally to avoid namespace +collisions with other mods. They are accessible via the "plantslib" method, +e.g. plantslib:spawn_on_surfaces() and so forth. ===== spawn_on_surfaces(biome) @@ -337,20 +337,21 @@ biome = { Regarding node_or_function_or_treedef, this must either be table with an L-Systems tree definition, or a string with a node or function name. -If you specified a string, the code will attempt to determine, as needed, -whether that string specifies a node name. If it does, that node will be -placed on top of the target position directly. - -If it wasn't a node, the code will assume you meant to specify a function -name, in which case that function will be passed a single position parameter -(in the usual table format), indicating where the named function should place -the object. It is called in the form of "somefunction(pos)", and behaves much -like a typical callback. +If you specified a string, the code will attempt to determine whether that +string specifies a valid node name. If it does, that node will be placed on +top of the target position directly (unless one of the other mapgen options +directs the code to do otherwise). If you specified a table, the code assumes this table contains an L-Systems tree definition, then that definition will be passed directly to the spawn_tree() function along with the position to spawn the tree on. +You can also supply a function to be directly executed, which is given the +current node position (the usual "pos" table format) as its sole argument. It +will be called in the form: + + somefunction(pos) + ===== plantslib:grow_plants(options)