• 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!

Solved Demon Oak Bug!

Ray Rewind

Doctor
Joined
Jun 6, 2009
Messages
1,348
Reaction score
75
Location
Germany
Getting this bug

[02/11/2013 12:37:55] [Error - Action Interface]
[02/11/2013 12:37:55] data/actions/scripts/quests/demonoak/demonOak.lua:eek:nUse
[02/11/2013 12:37:55] Description:
[02/11/2013 12:37:55] data/lib/102-demonoak.lua:243: attempt to call method 'lower' (a nil value)
[02/11/2013 12:37:55] stack traceback:
[02/11/2013 12:37:55] data/lib/102-demonoak.lua:243: in function 'monsterExists'
[02/11/2013 12:37:55] data/actions/scripts/quests/demonoak/demonOak.lua:59: in function <data/actions/scripts/quests/demonoak/demonOak.lua:1>


lib.

http://pastebin.com/FWDvUpks


actions.

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)

if blockingTree[itemEx.itemid] and itemEx.uid == blockingTree[itemEx.itemid][1] then

local tree = toPosition
if canEnter(cid, tree) ~= ERROR_NOERROR then
return doPlayerSendCancel(cid, getError(canEnter(cid, tree), tree)) and doSendMagicEffect(tree, CONST_ME_POFF)
end

doTransformItem(itemEx.uid, blockingTree[itemEx.itemid][2])
doSendMagicEffect(tree, CONST_ME_POFF)
doMoveCreature(cid, getDirectionTo(getCreaturePosition(cid), toPosition))
doCreatureSetStorage(cid, storages.treeCut, 1)
doCreatureSay(cid, "I AWAITED YOU! COME HERE AND GET YOUR REWARD!", TALKTYPE_MONSTER_YELL, false, cid, (positions.demonOak or getCreaturePosition(cid)))
return true

elseif isInArray(demonOak, itemEx.itemid) then

local get = getCreatureStorage(cid, itemEx.itemid)
if get == -1 then doCreatureSetStorage(cid, itemEx.itemid, 1) end

local k = 0
for i = demonOak[1], demonOak[#demonOak] do
if(getCreatureStorage(cid, i) == (waves and waves > 0 and waves or #summons) + 1) then
k = k + 1
end
end

if killAllBeforeCut or k == #demonOak then
if getCreaturesInQuestArea(TYPE_MONSTER, questAreaPosition[1], questAreaPosition[2], GET_COUNT) > 0 then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need to kill all monsters first.")
doSendMagicEffect(toPosition, CONST_ME_POFF)
return true
end
end

if(k == #demonOak) then
doTeleportThing(cid, positions.kick)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Tell Oldrak about your great victory against the demon oak.")
doCreatureSetStorage(cid, storages.done, 1)
return true
end

if getCreatureStorage(cid, itemEx.itemid) >= (waves and waves > 0 and waves or #summons) + 1 then
return doSendMagicEffect(toPosition, CONST_ME_POFF)
end

if math.random(10) > 3 then
doSendMagicEffect(toPosition, CONST_ME_DRAWBLOOD)
doCreatureSay(cid, "-krrrrak-", TALKTYPE_MONSTER_YELL, false, cid, getThingPos(itemEx.uid))
doTargetCombatHealth(0, cid, floorDamage.type, -floorDamage.min, -floorDamage.max, floorDamage.effect)
return true
end

local deny = false
local cbs = 0
if summons[get] then
for i = 1, #summons[get] do
if monsterExists(summons[get]) then
local sPos = positions.summon[math.random(#positions.summon)]
local thing = getTopCreature(sPos)
local area
if isMonster(thing.uid) then
area = getArea(sPos, 2, 2)
for _, pos in ipairs(area) do
if isCreature(getTopCreature(pos).uid) or not isInRange(pos, questAreaPosition[1], questAreaPosition[2]) then
deny = true
break
else
ret = doCreateMonster(summons[get], pos)
if tonumber(ret) == nil then
cbs = cbs + 1
end
break
end
end
else
ret = doCreateMonster(summons[get], sPos)
if tonumber(ret) == nil then
cbs = cbs + 1
end
end
end
end

if cbs > 0 then
return doPlayerSendCancel(cid, "There are " .. cbs .. " monster that could not be summoned. Wave has not been counted.")
end

if not deny then
doCreatureSetStorage(cid, itemEx.itemid, get + 1)
end
if isLastCut(cid) then
doCreatureSay(cid, "HOW IS THAT POSSIBLE?!? MY MASTER WILL CRUSH YOU!! AHRRGGG!", TALKTYPE_MONSTER_YELL, false, cid, (positions.demonOak or getCreaturePosition(cid)))
else
doCreatureSay(cid, sounds[2][math.random(1, #sounds[2])], TALKTYPE_MONSTER_YELL, false, cid, (positions.demonOak or getCreaturePosition(cid)))
end
doSendMagicEffect(toPosition, CONST_ME_DRAWBLOOD)
if math.random(100) >= 50 then
doTargetCombatHealth(0, cid, floorDamage.type, -floorDamage.min, -floorDamage.max, floorDamage.effect)
end
end
return false
end
end
 
The problem isn't your action scripts, is the lib.

Change this line:
Code:
if m_name:lower() == name:lower() then
To:
Code:
if string.lower(m_name) == string.lower(name) then

If you are still having problems after that; change the (name) for (name[1]), you might have a lot of errors in console when the server startup if your checkLib function is enabled, but the script will be working fine.
 
If I change (name[1]) script doest work many errors and no dmg from the tree


[03/11/2013 13:58:18] [Error - Action Interface]
[03/11/2013 13:58:18] data/actions/scripts/quests/demonoak/demonOak.lua:eek:nUse
[03/11/2013 13:58:18] Description:
[03/11/2013 13:58:18] data/lib/102-demonoak.lua:243: bad argument #1 to 'lower' (string expected, got table)
[03/11/2013 13:58:18] stack traceback:
[03/11/2013 13:58:18] [C]: in function 'lower'
[03/11/2013 13:58:18] data/lib/102-demonoak.lua:243: in function 'monsterExists'
[03/11/2013 13:58:18] data/actions/scripts/quests/demonoak/demonOak.lua:59: in function <data/actions/scripts/quests/demonoak/demonOak.lua:1>

[03/11/2013 13:58:21] [Error - Action Interface]
[03/11/2013 13:58:21] data/actions/scripts/quests/demonoak/demonOak.lua:eek:nUse
[03/11/2013 13:58:21] Description:
[03/11/2013 13:58:21] data/lib/102-demonoak.lua:243: bad argument #1 to 'lower' (string expected, got table)
[03/11/2013 13:58:21] stack traceback:
[03/11/2013 13:58:21] [C]: in function 'lower'
[03/11/2013 13:58:21] data/lib/102-demonoak.lua:243: in function 'monsterExists'
[03/11/2013 13:58:21] data/actions/scripts/quests/demonoak/demonOak.lua:59: in function <data/actions/scripts/quests/demonoak/demonOak.lua:1>
 
Code:
[03/11/2013 13:58:18] data/lib/102-demonoak.lua:243: bad argument #1 to 'lower' (string expected, got table)

That's because you didn't use the [1] ;O
 
Code:
[03/11/2013 17:51:10] [Error - Action Interface]
[03/11/2013 17:51:10] data/actions/scripts/quests/demonoak/demonOak.lua:onUse
[03/11/2013 17:51:10] Description:
[03/11/2013 17:51:10] data/lib/102-demonoak.lua:243: bad argument #1 to 'lower' (string expected, got table)
[03/11/2013 17:51:11] stack traceback:
[03/11/2013 17:51:11]    [C]: in function 'lower'
[03/11/2013 17:51:11]    data/lib/102-demonoak.lua:243: in function 'monsterExists'
[03/11/2013 17:51:11]    data/actions/scripts/quests/demonoak/demonOak.lua:59: in function <data/actions/scripts/quests/demonoak/demonOak.lua:1>
 
Ohhh, I didn't know that you were using 0.3.6... Hmm I don't have any server at the moment to try it ;( Sorry!
 
[20/03/2014 15:45:43] [Error - Action Interface]
[20/03/2014 15:45:43] data/actions/scripts/quests/demonoak/demonOak.lua:eek:nUse
[20/03/2014 15:45:43] Description:
[20/03/2014 15:45:43] data/lib/102-demonoak.lua:243: bad argument #1 to 'lower' (string expected, got table)
[20/03/2014 15:45:43] stack traceback:
[20/03/2014 15:45:43] [C]: in function 'lower'
[20/03/2014 15:45:43] data/lib/102-demonoak.lua:243: in function 'monsterExists'
[20/03/2014 15:45:43] data/actions/scripts/quests/demonoak/demonOak.lua:59: in function <data/actions/scripts/quests/demonoak/demonOak.lua:1>

[20/03/2014 15:45:45] [Error - Action Interface]
[20/03/2014 15:45:45] data/actions/scripts/quests/demonoak/demonOak.lua:eek:nUse
[20/03/2014 15:45:45] Description:
[20/03/2014 15:45:45] data/lib/102-demonoak.lua:243: bad argument #1 to 'lower' (string expected, got table)
[20/03/2014 15:45:45] stack traceback:
[20/03/2014 15:45:45] [C]: in function 'lower'
[20/03/2014 15:45:45] data/lib/102-demonoak.lua:243: in function 'monsterExists'
[20/03/2014 15:45:45] data/actions/scripts/quests/demonoak/demonOak.lua:59: in function <data/actions/scripts/quests/demonoak/demonOak.lua:1>

[20/03/2014 15:45:46] [Error - Action Interface]
[20/03/2014 15:45:46] data/actions/scripts/quests/demonoak/demonOak.lua:eek:nUse
[20/03/2014 15:45:46] Description:
[20/03/2014 15:45:46] data/lib/102-demonoak.lua:243: bad argument #1 to 'lower' (string expected, got table)
[20/03/2014 15:45:46] stack traceback:
[20/03/2014 15:45:46] [C]: in function 'lower'
[20/03/2014 15:45:46] data/lib/102-demonoak.lua:243: in function 'monsterExists'
[20/03/2014 15:45:46] data/actions/scripts/quests/demonoak/demonOak.lua:59: in function <data/actions/scripts/quests/demonoak/demonOak.lua:1>
 
From your first post:

data/lib/102-demonoak.lua:243: attempt to call method 'lower' (a nil value)

That tells you you tried to call a method on an object instance that hadn't been defined. This happened at physical line 243 in file data/lib/102-demonoak.lua.

Look at that file, extract the chunk of code the bad call is in, and paste it here (don't paste the whole thing - yet).
The chunk is probably a function, in which case we need the code from the function signature to the corresponding "end".

If you can find the code that calls the function, post that too, but keep them separate.

BTW - that "nil" means you have a an object reference (variable name) but it hasn't been initialized. This means there's a strong chance the error is elsewhere (possibly in the code that called the function, possibly even in the definition of the object)
 
Hey @Pteryx

this is the function part in the lib :)
229-253

Code:
function monsterExists(name)

local file = "data/monster/monsters.xml"
local openFile = io.open(file, "r")
local m_name, getName, getFile, m_file = 0, 0, 0, 0
local monsterExists, fileExists = false, false
if openFile ~= nil then
for line in io.lines(file) do
if line:find('name=".*".*') and line:find('file=".*".*') then
getName = string.match(line, 'name=".*".*')
getFile = string.match(line, 'file=".*".*')
if getName and getFile then
m_name = string.sub(getName, string.find(getName, '="') + 2, (string.find(getName, '" ') or string.find(getName, '"f') or 1) - 1)
m_file = string.sub(getFile, string.find(getFile, '="') + 2, (string.find(getFile, '"/') or string.find(getFile, '" ') or 1) - 1)
if string.lower(m_name) == string.lower(name) then
monsterExists = true
mfile = io.open("data/monster/" .. m_file, "r")
if mfile ~= nil then
fileExists = true
mfile:close()
end
end
end
end
end
openFile:close()
end
return monsterExists and fileExists or false
end
 
I fixed the problem it was the beholder because in monster.xml it was saved as

elder beholder and it should be elder_beholder now I got this error after I fixed this one

Code:
[20/03/2014 20:47:45] [Error - Action Interface]
[20/03/2014 20:47:45] data/actions/scripts/quests/demonoak/demonOak.lua:onUse
[20/03/2014 20:47:45] Description:
[20/03/2014 20:47:45] data/lib/102-demonoak.lua:243: bad argument #1 to 'lower' (string expected, got table)
[20/03/2014 20:47:45] stack traceback:
[20/03/2014 20:47:45]    [C]: in function 'lower'
[20/03/2014 20:47:45]    data/lib/102-demonoak.lua:243: in function 'monsterExists'
[20/03/2014 20:47:45]    data/actions/scripts/quests/demonoak/demonOak.lua:59: in function <data/actions/scripts/quests/demonoak/demonOak.lua:1>
 
Hate the code formatting :)

It looks like variable m_name is either going to be a string or nil, so it shouldn't cause that error

That leaves us with "name", which comes from the initial call to the function. This is why I asked earlier for the code that called the monsterExists() function. The message seems to be telling us "name" is a table.

If you can find that, please copy it here. If not, you could:

a. If you know an easy way to log from the script, or write to a console, output the result of
Code:
type(name)
somewhere close to the start of the function. If it's not "string", calling string.lower(name) will fail.

b. You could also use a local value of some kind instead of "name" in
Code:
if string.lower(m_name) == string.lower(name) then


If you're looking for a monster called "demonoak" you could add this near the top:
Code:
local nameX = "demonoak"

and replace the test with:
Code:
if string.lower(m_name) == string.lower(nameX) then
 
Last edited:
A more readable version. I put some comments in too - let me know if any are wrong.

Code:
function monsterExists(name)

    local file = "data/monster/monsters.xml"
    local openFile = io.open(file, "r")
    local m_name, getName, getFile, m_file = 0, 0, 0, 0
    local monsterExists, fileExists = false, false

    if openFile ~= nil then
 
        for line in io.lines(file) do -- step through the file
     
            if line:find('name=".*".*') and line:find('file=".*".*') then  -- process lines with name= and file = in them
                getName = string.match(line, 'name=".*".*')
                getFile = string.match(line, 'file=".*".*')
             
                if getName and getFile then  -- check the name and file are strings
                    -- grab the monster name and the file name
                    m_name = string.sub(getName, string.find(getName, '="') + 2, (string.find(getName, '" ') or string.find(getName, '"f') or 1) - 1)
                    m_file = string.sub(getFile, string.find(getFile, '="') + 2, (string.find(getFile, '"/') or string.find(getFile, '" ') or 1) - 1)
                 
                    -- if the monster name from the file matches the one we're looking for,
                    -- check the file is available
                    if string.lower(m_name) == string.lower(name) then
                        monsterExists = true
                        mfile = io.open("data/monster/" .. m_file, "r")
                        if mfile ~= nil then
                            fileExists = true
                            mfile:close()
                        end
                    end
                 
                end
            end
         
        end
 
        openFile:close()
    end
 
    return monsterExists and fileExists or false  -- true if the monster is in monsters.xml, and its monstername.xml exists
 
end
 
Hey ! I got this error still -.-

[21/03/2014 14:14:27] [Error - Action Interface]
[21/03/2014 14:14:27] data/actions/scripts/quests/demonoak/demonOak.lua:eek:nUse
[21/03/2014 14:14:27] Description:
[21/03/2014 14:14:27] data/lib/102-demonoak.lua:251: bad argument #1 to 'lower' (string expected, got table)
[21/03/2014 14:14:27] stack traceback:
[21/03/2014 14:14:27] [C]: in function 'lower'
[21/03/2014 14:14:27] data/lib/102-demonoak.lua:251: in function 'monsterExists'
[21/03/2014 14:14:27] data/actions/scripts/quests/demonoak/demonOak.lua:59: in function <data/actions/scripts/quests/demonoak/demonOak.lua:1>
 
@Ray
That code I pasted wasn't a fix - it's exactly the same as yours, except it's formatted and has a few comments in it :)

I think "name" is actually a table, and that you probably need to get at the text using something like name[1].

You can run one or both of the tests I suggested above, or do some random experiments :)

test 3 (this one is a bit random):

replace
Code:
-- if the monster name from the file matches the one we're looking for,
-- check the file is available
if string.lower(m_name) == string.lower(name) then
with
Code:
-- if the monster name from the file matches the one we're looking for,
-- check the file is available
local monsterName = name[1]
if string.lower(m_name) == string.lower(monsterName) then

Important: this is just a guess: (a) that name is a table, and (b) that the first element in the table is a string with the monster name.
It's quick/easy to try it though :)
 
Limos helped me ty also Pteryx now the quest is working :)

Just one last question

can I chane this part?


Code:
function getError(data, tree)
    if data == ERROR_TREEPOSITION then
        return print("[!] --> [Warning - Action::Demon Oak Script] Dead tree position is inside the quest area positions.\nDead tree position: (x: " .. tree.x .. ", y: " .. tree.y .. ", z: " .. tree.z .. ")\nNorth-West area position (x: " .. questAreaPosition[1].x .. ", y: " .. questAreaPosition[1].y .. ", z: " .. questAreaPosition[1].z .. ")\nSouth-West area position (x: " .. questAreaPosition[2].x .. ", y: " .. questAreaPosition[2].y .. ", z: " .. questAreaPosition[2].z .. ")\nScript will not work correctly, please fix it.") and "Something is wrong, please contact a staff member."
    elseif data == ERROR_NOTENOUGHLEVEL then
        return "You need level " .. level .. " or higher to enter to the quest area."
    elseif data == ERROR_ALREADYDONE then
        return "You already done this quest."
    elseif data == ERROR_ALREADYCUT then
        return "You can not leave the quest area by here."
    elseif data == ERROR_PLAYERINAREA then
        return "Wait until the player inside the quest area finishes the quest."
    elseif data == ERROR_MISSINGINFO then
        return "Sorry, not possible."
    end
    return ""
end

Message should appear in orange not in white it's not very readable
 
Back
Top