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

help missing function?

miguelshta

Member
Joined
Mar 21, 2009
Messages
351
Solutions
1
Reaction score
13
Location
Toronto, Canada
hello i got this console error with my scarlett etzel script maybe a missing function? can someone help me and how to add it?
Lua:
Lua Script Error: [Test Interface]
data/actions/scripts/quests/grave_danger/cobra_bastion/scarlett.lua
...s/scripts/quests/grave_danger/cobra_bastion/scarlett.lua:7: attempt to index field 'GraveDanger' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...s/scripts/quests/grave_danger/cobra_bastion/scarlett.lua:7: in main chunk
[Warning - Event::checkScript] Can not load script: scripts/quests/grave_danger/cobra_bastion/scarlett.lua


Lua Script Error: [Test Interface]
data/actions/scripts/ezipsoft/scarlett_bossFight.lua
data/actions/scripts/ezipsoft/scarlett_bossFight.lua:1: attempt to index global 'ScarlettBossFight' (a nil value)
stack traceback:

        [C]: in function '__index'
        data/actions/scripts/ezipsoft/scarlett_bossFight.lua:1: in main chunk
[Warning - Event::checkScript] Can not load script: scripts/ezipsoft/scarlett_bossFight.lua
scripts/quests/grave_danger/cobra_bastion/scarlett.lua
Lua:
local info = {
    bossName = "Scarlett Etzel",
    middle = Position(33395, 32662, 6),
    fromPos = Position(33385, 32638, 6),
    toPos = Position(33406, 32660, 6),
    exitPos = Position(33395, 32670, 6),
    timer = Storage.GraveDanger.CobraBastion.ScarlettTimer,
    armorId = 36317,
    armorPos = Position(33398, 32640, 6)
}

local transformTo = {
    [36309] = 36310,
    [36310] = 36311,
    [36311] = 36312,
    [36312] = 36309
}

local function createArmor(id, amount, pos)
    local armor = Game.createItem(id, amount, pos)
    if armor then armor:setActionId(4962) end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local playersTable = {}
    if item.actionid == 4961 then
        if doCheckBossRoom(player:getId(), info.bossName, info.fromPos, info.toPos) then
            for x = info.middle.x - 1, info.middle.x + 1 do
                for y = info.middle.y - 1, info.middle.y + 1 do
                    local sqm = Tile(Position(x, y, 6))
                    if sqm and sqm:getGround():getId() == 20293 then
                        local player_ = sqm:getTopCreature()
                        if player_ and player_:isPlayer() then
                            if player_:getStorageValue(info.timer) > os.time() then
                                player_:getPosition():sendMagicEffect(CONST_ME_POFF)
                                player_:sendCancelMessage('You are still exhausted from your last battle.')
                                return true
                            end
                            table.insert(playersTable, player_:getId())
                        end
                    end
                end
            end
            for _, p in pairs(playersTable) do
                local nPlayer = Player(p)
                if nPlayer then
                    nPlayer:teleportTo(Position(33395, 32656, 6))
                    nPlayer:setStorageValue(info.timer, os.time() + 20*60*60)
                end
            end
            local scarlett = Game.createMonster("Scarlett Etzel", Position(33396, 32640, 6))
            if scarlett then
                scarlett:registerEvent('scarlettThink')
            end
            SCARLETT_MAY_TRANSFORM = 0
            addEvent(kickPlayersAfterTime, 30*60*1000, playersTable, info.fromPos, info.toPos, info.exitPos)
        end
    elseif item.actionid == 4962 then
        if isInArray(transformTo, item.itemid) then
            local pilar = transformTo[item.itemid]
            if pilar then
                item:transform(pilar)
                item:getPosition():sendMagicEffect(CONST_ME_POFF)
            end
        elseif item.itemid == info.armorId then
            item:getPosition():sendMagicEffect(CONST_ME_THUNDER)
            item:remove(1)
            player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You hold the old chestplate of Galthein in front of you. It does not fit and far too old to withstand any attack.")
            addEvent(createArmor, 20*1000, info.armorId, 1, info.armorPos)
            SCARLETT_MAY_TRANSFORM = 1
            addEvent(function()
                SCARLETT_MAY_TRANSFORM = 0
            end, 6*1000)
        end
    end
    return true
end
data/actions/scripts/ezipsoft/scarlett_bossFight.lua
Lua:
local config = ScarlettBossFight.config

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getLevel() < config.requiredLevel then
        player:sendTextMessage(MESSAGE_INFO_DESCR, string.format("You must be atlest level %d to use this item.", config.requiredLevel))
        return true
    end

    local validPosition = false
    for _, position in ipairs(config.playerPositions) do
        if position == player:getPosition() then
            validPosition = true
            break
        end
    end

    local leverPosition = item:getPosition()
    if not validPosition then
        return false
    end

    if ScarlettBossFight.room.time > os.time() then
        player:say(string.format('You must wait %s before entrace on this area.', showTimeLeft(ScarlettBossFight.room.time - os.time(), true)), TALKTYPE_MONSTER_SAY, false, nil, leverPosition)
        return true
    end

    if player:getStorageValue(config.storage) >= os.time() then
        player:say(string.format('You must wait %s before fight again with the boss.', showTimeLeft(player:getStorageValue(config.storage) - os.time(), true)), TALKTYPE_MONSTER_SAY, false, nil, leverPosition)
        return true
    end

    local leverPosition = item:getPosition()

    local players = { }
    for _, position in pairs(config.playerPositions) do
        local tile = Tile(position)
        if tile then
            local topCreature = tile:getTopCreature()
            if topCreature and topCreature:isPlayer() then
                if topCreature:getStorageValue(config.storage) >= os.time() then
                    topCreature:say(string.format('%s must wait %s before fight again with the boss.', topCreature:getName(), showTimeLeft(topCreature:getStorageValue(config.storage) - os.time(), true)), TALKTYPE_MONSTER_SAY, false, nil, leverPosition)
                    return true
                end

                if topCreature:getLevel() < config.requiredLevel then
                    player:sendTextMessage(MESSAGE_STATUS_SMALL, "All the players need to be level ".. config.requiredLevel .." or higher.")
                    return true
                end
                
                players[#players + 1] = topCreature
            end
        end
    end

    local specs = Game.getSpectators(config.centerPosition, false, false, 10, 10, 10, 10)
    for i = 1, #specs do
        local spec = specs[i]
        if spec:isPlayer() then
            player:sendTextMessage(MESSAGE_STATUS_SMALL, "There is someone already inside this room.")
            return true
        end
    end

    local specs = Game.getSpectators(config.centerPosition, false, false, 7, 7, 7, 7)
    for i = 1, #specs do
        local spec = specs[i]
        if spec:isMonster() then
            spec:remove()
        end
    end

    local monster = Game.createMonster(config.monstersSpawn.name, config.monstersSpawn.position)
    if not monster then
        return
    end

    local newPosition = Position(config.newPosition.x + 1, config.newPosition.y, config.newPosition.z)
    for i = 1, #players do
        local tmpPlayer = players[i]
        config.playerPositions[i]:sendMagicEffect(CONST_ME_POFF)

        newPosition = Position(newPosition.x + 1, newPosition.y, newPosition.z)
        tmpPlayer:teleportTo(newPosition)
        newPosition:sendMagicEffect(CONST_ME_TELEPORT)

        tmpPlayer:setDirection(DIRECTION_NORTH)
        tmpPlayer:setStorageValue(config.storage, os.time() + (20 * 3600))
    end

    ScarlettBossFight.room.time = os.time() + (20 * 60)
    ScarlettBossFight.room.id = ScarlettBossFight.room.id + 1
    ScarlettBossFight.room.activated = true
    ScarlettBossFight.room.canReceiveDamage = false
    ScarlettBossFight.room.monsterId = monster:getId()

    ScarlettBossFight:createArmorItem()
    ScarlettBossFight:randomizeMirrors()

    addEvent(
        function(ScarlettBossFight)
            ScarlettBossFight:createArmorItem()
        end,
        math.random(30, 40) * 1000, ScarlettBossFight
    )

    ScarlettBossFight.room.mirrorsEvent = addEvent(
        function(ScarlettBossFight)
            ScarlettBossFight:changeMirrors()
        end, 20 * 1000, ScarlettBossFight
    ) -- Muda os espelhos da sala a cada 20 segundos
    
    addEvent(
        function(roomId)
            ScarlettBossFight:clearRoom(roomId)
        end, 20 * 60 * 1000, ScarlettBossFight.room.id
    )   
    return true
end
Post automatically merged:

solved--
some storages missing and i have to add it
 
Last edited:
Back
Top