a little bit of documentation
parent
c094593eef
commit
f111e82b6a
|
@ -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.
|
For several amounts also a kind of speed is calculated, like walking speed or crafting speed.
|
||||||
|
|
||||||
Following chat commands are available:
|
Following chat commands are available:
|
||||||
|
|
||||||
/xpfw
|
/xpfw
|
||||||
prints stored values of XPFW in the chat window
|
prints stored values of XPFW in the chat window
|
||||||
|
|
||||||
/xphud
|
/xphud
|
||||||
toggle the visible statistics in players hud on/off
|
toggle the visible statistics in players hud on/off
|
||||||
|
|
||||||
/xpreset
|
/xpreset
|
||||||
set all values to default
|
set all values to default
|
||||||
|
|
||||||
/xpset <variable> <value>
|
/xpset <variable> <value>
|
||||||
need xpfwset privilege
|
need xpfwset privilege
|
||||||
Set variable of user to new value
|
Set variable of user to new value
|
||||||
|
|
||||||
Usage (roughly):
|
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
|
Authors of source code
|
||||||
----------------------
|
----------------------
|
||||||
|
|
12
api.lua
12
api.lua
|
@ -80,10 +80,22 @@ xpfw.player_sub_attribute=function(player,attrib,val)
|
||||||
end
|
end
|
||||||
|
|
||||||
xpfw.player_get_attribute=function(player,attrib)
|
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()
|
local pm=player:get_meta()
|
||||||
return pm:get_float(xpfw.prefix.."_"..attrib) or 0
|
return pm:get_float(xpfw.prefix.."_"..attrib) or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
xpfw.player_set_attribute=function(player,attrib,val)
|
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 pm=player:get_meta()
|
||||||
local playername=player:get_player_name()
|
local playername=player:get_player_name()
|
||||||
local att_def=M.player[playername].attributes[attrib]
|
local att_def=M.player[playername].attributes[attrib]
|
||||||
|
|
Loading…
Reference in New Issue