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

Lua Two lua script errors

Royal Inferno

Member
Joined
Apr 5, 2012
Messages
464
Reaction score
21
As we have no scripters who are available too often on our team, we would need help asap with these bugs.




Key script:
Code:
local keys = {
	[0] = {keyAid= 14514, itemUid =  14514, oneTimeUse = false, storage = 14514}
	[0] = {keyAid= 14515, itemUid = 14515, oneTimeUse = false, storage = 14514}
}
local doors = {
	[0] = {itemUid = 5123, storage = 14515}
}

local function doorEnter(cid, item, toPosition)
	doTransformItem(item.uid, item.itemid + 1)
	doTeleportThing(cid, toPosition)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	-- Key Use
	if (item.aid = keys[item.itemid].keyAid and itemEx.uid = keys[item.itemid].itemUid) then
		if (keys[item.itemid].storage ~= 0) then
			doCreatureSetStorage(cid, keys[item.itemid].storage, 1)
			
			if (keys[item.itemid].oneTimeUse) then
				doPlayerRemoveItem(cid, item.itemid, 1)
			end
		end
	end
	
	-- Door Use
	if (item.uid = doors[item.itemid].itemUid and getCreatureStorage(cid, doors[item.itemid].storage) == 1) then
		doorEnter(cid, item, toPosition)
	end
	return true
end

Statue script:
Code:
local statue = {
	[0] = {statueUID = 14530, doorUid = 14532, storage = 14526}
	-- [0] = {statueUID= 0, doorUid = 0, storage = 0}
}

local doors = {
	[0] = {itemUid = 14532, storage = 14526}
}

local function doorEnter(cid, item, toPosition)
	doTransformItem(item.uid, item.itemid + 1)
	doTeleportThing(cid, toPosition)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	-- Key Use
	if (item.uid == statue[item.itemid].statueUID and itemEx.uid == statue[item.itemid].doorUid) then
		if (statue[item.itemid].storage ~= 0) then
			doCreatureSetStorage(cid, statue[item.itemid].storage, 1)
		end
	end
	
	-- Door Use
	if (item.uid == doors[item.itemid].itemUid and getCreatureStorage(cid, doors[item.itemid].storage) == 1) then
		doorEnter(cid, item, toPosition)
	end
	return true
end

Key script error:
Code:
[12:2:28.574] > Loading actions... [Error - LuaInterface::loadFile] data/actions
/scripts/quests/keys.lua:3: '}' expected (to close '{' at line 1) near '['
[12:2:28.656] [Error - Event::checkScript] Cannot load script (data/actions/scri
pts/quests/keys.lua)
[12:2:28.706] data/actions/scripts/quests/keys.lua:3: '}' expected (to close '{'
 at line 1) near '['
[12:2:30.067] done.

Statue script error:
Code:
[12:3:58.245] [Error - Action Interface]
[12:3:58.260] data/actions/scripts/quests/statue.lua:onUse
[12:3:58.337] Description:
[12:3:58.345] data/actions/scripts/quests/statue.lua:17: attempt to index a nil
value
[12:3:58.407] stack traceback:
[12:3:58.419]   data/actions/scripts/quests/statue.lua:17: in function <data/act
ions/scripts/quests/statue.lua:15>
 
Last edited:
Missing comma after
[0] = {keyAid= 14514, itemUid = 14514, oneTimeUse = false, storage = 14514}
Fixed below.
Lua:
local keys = {
    [0] = {keyAid= 14514, itemUid =  14514, oneTimeUse = false, storage = 14514},
    [0] = {keyAid= 14515, itemUid = 14515, oneTimeUse = false, storage = 14514}
}
local doors = {
    [0] = {itemUid = 5123, storage = 14515}
}

local function doorEnter(cid, item, toPosition)
    doTransformItem(item.uid, item.itemid + 1)
    doTeleportThing(cid, toPosition)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    -- Key Use
    if (item.aid = keys[item.itemid].keyAid and itemEx.uid = keys[item.itemid].itemUid) then
        if (keys[item.itemid].storage ~= 0) then
            doCreatureSetStorage(cid, keys[item.itemid].storage, 1)
            
            if (keys[item.itemid].oneTimeUse) then
                doPlayerRemoveItem(cid, item.itemid, 1)
            end
        end
    end
    
    -- Door Use
    if (item.uid = doors[item.itemid].itemUid and getCreatureStorage(cid, doors[item.itemid].storage) == 1) then
        doorEnter(cid, item, toPosition)
    end
    return true
end

The way that the function calls this line
[0] = {statueUID = 14530, doorUid = 14532, storage = 14526}
The 0 need to be the statues item id.
Example below, if the statues item id is 7641 then the script would be like this.
Lua:
local statue = {
    [7641] = {statueUID = 14530, doorUid = 14532, storage = 14526}
    -- [0] = {statueUID= 0, doorUid = 0, storage = 0}
}

local doors = {
    [0] = {itemUid = 14532, storage = 14526}
}

local function doorEnter(cid, item, toPosition)
    doTransformItem(item.uid, item.itemid + 1)
    doTeleportThing(cid, toPosition)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    -- Key Use
    if (item.uid == statue[item.itemid].statueUID and itemEx.uid == statue[item.itemid].doorUid) then
        if (statue[item.itemid].storage ~= 0) then
            doCreatureSetStorage(cid, statue[item.itemid].storage, 1)
        end
    end
    
    -- Door Use
    if (item.uid == doors[item.itemid].itemUid and getCreatureStorage(cid, doors[item.itemid].storage) == 1) then
        doorEnter(cid, item, toPosition)
    end
    return true
end
 
Back
Top