kimi-k2-0711-preview LMArena Human Preference 140K
so can you make me something for tick
- User
so can you make me something for tick
- Assistant
Here is a drop-in “tick” helper that you can use with the StatusEffect class you already have.
It is a tiny EffectTicker module that:- keeps a list of running effects
- runs them every frame (or every heartbeat)
- automatically removes them when they expire
- exposes one public function:
EffectTicker.update(deltaTime)
You can copy-paste it into a separate ModuleScript or just inline it.
-- EffectTicker.lua local RunService = game:GetService("RunService") local EffectTicker = {} EffectTicker.__index = EffectTicker -- Private -------------------------------------------------------------------- local activeEffects = {} -- { [target] = { [StatusEffect] = true, ... } } -- Public --------------------------------------------------------------------- -- Call this once per frame / heartbeat from your main loop. function EffectTicker.update(deltaTime) for target, effects in pairs(activeEffects) do for effect, _ in pairs(effects) do effect:tick(deltaTime) -- your StatusEffect:tick method if effect.Elapsed >= effect.Duration then effect:expire(target) -- your StatusEffect:expire method effects[effect] = nil -- remove from this target end end if next(effects) == nil then activeEffects[target] = nil -- no effects left on this target end end end -- Adds an effect to a target and starts it. function EffectTicker.add(target, effect) activeEffects[target] = activeEffects[target] or {} activeEffects[target][effect] = true effect:apply(target) -- your StatusEffect:apply method end -- Removes an effect early (e.g. cleanse / dispel). function EffectTicker.remove(target, effect) if activeEffects[target] and activeEffects[target][effect] then effect:expire(target, false) -- false = manually removed activeEffects[target][effect] = nil if next(activeEffects[target]) == nil then activeEffects[target] = nil end end end -- Optional: hook into RunService so you don’t have to call update yourself. -- Uncomment the next two lines if you want automatic ticking. -- RunService.Heartbeat:Connect(EffectTicker.update) return EffectTickerUsage example
local StatusEffect = require(script.StatusEffect) local EffectTicker = require(script.EffectTicker) -- 1. Create an effect local burn = StatusEffect.new( "Burn", 5, -- 5 seconds function(t) print(t.Name .. " starts burning!") end, function(t, dt) print(t.Name .. " takes " .. (10*dt) .. " burn dmg") end, function(t, expired) print(t.Name .. " is no longer burning") end, false ) -- 2. Attach it to a target (any table or instance) local dummy = { Name = "Dummy" } EffectTicker.add(dummy, burn) -- 3. In your main loop (or just let the RunService hook do it) game:GetService("RunService").Heartbeat:Connect(function(dt) EffectTicker.update(dt) end)That’s all you need for a clean, centralized tick system.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.