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

Need a little help

Wanheda

New Member
Joined
Feb 17, 2016
Messages
44
Solutions
2
Reaction score
4
I have this script which use an item to another and according to the vocation comes configured id. but is giving the following error.

[Warning - Event::checkScript] Can not load script: scripts/wolfamulet.lua
data/actions/scripts/wolfamulet.lua:7: '}' expected (to close '{' at line 2) near '['


PHP:
local moonlightcrystals = {24739}
local items = { -- 1 and 2 is mage, 3 is paladin, 4 is knight, change if wrong
    [1] = {
        [24716] = {24717},
        [24718] = {24771}
    }
    [3] = {
        [24716] = {24717},
        [24718] = {24783}
    }
    [4] = {
        [24716] = {24717},
        [24718] = {24769}
    }
    
}

items[2] = items[1]

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local voc = player:getVocation():getId()%4
    voc = (voc > 0 and voc) or 4
    if isInArray(moonlightcrystals, item:getId()) then
        local toId = items[voc][target.itemid]
        if toId then
            target:transform(toId)
            item:remove(1)
            target:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
        else
            fromPosition:sendMagicEffect(CONST_ME_POFF)         
        end
    end
    return true
end
 
after each table you have to end it with a comma (,) if you want to have another index afterwards
like this:
[1] = {},
[2] = {},
[3]
edit: also dont put a value in a table if that's the only thing you need
[1] = 2476 instead of [1] = {2476}
 
Last edited:
tarek/dot
why do you comment on stuff you clearly dont understand?
you can put comments wherever the fuck you want, lua ignores anything after -- on the same line, as xeraphus said hes missing commas
Code:
local items = { -- 1 and 2 is mage, 3 is paladin, 4 is knight, change if wrong
    [1] = {
        [24716] = {24717},
        [24718] = {24771}
    },
    [3] = {
        [24716] = {24717},
        [24718] = {24783} -- asdjhkasjhdasjh
    },
    [4] = {--asjkdasjkdasjk
        [24716] = {24717},
        [24718] = {24769}
    }
}
works perfectly fine
https://www.lua.org/cgi-bin/demo
 
Back
Top