a little bit of documentation

master
A. Demant 2019-02-12 08:05:46 +01:00
parent c094593eef
commit f111e82b6a
2 changed files with 19 additions and 1 deletions

View File

@ -17,18 +17,24 @@ XPFW provide an API for storing values relevant for experience mechanism into pl
For several amounts also a kind of speed is calculated, like walking speed or crafting speed.
Following chat commands are available:
/xpfw
prints stored values of XPFW in the chat window
/xphud
toggle the visible statistics in players hud on/off
/xpreset
set all values to default
/xpset <variable> <value>
need xpfwset privilege
Set variable of user to new value
Usage (roughly):
xpfw.register_attribute(name,data) to register new attribute <name>
- xpfw.register_attribute(name,data) to register new attribute <name>
- xpfw.player_get_attribute(player,name) Get stored value of attribute <name> for ObjectRef player
Authors of source code
----------------------

12
api.lua
View File

@ -80,10 +80,22 @@ xpfw.player_sub_attribute=function(player,attrib,val)
end
xpfw.player_get_attribute=function(player,attrib)
--[[
Get stored attribute (or 0) for specified player:
- player : ObjectRef to player
- attrib : name of attribute
]]
local pm=player:get_meta()
return pm:get_float(xpfw.prefix.."_"..attrib) or 0
end
xpfw.player_set_attribute=function(player,attrib,val)
--[[
Set stored attribute (or 0) for specified player:
- player : ObjectRef to player
- attrib : name of attribute
- val : Value to store
]]
local pm=player:get_meta()
local playername=player:get_player_name()
local att_def=M.player[playername].attributes[attrib]