local StatusEffect = {} StatusEffect.__index = StatusEffect function StatusEffect.new()…
- User
local StatusEffect = {} StatusEffect.__index = StatusEffect
function StatusEffect.new()
end
return StatusEffect
what should the args be for new
- Assistant
That depends on what a “status effect” means in your game and how you plan to use it.
Usually a status effect has at least:- Something that identifies it (name or id)
- How long it lasts (duration or expiration time)
- What it actually does (a table of stat changes, a callback, etc.)
- (Optional) Stacking / unique key / priority info
A very common minimal constructor signature is:
function StatusEffect.new(name, duration, data) -- name : string – “Poison”, “Stun”, etc. -- duration : number – seconds (or -1 for infinite) -- data : table – anything you need (damage per tick, icon id, callbacks…) endBut if you want something more explicit you could break
dataout into separate parameters:function StatusEffect.new(name, duration, onApply, onTick, onExpire, stackable) -- name : string -- duration : number -- onApply : function(target) – called once when applied -- onTick : function(target, dt) – called every heartbeat / Stepped -- onExpire : function(target, expired) – called when removed -- stackable : boolean (default false) endOr, model-driven:
function StatusEffect.new(config) -- config = { -- Id = "Burn", -- Duration = 5, -- TickRate = 1, -- seconds -- Damage = 3, -- each tick -- MaxStacks = 1, -- Icon = 123456, -- } endIf you’re not yet sure, start small:
local StatusEffect = {} StatusEffect.__index = StatusEffect function StatusEffect.new(name, duration) local self = setmetatable({}, StatusEffect) self.Name = name self.Duration = duration or 0 -- seconds, 0 = instant self.Elapsed = 0 return self end return StatusEffectThen, when you discover you also need callbacks or extra data, you can add another field or pass a single table of options to keep the signature from getting too long.
Questions to ask yourself: • Do you need per-tick logic?
• Should the same effect stack or refresh?
• Do different entities need to query active effects by unique id?
• Are you okay passing one “options” table instead of many positional args?If you let me know how you plan to drive the effect (e.g. run service loop, Roblox task.defer, etc.) I can suggest a more concrete constructor signature and sample usage.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.