• 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 Create Monster do not work!

Ray Rewind

Doctor
Joined
Jun 6, 2009
Messages
1,349
Reaction score
76
Location
Germany
Code:
-- Config #1 --
local BlindField = {x=748, y=1921, z=10, stackpos=1}
local topLeft = {x=743, y=1923, z=10}
local buttomRight = {x=758, y=1940, z=10}
local tpin = {{x=751, y=1941, z=10}, {x=750, y=1939, z=9}}
local tpout = {{x=750, y=1939, z=10}, {x=751, y=1941, z=10}}
local glo = {x=750, y=1930, z=10}
local m_posi = {
{x= glo.x - 4,y=glo.y,z=glo.z},
{x= glo.x + 4,y=glo.y,z=glo.z},
{x=glo.x,y=glo.y + 4,z=glo.z},
{x=glo.x,y=glo.y - 4,z=glo.z},
{x=glo.x,y=glo.y + 5,z=glo.z},
{x=glo.x,y=glo.y - 5,z=glo.z}
}
ttime = {10, 30}
local isEvent = 58263;
-- end --

function getCreaturesFromArea(fromPos, toPos,checkFunction)
    local rarr = {};
    checkFunction = checkFunction or function(arg) return true; end;
    for fx = fromPos.x, toPos.x do
        for fy = fromPos.y, toPos.y do
            for fz = fromPos.z, toPos.z do
                local tmp = getTopCreature({x=fx,y=fy,z=fz}).uid;
                if(checkFunction(tmp))then
                    table.insert(rarr, tmp);
                end
            end
        end
    end
    local tmp = getTopCreature(BlindField).uid;
    if(checkFunction(tmp))then
        table.insert(rarr, tmp);
    end
    return rarr;
end

function getCreatureFromArea(fromPos, toPos,name)
    for fx = fromPos.x, toPos.x do
        for fy = fromPos.y, toPos.y do
            for fz = fromPos.z, toPos.z do
                local tmp = getTopCreature({x=fx,y=fy,z=fz}).uid;
                if(tmp > 0)then
                    if(string.lower(name) == string.lower(getCreatureName(tmp)))then
                        return tmp;
                    end
                end
            end
        end
    end
    local tmp = getTopCreature(BlindField).uid;
    if(tmp > 0)then
        if(string.lower(name) == string.lower(getCreatureName(tmp)))then
            return tmp;
        end
    end
    return 0;
end

local function FirstWave(count, spawnazerus)
    if(getStorage(isEvent) < 1)then
        return;
    end
    spawnazerus = spawnazerus or false;
    if(spawnazerus)then
        doCreateMonster('Azerus', m_posi[math.random(1,#m_posi)]);
        for _,pos in pairs(m_posi) do
          -- doCreateMonster("Rift Worm", pos, false, true);
        end
    else
        for i =1, count do
            doCreateMonster('Rift Worm', m_posi[math.random(1,#m_posi)]);
        end
    end
    addEvent(FirstWave,math.random(ttime[1],ttime[2])*1000,math.random(1,#m_posi));
end

local function SecondWave(count, replaceazerus)
    if(getStorage(isEvent) < 1)then
        return;
    end
    replaceazerus = replaceazerus or false;
    if(replaceazerus)then
        local tmp = getCreatureByName("Azerus");
        if(tmp > 0)then
            doRemoveCreature(tmp);
        end
        doCreateMonster("Azerus1", m_posi[math.random(1,#m_posi)]);
   
        for _,pos in pairs(m_posi) do
          -- doCreateMonster("Rift Brood", pos, false, true);
        end
    else
        for i =1, count do
          -- doCreateMonster("Rift Brood", m_posi[math.random(1,#m_posi)]);
        end
    end
    addEvent(SecondWave,math.random(ttime[1],ttime[2])*1000,math.random(1,#m_posi));
end

local function ThirdWave(count, replaceazerus)
    if(getStorage(isEvent) < 1)then
        return;
    end
    replaceazerus = replaceazerus or false;
    if(replaceazerus)then
        local tmp = getCreatureByName("Azerus");
        if(tmp > 0)then
            doRemoveCreature(tmp);
        end
        doCreateMonster("Azerus2", m_posi[math.random(1,#m_posi)]);
        for _,pos in pairs(m_posi) do
          -- doCreateMonster("Rift Scythe", pos, false, true);
        end
    else
        for i =1, count do
        --  doCreateMonster("Rift Scythe", m_posi[math.random(1,#m_posi)]);
        end
    end
    addEvent(ThirdWave,math.random(ttime[1],ttime[2])*1000,math.random(1,#m_posi));
end

local function FourthWave(count, replaceazerus)
    if(getStorage(isEvent) < 1)then
        return;
    end
    if(replaceazerus)then
        local tmp = getCreatureByName("Azerus");
        if(tmp > 0)then
            doRemoveCreature(tmp);
        end
        tmp = doCreateMonster("Azerus3", m_posi[math.random(1,#m_posi)]);
        registerCreatureEvent(tmp, "AzerusDeath");
   
        for _,pos in pairs(m_posi) do
            doCreateMonster("War Golem", pos, false, true);
        end
    else
        for i =1, count do
            doCreateMonster("War Golem", m_posi[math.random(1,#m_posi)]);
        end
    end
    addEvent(FourthWave,math.random(ttime[1],ttime[2])*1000,math.random(1,#m_posi));
end

local function fixGlobe()
    doItemSetAttribute(getTileItemById(glo, 9767).uid, "aid", 58261)
end

local function checkArea()
    if(getStorage(isEvent) > 0)then
        local players = getCreaturesFromArea(topLeft, buttomRight, isPlayer);
        if(#players < 1)then
            doSetStorage(isEvent,0);
            endAzerusFightA();
            addEvent(fixGlobe, 60*1000);
        else
            addEvent(checkArea, 10*1000);
        end
    end
end

function endAzerusFightA()
    local monsters = getCreaturesFromArea(topLeft,buttomRight,isMonster);
    while(#monsters > 0)do
        for _,m in pairs(monsters)do
            doRemoveCreature(m);
        end
        monsters = getCreaturesFromArea(topLeft,buttomRight,isMonster);
    end
    doCreateTeleport(1387, tpin[2],tpin[1]);
    doCreateTeleport(1387, tpout[2],tpout[1]);
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.actionid == 58261 then
        doItemSetAttribute(item.uid, "aid", 58263)
    else
        doCreatureSay(cid, "You have to wait some time before this globe will charge.", TALKTYPE_ORANGE_1)
        return;
    end

    local tp = getTileItemById(tpin[1],1387).uid;
    if(tp > 0)then
        doRemoveItem(tp)
    end
    tp = getTileItemById(tpout[1],1387).uid;
    if(tp > 0)then
        doRemoveItem(tp)
    end
    doSetStorage(isEvent,1);
    checkArea();
    FirstWave(0,true)
    addEvent(SecondWave, math.random(60,70)*1000,0,true)
    addEvent(ThirdWave, math.random(100,130)*1000,0,true)
    addEvent(FourthWave, math.random(190,210)*1000,0,true)
    return true
end


[17/04/2014 17:43:51] [Error - Action Interface]
[17/04/2014 17:43:51] In a timer event called from:
[17/04/2014 17:43:51] data/actions/scripts/quests/yalahar/azerus.lua:onUse
[17/04/2014 17:43:51] Description:
[17/04/2014 17:43:51] (luaDoCreateMonster) Monster with name '' not found
 
Code:
doCreateMonster('Azerus', m_posi[math.random(1,#m_posi)]);
Shouldn't it be
Code:
doCreateMonster("Azerus", m_posi[math.random(1,#m_posi)]);
?
 
@Syryniss
http://www.lua.org/pil/2.4.html
It does not matter whether you use " or ' for strings in LUA. ' looks better in my opinion.

@Ray Rewind
I don't see any issue with doCreateMonster, try commenting all lines but one summon line at once and find which causes the error.
Which wave does it happen in? Are the monsters registered in monsters.xml?
 
@Summ
My bad then, there was a lot "Azerus" and only one 'Azerus' so I thought it can be reason of error.

#topic
Do what Summ said. It's always the best method to eliminate all the rest and find out what causes the error.
 
@Syryniss
http://www.lua.org/pil/2.4.html
It does not matter whether you use " or ' for strings in LUA. ' looks better in my opinion.

@Ray Rewind
I don't see any issue with doCreateMonster, try commenting all lines but one summon line at once and find which causes the error.
Which wave does it happen in? Are the monsters registered in monsters.xml?


it happends in last wave
 
The last wave is missing
Code:
replaceazerus = replaceazerus or false;
Maybe it's for some reason, but you can try if this disables error.
 
[18/04/2014 00:50:22] [Error - Action Interface]
[18/04/2014 00:50:22] In a timer event called from:
[18/04/2014 00:50:22] data/actions/scripts/quests/yalahar/azerus.lua:onUse
[18/04/2014 00:50:22] Description:
[18/04/2014 00:50:22] (luaDoCreateMonster) Monster with name '' not found

[18/04/2014 00:50:27] [Error - Action Interface]
[18/04/2014 00:50:27] In a timer event called from:
[18/04/2014 00:50:27] data/actions/scripts/quests/yalahar/azerus.lua:onUse
[18/04/2014 00:50:27] Description:
[18/04/2014 00:50:27] (luaDoCreateMonster) Cannot create monster: Rift Brood

[18/04/2014 00:50:41] [Error - Action Interface]
[18/04/2014 00:50:41] In a timer event called from:
[18/04/2014 00:50:41] data/actions/scripts/quests/yalahar/azerus.lua:onUse
[18/04/2014 00:50:41] Description:
[18/04/2014 00:50:41] (luaDoCreateMonster) Cannot create monster: Rift Brood

[18/04/2014 00:51:14] [Error - Action Interface]
[18/04/2014 00:51:14] In a timer event called from:
[18/04/2014 00:51:14] data/actions/scripts/quests/yalahar/azerus.lua:onUse
[18/04/2014 00:51:14] Description:
[18/04/2014 00:51:14] (luaDoCreateMonster) Cannot create monster: Rift Scythe

[18/04/2014 00:51:14] [Error - Action Interface]
[18/04/2014 00:51:14] In a timer event called from:
[18/04/2014 00:51:14] data/actions/scripts/quests/yalahar/azerus.lua:onUse
[18/04/2014 00:51:14] Description:
[18/04/2014 00:51:14] (luaDoCreateMonster) Cannot create monster: Rift Scythe
 
Last edited:
Back
Top