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
|
if ( #aDef.stages < 1 ) then
|
||||||
return false
|
return false
|
||||||
end
|
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
|
affects._affects[aDef.affectid] = aDef
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function affects.removeAffect(name, affectid)
|
function affects.removeAffect(name, affectid)
|
||||||
|
@ -39,6 +40,7 @@ function affects.affectPlayer(name, affectid)
|
||||||
|
|
||||||
if ( affects._affectedPlayers[name][affectid] == nil ) then
|
if ( affects._affectedPlayers[name][affectid] == nil ) then
|
||||||
if ( affects._affects[affectid] ~= nil ) then
|
if ( affects._affects[affectid] ~= nil ) then
|
||||||
|
whoison.updateStats(name)
|
||||||
local ns = ( whoison.getTimeOnline(name) + affects._affects[affectid].stages[1].time )
|
local ns = ( whoison.getTimeOnline(name) + affects._affects[affectid].stages[1].time )
|
||||||
affects._affectedPlayers[name][affectid] = { stage = 1, nextStage = ns, ran=false }
|
affects._affectedPlayers[name][affectid] = { stage = 1, nextStage = ns, ran=false }
|
||||||
applyAffect(name,affectid)
|
applyAffect(name,affectid)
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
function applyAffect(name,affectid)
|
function applyAffect(name,affectid)
|
||||||
minetest.log("action","Applying affect "..affectid.." on "..name)
|
minetest.log("action","Applying affect "..affectid.." on "..name)
|
||||||
|
whoison.updateStats(name)
|
||||||
local player = minetest.get_player_by_name(name)
|
local player = minetest.get_player_by_name(name)
|
||||||
|
|
||||||
local oStage = affects._affectedPlayers[name][affectid].stage
|
local oStage = affects._affectedPlayers[name][affectid].stage
|
||||||
-- see if they need advanced into the next stage
|
-- see if they need advanced into the next stage
|
||||||
if ( affects._affectedPlayers[name][affectid].nextStage < whoison.getTimeOnline(name) ) then
|
if ( affects._affectedPlayers[name][affectid].nextStage < whoison.getTimeOnline(name) ) then
|
||||||
affects._affectedPlayers[name][affectid].stage = affects._affectedPlayers[name][affectid].stage + 1
|
local nextStageNum = affects._affectedPlayers[name][affectid].stage + 1
|
||||||
|
affects._affectedPlayers[name][affectid].stage = nextStageNum
|
||||||
affects._affectedPlayers[name][affectid].ran = false
|
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)
|
minetest.log("action","Affect "..affectid.." has worn off of "..name)
|
||||||
affects.removeAffect(name,affectid)
|
affects.removeAffect(name,affectid)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
affects._affectedPlayers[name][affectid].nextStage = (whoison.getTimeOnline(name) + affects._affects[affectid].stages[nextStageNum].time)
|
||||||
end
|
end
|
||||||
|
|
||||||
local iStage = affects._affectedPlayers[name][affectid].stage
|
local iStage = affects._affectedPlayers[name][affectid].stage
|
||||||
|
|
Loading…
Reference in New Issue