• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua How to pass variable to other function.

BulawOw

Soul of Shinobi
Joined
Sep 15, 2014
Messages
204
Solutions
8
Reaction score
62
LUA:
local function animateGate(creature, variant, animationLoop)
    animationLoop = animationLoop + 1
    print(animationLoop)
    if not animationLoop == 3 then
        --do stuff
    end
end

function onCastSpell(creature, variant)
    
    local animationLoop = 0
    
    addEvent(animateGate, 100, animationLoop)
end

Im stuck on this and cant figure out how to pass this variable this is error im getting

2c0815ef6c23f214b119eafb43c39e76.png
 
Solution
Your animateGate function expected creature, variant & animationLoop parameters, but you only passed 1 parameter to it from the addEvent call, which turned out to be creature in this case.

LUA:
local function animateGate(animationLoop)
    animationLoop = animationLoop + 1
    print(animationLoop)
    if not animationLoop == 3 then
        --do stuff
    end
end

function onCastSpell(creature, variant)    
    local animationLoop = 0
    addEvent(animateGate, 100, animationLoop)
end

You should look at this if you want to learn more about using addEvent: [How-to] Using addEvent() (https://otland.net/threads/how-to-using-addevent.225292/)
Your animateGate function expected creature, variant & animationLoop parameters, but you only passed 1 parameter to it from the addEvent call, which turned out to be creature in this case.

LUA:
local function animateGate(animationLoop)
    animationLoop = animationLoop + 1
    print(animationLoop)
    if not animationLoop == 3 then
        --do stuff
    end
end

function onCastSpell(creature, variant)    
    local animationLoop = 0
    addEvent(animateGate, 100, animationLoop)
end

You should look at this if you want to learn more about using addEvent: [How-to] Using addEvent() (https://otland.net/threads/how-to-using-addevent.225292/)
 
Solution
Back
Top