fix a few bugs
parent
c55b571f22
commit
5ee9870680
6
api.lua
6
api.lua
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue