a little bit of documentation

master
A. Demant 2019-02-12 07:48:22 +01:00
parent 238e017d70
commit db046e7362
2 changed files with 28 additions and 1 deletions

View File

@ -3,7 +3,7 @@ Minetest Game mod: XPFW
==========================
See license.txt for license information.
XPFW provide an API for storing values relevant for experience mechanism into player metadata. It also stores several statistic values during playtime:
XPFW provide an API for storing values relevant for experience mechanism into player metadata (Identified with prefix "XPFW_"). It also stores several statistic values during playtime:
- Walked distances calculated out of velocity (important: teleporting does not influence this value)
- accumulated distance out of comparing with last known position (important: teleporting is included in this value)
- whole playtime on the server
@ -16,6 +16,20 @@ 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>
Authors of source code
----------------------
ademant (MIT)

13
api.lua
View File

@ -1,3 +1,6 @@
--[[
API for using statistic via meta data
]]
local M=xpfw
if M.player == nil then
@ -14,6 +17,16 @@ end
end
xpfw.register_attribute=function(name,data)
--[[ Register new attribute for all user with spec in data
data = {name = name of attribute,
min = Minimum value this attribute should be,
max = Maximum value where the attribute is cut, can be inf,
default = default value set at initialisation or reset,
hud = if set, attribute is shown in toggable hud display,
moving_average_factor = Attribute is moving average with this weighting factor,
recreation_factor = During recreation the value is reduced with this weighting factor
}
]]
check_value(data,"min",0)
check_value(data,"max",math.huge)
data.name=name