• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[spell] randomization help

andu

Sold 649 scripts, 25 maps and 9 events!
Joined
Aug 7, 2009
Messages
978
Solutions
17
Reaction score
373
GitHub
olrios
Twitch
jamagowy
hello otland
i made a animated spell with random hits
but something is wrong

part of code:
Code:
...
local function onCastSpell40(parameters)
    doCombat(parameters.cid, combat40, parameters.var)
end


function onCastSpell(cid, var)
local parameters = { cid = cid, var = var}

local bubbles = {onCastSpell1, onCastSpell2, onCastSpell3... }

addEvent(math.random(1,#bubbles), 0, parameters)
addEvent(math.random(1,#bubbles), 1500, parameters)
...

when i tried to use this spell
that error in console apper
Code:
[08/07/2010 20:03:03] Lua Script Error: [Spell Interface] 
[08/07/2010 20:03:03] data/spells/scripts/attack/blizzard.lua:onCastSpell

[08/07/2010 20:03:03] luaAddEvent(). Callback parameter should be a function.
this error apper for each addEvent i have in that spell

can someone tell me what i do wrong?
or what i need to edit?

Thx for help
 
Code:
addEvent(bubbles[math.random(#bubbles)], 0, parameters)
addEvent(bubbles[math.random(#bubbles)], 1500, parameters)
 
I can see as you have a function called onCastSpell40, you are doing something very unnecessary - repeating functions with the purpose.
Also repeating 40 addEvents like that is very inefficient.

If you post the script here I can shorten it for you with comments, unless it's private you can just PM it to me.
 
Back
Top