• 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 Error scripts

adrenysny

Member
Joined
Feb 17, 2021
Messages
140
Reaction score
14
help me with these scripts, I do not know why it gives error: S


Lua:
Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/quests/feaster_of_souls/the_pale_worm/boss_lever.lua
...pts/quests/feaster_of_souls/the_pale_worm/boss_lever.lua:42: attempt to index local 'condition' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...pts/quests/feaster_of_souls/the_pale_worm/boss_lever.lua:42: in main chunk
        [C]: in function 'reload'
        .../forgottenserver/data/scripts/talkactions/god/reload.lua:61: in function <.../forgottenserver/data/scripts/talkactions/god/reload.lua:47>
> boss_lever.lua [error]
^

Lua Script Error: [Scripts Interface]
/home/forgottenserver/data/scripts/quests/feaster_of_souls/the_pale_worm/lantern.lua
...cripts/quests/feaster_of_souls/the_pale_worm/lantern.lua:7: attempt to index local 'condition' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...cripts/quests/feaster_of_souls/the_pale_worm/lantern.lua:7: in main chunk

boss_lever.lua
Code:
local config = {
    centerPos = {Position({x = 33806, y = 31505, z = 14}), Position({x = 33806, y = 31505, z = 15})},
    rangeX = 12,
    rangeY = 12,
    exitPos = Position({x = 33572, y = 31452, z = 10}),
    newPos = Position({x = 33806, y = 31512, z = 14}),
    bossPos = {
        Position({x = 33811, y = 31505, z = 14}),
        Position({x = 33805, y = 31505, z = 15}),
    },
    waitingTime = 25 * 60 * 60,
    maxRoomTime = 15 * 60,
}

local bossLever = Action()

local function clearRoom(id)
    local player = Player(id)
    if player then
        local spectators = Game.getSpectators(config.centerPos[1], false, true, config.rangeX, config.rangeX, config.rangeY, config.rangeY)
        for _, pid in pairs(spectators) do
            if pid:getId() == id then
                player:teleportTo(config.exitPos)
                config.exitPos:sendMagicEffect(CONST_ME_TELEPORT)
                player:sendCancelMessage("Time's over!")
                break
            end
        end
        spectators = Game.getSpectators(config.centerPos[2], false, true, config.rangeX, config.rangeX, config.rangeY, config.rangeY)
        for _, pid in pairs(spectators) do
            if pid:getId() == id then
                player:teleportTo(config.exitPos)
                config.exitPos:sendMagicEffect(CONST_ME_TELEPORT)
                player:sendCancelMessage("Time's over!")
                break
            end
        end
    end
end   

local condition = Condition(CONDITION_HEX)
    condition:setParameter(CONDITION_PARAM_TICKS, -1)
    condition:setParameter(CONDITION_PARAM_SUBID, 1095)
    condition:setParameter(CONDITION_PARAM_BUFF_HEALINGRECEIVED, 40)
    condition:setParameter(CONDITION_PARAM_BUFF_DAMAGEDEALT, 40)
    condition:setParameter(CONDITION_PARAM_HEALTHREDUCTIONPERCENT, 60)

function bossLever.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getPosition() ~= Position({x = 33772, y = 31504, z = 14}) then
        return false
    end
    if item:getId() == 9826 then
        item:transform(9825)
        return true
    end
    item:transform(9826)
    local spectators = Game.getSpectators(config.centerPos[1], false, false, config.rangeX, config.rangeX, config.rangeY, config.rangeY)
    for _, creature in pairs(spectators) do
        if creature:isPlayer() then
            player:sendCancelMessage("There's someone fighting the boss.")
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
            return true
        end
    end
    local secondFloorSpectators = Game.getSpectators(config.centerPos[1], false, false, config.rangeX, config.rangeX, config.rangeY, config.rangeY)
    for _, creature in pairs(secondFloorSpectators) do
        if creature:isPlayer() then
            player:sendCancelMessage("There's someone fighting the boss.")
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
            return true
        end
    end
    local players = {}
    if player:getStorageValue(Storage.Quest.FeasterOfSouls.Bosses.ThePaleWorm.Timer) >= os.time() then
        player:sendCancelMessage("Someone of your team fought this boss in the last 20h.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    else
        table.insert(players, player)
    end
    for x = 33773, 33773 + 2 do
        for y = 31503, 31503 + 2 do
            local tile = Tile(Position(x, y, 14))
            local creature = tile:getTopCreature()
            if creature and creature:isPlayer() then
                if creature:getStorageValue(Storage.Quest.FeasterOfSouls.Bosses.ThePaleWorm.Timer) >= os.time() then
                    player:sendCancelMessage("Someone of your team fought this boss in the last 20h.")
                    player:getPosition():sendMagicEffect(CONST_ME_POFF)
                    return true
                else
                    table.insert(players, creature)
                end
            end
        end
    end

    for _, creature in pairs(spectators) do
        creature:remove()
    end
    for _, creature in pairs(secondFloorSpectators) do
        creature:remove()
    end
    Game.createMonster("The Pale Worm", config.bossPos[1], false, true)
    Game.createMonster("A Weak Spot", config.bossPos[2], false, true)
    for _, pid in pairs(players) do
        pid:setStorageValue(Storage.Quest.FeasterOfSouls.Bosses.ThePaleWorm.Timer, os.time() + config.waitingTime)
        pid:getPosition():sendMagicEffect(CONST_ME_POFF)
        pid:teleportTo(config.newPos)
        addEvent(clearRoom, config.maxRoomTime * 1000, pid:getId())
        pid:addCondition(condition)
    end
    addEvent(function()
        Game.createMonster("Hunger Worm", Position({x = 33805, y = 31499, z = 14}), false, true)
    end, 45000)
    config.newPos:sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

bossLever:aid(49610)

bossLever:register()

lantern.lua
Code:
local lantern = Action()


local condition = Condition(CONDITION_HEX)
    condition:setParameter(CONDITION_PARAM_TICKS, -1)
    condition:setParameter(CONDITION_PARAM_SUBID, 1095)
    condition:setParameter(CONDITION_PARAM_BUFF_HEALINGRECEIVED, 40)
    condition:setParameter(CONDITION_PARAM_BUFF_DAMAGEDEALT, 40)
    condition:setParameter(CONDITION_PARAM_HEALTHREDUCTIONPERCENT, 60)

function lantern.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not player:getCondition(CONDITION_HEX, CONDITIONID_COMBAT, 1095) then
        player:sendCancelMessage("You are not in fight with the pale worm.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    local chances = math.random(1, 100)
    player:removeCondition(CONDITION_HEX, CONDITIONID_COMBAT, 1095)
    if chances <= 20 then
        item:remove()
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your soulforged lantern has burned out and dissipates into nothingness!")
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your soulforged lantern has cleansed the taint of the worm!")
    end
    player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)

    return true
end

lantern:id(37426)

lantern:register()
 
looks like CONDITION_HEX doesn't exist.
Lua:
local condition = Condition(CONDITION_HEX)

would I have to add it like this?
Lua:
enum ConditionType_t {
    CONDITION_NONE,

    CONDITION_POISON = 1 << 0,
    CONDITION_FIRE = 1 << 1,
    CONDITION_ENERGY = 1 << 2,
    CONDITION_BLEEDING = 1 << 3,
    CONDITION_HASTE = 1 << 4,
    CONDITION_PARALYZE = 1 << 5,
    CONDITION_OUTFIT = 1 << 6,
    CONDITION_INVISIBLE = 1 << 7,
    CONDITION_LIGHT = 1 << 8,
    CONDITION_MANASHIELD = 1 << 9,
    CONDITION_INFIGHT = 1 << 10,
    CONDITION_DRUNK = 1 << 11,
    CONDITION_EXHAUST = 1 << 12, // unused
    CONDITION_REGENERATION = 1 << 13,
    CONDITION_SOUL = 1 << 14,
    CONDITION_DROWN = 1 << 15,
    CONDITION_MUTED = 1 << 16,
    CONDITION_CHANNELMUTEDTICKS = 1 << 17,
    CONDITION_YELLTICKS = 1 << 18,
    CONDITION_ATTRIBUTES = 1 << 19,
    CONDITION_FREEZING = 1 << 20,
    CONDITION_DAZZLED = 1 << 21,
    CONDITION_CURSED = 1 << 22,
    CONDITION_EXHAUST_COMBAT = 1 << 23, // unused
    CONDITION_EXHAUST_HEAL = 1 << 24, // unused
    CONDITION_PACIFIED = 1 << 25,
    CONDITION_SPELLCOOLDOWN = 1 << 26,
    CONDITION_SPELLGROUPCOOLDOWN = 1 << 27,
    CONDITION_ROOTED = 1 << 28,
    CONDITION_HEX = 1 << 29,
};
 
would I have to add it like this?
Lua:
enum ConditionType_t {
    CONDITION_NONE,

    CONDITION_POISON = 1 << 0,
    CONDITION_FIRE = 1 << 1,
    CONDITION_ENERGY = 1 << 2,
    CONDITION_BLEEDING = 1 << 3,
    CONDITION_HASTE = 1 << 4,
    CONDITION_PARALYZE = 1 << 5,
    CONDITION_OUTFIT = 1 << 6,
    CONDITION_INVISIBLE = 1 << 7,
    CONDITION_LIGHT = 1 << 8,
    CONDITION_MANASHIELD = 1 << 9,
    CONDITION_INFIGHT = 1 << 10,
    CONDITION_DRUNK = 1 << 11,
    CONDITION_EXHAUST = 1 << 12, // unused
    CONDITION_REGENERATION = 1 << 13,
    CONDITION_SOUL = 1 << 14,
    CONDITION_DROWN = 1 << 15,
    CONDITION_MUTED = 1 << 16,
    CONDITION_CHANNELMUTEDTICKS = 1 << 17,
    CONDITION_YELLTICKS = 1 << 18,
    CONDITION_ATTRIBUTES = 1 << 19,
    CONDITION_FREEZING = 1 << 20,
    CONDITION_DAZZLED = 1 << 21,
    CONDITION_CURSED = 1 << 22,
    CONDITION_EXHAUST_COMBAT = 1 << 23, // unused
    CONDITION_EXHAUST_HEAL = 1 << 24, // unused
    CONDITION_PACIFIED = 1 << 25,
    CONDITION_SPELLCOOLDOWN = 1 << 26,
    CONDITION_SPELLGROUPCOOLDOWN = 1 << 27,
    CONDITION_ROOTED = 1 << 28,
    CONDITION_HEX = 1 << 29,
};
It's gonna be more than just adding an enum.

 
It's gonna be more than just adding an enum.

I can't change this condition to another in the scripts? CONDITION_HEX
 
Anything other than CONDITION_HEX? you can.
Modify this if you wish to change it
local condition = Condition(CONDITION_HEX)
I put it like this, but it doesn't work, should I change something else?

Lua:
local config = {
    centerPos = {Position({x = 33806, y = 31505, z = 14}), Position({x = 33806, y = 31505, z = 15})},
    rangeX = 12,
    rangeY = 12,
    exitPos = Position({x = 33572, y = 31452, z = 10}),
    newPos = Position({x = 33806, y = 31512, z = 14}),
    bossPos = {
        Position({x = 33811, y = 31505, z = 14}),
        Position({x = 33805, y = 31505, z = 15}),
    },
    waitingTime = 25 * 60 * 60,
    maxRoomTime = 15 * 60,
}

local bossLever = Action()

local function clearRoom(id)
    local player = Player(id)
    if player then
        local spectators = Game.getSpectators(config.centerPos[1], false, true, config.rangeX, config.rangeX, config.rangeY, config.rangeY)
        for _, pid in pairs(spectators) do
            if pid:getId() == id then
                player:teleportTo(config.exitPos)
                config.exitPos:sendMagicEffect(CONST_ME_TELEPORT)
                player:sendCancelMessage("Time's over!")
                break
            end
        end
        spectators = Game.getSpectators(config.centerPos[2], false, true, config.rangeX, config.rangeX, config.rangeY, config.rangeY)
        for _, pid in pairs(spectators) do
            if pid:getId() == id then
                player:teleportTo(config.exitPos)
                config.exitPos:sendMagicEffect(CONST_ME_TELEPORT)
                player:sendCancelMessage("Time's over!")
                break
            end
        end
    end
end  

local condition = Condition(CONDITION_CURSED)
    condition:setParameter(CONDITION_PARAM_TICKS, -1)
    condition:setParameter(CONDITION_PARAM_SUBID, 1095)
    condition:setParameter(CONDITION_PARAM_BUFF_HEALINGRECEIVED, 40)
    condition:setParameter(CONDITION_PARAM_BUFF_DAMAGEDEALT, 40)
    condition:setParameter(CONDITION_PARAM_HEALTHREDUCTIONPERCENT, 60)

function bossLever.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getPosition() ~= Position({x = 33772, y = 31504, z = 14}) then
        return false
    end
    if item:getId() == 9826 then
        item:transform(9825)
        return true
    end
    item:transform(9826)
    local spectators = Game.getSpectators(config.centerPos[1], false, false, config.rangeX, config.rangeX, config.rangeY, config.rangeY)
    for _, creature in pairs(spectators) do
        if creature:isPlayer() then
            player:sendCancelMessage("There's someone fighting the boss.")
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
            return true
        end
    end
    local secondFloorSpectators = Game.getSpectators(config.centerPos[1], false, false, config.rangeX, config.rangeX, config.rangeY, config.rangeY)
    for _, creature in pairs(secondFloorSpectators) do
        if creature:isPlayer() then
            player:sendCancelMessage("There's someone fighting the boss.")
            player:getPosition():sendMagicEffect(CONST_ME_POFF)
            return true
        end
    end
    local players = {}
    if player:getStorageValue(Storage.Quest.FeasterOfSouls.Bosses.ThePaleWorm.Timer) >= os.time() then
        player:sendCancelMessage("Someone of your team fought this boss in the last 20h.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    else
        table.insert(players, player)
    end
    for x = 33773, 33773 + 2 do
        for y = 31503, 31503 + 2 do
            local tile = Tile(Position(x, y, 14))
            local creature = tile:getTopCreature()
            if creature and creature:isPlayer() then
                if creature:getStorageValue(Storage.Quest.FeasterOfSouls.Bosses.ThePaleWorm.Timer) >= os.time() then
                    player:sendCancelMessage("Someone of your team fought this boss in the last 20h.")
                    player:getPosition():sendMagicEffect(CONST_ME_POFF)
                    return true
                else
                    table.insert(players, creature)
                end
            end
        end
    end

    for _, creature in pairs(spectators) do
        creature:remove()
    end
    for _, creature in pairs(secondFloorSpectators) do
        creature:remove()
    end
    Game.createMonster("The Pale Worm", config.bossPos[1], false, true)
    Game.createMonster("A Weak Spot", config.bossPos[2], false, true)
    for _, pid in pairs(players) do
        pid:setStorageValue(Storage.Quest.FeasterOfSouls.Bosses.ThePaleWorm.Timer, os.time() + config.waitingTime)
        pid:getPosition():sendMagicEffect(CONST_ME_POFF)
        pid:teleportTo(config.newPos)
        addEvent(clearRoom, config.maxRoomTime * 1000, pid:getId())
        pid:addCondition(condition)
    end
    addEvent(function()
        Game.createMonster("Hunger Worm", Position({x = 33805, y = 31499, z = 14}), false, true)
    end, 45000)
    config.newPos:sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

bossLever:aid(49610)

bossLever:register()



Code:
local lantern = Action()


local condition = Condition(CONDITION_CURSED)
    condition:setParameter(CONDITION_PARAM_TICKS, -1)
    condition:setParameter(CONDITION_PARAM_SUBID, 1095)
    condition:setParameter(CONDITION_PARAM_BUFF_HEALINGRECEIVED, 40)
    condition:setParameter(CONDITION_PARAM_BUFF_DAMAGEDEALT, 40)
    condition:setParameter(CONDITION_PARAM_HEALTHREDUCTIONPERCENT, 60)

function lantern.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if not player:getCondition(CONDITION_CURSED, CONDITIONID_COMBAT, 1095) then
        player:sendCancelMessage("You are not in fight with the pale worm.")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return true
    end
    local chances = math.random(1, 100)
    player:removeCondition(CONDITION_CURSED, CONDITIONID_COMBAT, 1095)
    if chances <= 20 then
        item:remove()
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your soulforged lantern has burned out and dissipates into nothingness!")
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your soulforged lantern has cleansed the taint of the worm!")
    end
    player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)

    return true
end

lantern:id(37426)

lantern:register()
BOSS.png
 
Last edited:
Back
Top