update recreation method
parent
898e2eb229
commit
7a34fc75a5
6
api.lua
6
api.lua
|
@ -25,6 +25,9 @@ local player_addsub_attribute=function(player,attrib,val,maf)
|
|||
local new_val = oldvalue + val
|
||||
if maf ~= nil then
|
||||
new_val=(oldvalue*maf + val)/(maf + 1)
|
||||
if val < 0 then
|
||||
new_val=math.floor(new_val)
|
||||
end
|
||||
end
|
||||
xpfw.player_set_attribute(player,attrib,new_val)
|
||||
end
|
||||
|
@ -46,7 +49,6 @@ end
|
|||
xpfw.player_sub_attribute=function(player,attrib,val)
|
||||
local nval=val
|
||||
local playername=player:get_player_name()
|
||||
-- local att_def=xpfw.attributes[attrib]
|
||||
local att_def=M.player[playername].attributes[attrib]
|
||||
if val==nil then
|
||||
nval=att_def.max or 20
|
||||
|
@ -320,7 +322,7 @@ minetest.register_globalstep(function(dtime)
|
|||
player:hud_change(playerdata.hidx,"text",act_print)
|
||||
end
|
||||
|
||||
if playerdata.dtime>5 then
|
||||
if playerdata.dtime>xpfw.rtime then
|
||||
playerdata.dtime=0
|
||||
-- print(dump2(player:hud_get_flags()))
|
||||
for i,att_def in pairs(xpfw.attributes) do
|
||||
|
|
|
@ -11,6 +11,7 @@ end
|
|||
xpfw.prefix=minetest.settings:get("xpfw.prefix") or "xp"
|
||||
xpfw.mean_weight=tonumber(minetest.settings:get("xpfw.mean_weight")) or 500
|
||||
xpfw.experience_max=tonumber(minetest.settings:get("xpfw.experience_max")) or 20
|
||||
xpfw.rtime=tonumber(minetest.settings:get("xpfw.recreation_time")) or 5
|
||||
|
||||
for i,attr in ipairs({"walked","distance","swam","login","dug","build","deaths","spoke","killed_mobs","killed_player",
|
||||
"logon"}) do
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
xpfw.prefix (Prefix for variable name) string "xp"
|
||||
xpfw.recreation_time (Global time step to reduce mean values) int 5 1 100
|
||||
xpfw.light_mean_weight (Weight factor for light value) int 5000 1 10000
|
||||
xpfw.light_mean_default (Weight factor for light value) int 11 0 14
|
||||
xpfw.mean_weight (Weight factor for calculating mean value) int 5000 1 10000
|
||||
|
|
Loading…
Reference in New Issue