summaryrefslogtreecommitdiff
path: root/doc/lua_api.txt
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2020-02-13 19:44:38 +0100
committersfan5 <sfan5@live.de>2020-02-23 22:24:12 +0100
commit6be7150cd5c18869911bcba8e5833155521d2780 (patch)
tree84e24466cc38d2dd345920df5194918b3c28a353 /doc/lua_api.txt
parent217f3a42f48f729f0977338bdfaa1be019fe76e9 (diff)
downloadminetest-6be7150cd5c18869911bcba8e5833155521d2780.tar.gz
minetest-6be7150cd5c18869911bcba8e5833155521d2780.tar.bz2
minetest-6be7150cd5c18869911bcba8e5833155521d2780.zip
Documementation: Add advice on lifetime of ObjectRefs
Diffstat (limited to 'doc/lua_api.txt')
-rw-r--r--doc/lua_api.txt15
1 files changed, 14 insertions, 1 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index b87353b6a..75ad07cad 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -5706,8 +5706,21 @@ Can be gotten via `minetest.get_node_timer(pos)`.
-----------
Moving things in the game are generally these.
+This is basically a reference to a C++ `ServerActiveObject`.
+
+### Advice on handling `ObjectRefs`
+
+When you receive an `ObjectRef` as a callback argument or from another API
+function, it is possible to store the reference somewhere and keep it around.
+It will keep functioning until the object is unloaded or removed.
+
+However, doing this is **NOT** recommended as there is (intentionally) no method
+to test if a previously acquired `ObjectRef` is still valid.
+Instead, `ObjectRefs` should be "let go" of as soon as control is returned from
+Lua back to the engine.
+Doing so is much less error-prone and you will never need to wonder if the
+object you are working with still exists.
-This is basically a reference to a C++ `ServerActiveObject`
### Methods