2024-12-30 22:05:28 -06:00

64 lines
1.4 KiB
Lua

local effects = {}
PyuTest.STATUS_EFFECTS = {}
PyuTest.register_status_effect = function(id, func, oih)
PyuTest.STATUS_EFFECTS[id] = func or function(ObjectRef)end
end
PyuTest.status_effect_add = function(player, name, multiplier, length)
effects[player][name] = multiplier
if length ~= nil then
core.after(length, function()
PyuTest.status_effect_remove(player, name)
end)
end
end
PyuTest.status_effect_remove = function(player, name)
effects[player][name] = false
end
PyuTest.status_effect_get = function(player, name)
if effects[player][name] ~= false and effects[player][name] ~= nil then
return effects[player][name]
end
return 1
end
PyuTest.status_effect_has = function(player, name)
return effects[player][name] ~= false
end
core.register_on_joinplayer(function (player)
local name = player:get_player_name()
if effects[name] == nil then
effects[name] = {}
end
for _, v in pairs(PyuTest.STATUS_EFFECTS) do
if effects[name][v] == nil then
effects[name][v] = false
end
end
end)
core.register_on_respawnplayer(function (player)
local name = player:get_player_name()
for k, _ in pairs(PyuTest.STATUS_EFFECTS) do
effects[name][k] = false
end
end)
core.register_globalstep(function ()
for _, v in pairs(core.get_connected_players()) do
local name = v:get_player_name()
for k, f in pairs(PyuTest.STATUS_EFFECTS) do
f(v, name)
end
end
end)