From b7a98e98500402c3bbdb6d56d0fe42b4f5b3cedb Mon Sep 17 00:00:00 2001
From: Loïc Blot <nerzhul@users.noreply.github.com>
Date: Fri, 27 Jan 2017 08:59:30 +0100
Subject: Implement player attribute backend (#4155)

* This backend permit mods to store extra players attributes to a common interface.
* Add the obj:set_attribute(attr, value) Lua call
* Add the obj:get_attribute(attr) Lua call

Examples:
* player:set_attribute("home:home", "10,25,-78")
* player:get_attribute("default:mana")

Attributes are saved as a json in the player file in extended_attributes
key

They are saved only if a modification on the attributes occurs and loaded
when emergePlayer is called (they are attached to PlayerSAO).
---
 doc/lua_api.txt | 2 ++
 1 file changed, 2 insertions(+)

(limited to 'doc')

diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index 62a7b81f7..ee7d57c2f 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -2899,6 +2899,8 @@ This is basically a reference to a C++ `ServerActiveObject`
         * `0`: player is drowning,
         * `1`-`10`: remaining number of bubbles
         * `11`: bubbles bar is not shown
+* `set_attribute(attribute, value)`: sets an extra attribute with value on player
+* `get_attribute(attribute)`: returns value for extra attribute. Returns nil if no attribute found.
 * `set_inventory_formspec(formspec)`
     * Redefine player's inventory form
     * Should usually be called in on_joinplayer
-- 
cgit v1.2.3