Custom Status Effect with icon and timer handling - Miczu/Noita-Twitch-Integration GitHub Wiki
Noita Twitch Integration provides helpful and easy* to use icon effects with duration management.
add_icon_effect(icon_path, "Unique Effect name", "Effect Description", frames_of_duration, onStartFunction, onEndFunction, booleanShowTimer)
Additionally there is supporting method to check if status effect is still active
is_icon_effect_active("Unique Effect name")
With this, you should be able to create effects that do something at the start, at the end or throughout the effect.
Example of possible ti outcome:
--Demo Example
--I'm not sure if this helps
--lame
--100
--Confuses reader with lua code
function twitch_demo_example()
local uniqueName = "Demo Example"
local onEndFunction= nil
local showTimer = true;
add_icon_effect(
"mods/twitch-integration/files/effects/status_icons/demo_example.png",
uniqueName,
"You are annoyed by message spam",
10*60,
function()
async(function()
GamePrint("Effect " .. uniqueName .. " has started")
local lastSwap = GameGetFrameNum()
repeat
local pid = get_player()
if pid ~= nil then
GamePrint("Effect " .. uniqueName .. " is ongoing and player isn't polymorphed")
end
wait(10)
until not is_icon_effect_active(uniqueName )
end)
end,
onEndFunction,
showTimer
)
end
Above example shows how to have a loop with 10 frame delay between executions that ends when the effect status ends after 10 seconds - each second has 60 frames in game without lag.