fix a few bugs

master
Brandon 2014-01-31 13:32:19 -06:00
parent c55b571f22
commit 5ee9870680
3 changed files with 16 additions and 7 deletions

View File

@ -9,10 +9,11 @@ function affects.registerAffect( aDef )
if ( #aDef.stages < 1 ) then
return false
end
-- TODO add more checks here to ensure the affect definition won't crash the server
-- TODO add more checks here to ensure the affect definition won't crash the server
affects._affects[aDef.affectid] = aDef
end
function affects.removeAffect(name, affectid)
@ -39,6 +40,7 @@ function affects.affectPlayer(name, affectid)
if ( affects._affectedPlayers[name][affectid] == nil ) then
if ( affects._affects[affectid] ~= nil ) then
whoison.updateStats(name)
local ns = ( whoison.getTimeOnline(name) + affects._affects[affectid].stages[1].time )
affects._affectedPlayers[name][affectid] = { stage = 1, nextStage = ns, ran=false }
applyAffect(name,affectid)

View File

@ -1,17 +1,21 @@
function applyAffect(name,affectid)
minetest.log("action","Applying affect "..affectid.." on "..name)
whoison.updateStats(name)
local player = minetest.get_player_by_name(name)
local oStage = affects._affectedPlayers[name][affectid].stage
-- see if they need advanced into the next stage
if ( affects._affectedPlayers[name][affectid].nextStage < whoison.getTimeOnline(name) ) then
affects._affectedPlayers[name][affectid].stage = affects._affectedPlayers[name][affectid].stage + 1
if ( affects._affectedPlayers[name][affectid].nextStage < whoison.getTimeOnline(name) ) then
local nextStageNum = affects._affectedPlayers[name][affectid].stage + 1
affects._affectedPlayers[name][affectid].stage = nextStageNum
affects._affectedPlayers[name][affectid].ran = false
if ( #affects._affects[affectid].stages < affects._affectedPlayers[name][affectid].stage ) then
minetest.log("action","Advancing "..affectid.." to the next stage for "..name)
if ( #affects._affects[affectid].stages < nextStageNum ) then
minetest.log("action","Affect "..affectid.." has worn off of "..name)
affects.removeAffect(name,affectid)
return
end
end
affects._affectedPlayers[name][affectid].nextStage = (whoison.getTimeOnline(name) + affects._affects[affectid].stages[nextStageNum].time)
end
local iStage = affects._affectedPlayers[name][affectid].stage

View File

@ -18,4 +18,7 @@ affects.loadAffects()
minetest.register_privilege("affects", "Player can use the affects chat commands.")
minetest.register_on_shutdown(function()
affects.saveAffects()
end
)