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

Bad Argument #2

Simonalina

Member
Joined
May 10, 2008
Messages
179
Solutions
1
Reaction score
14
Location
Sweden
So i got this damn error...

Using TFS 1.3 on a realmap 10.98

but this i just can't figure out...

Lua Script Error: [Action Interface]
data/actions/scripts/quests/pits of inferno/levers.lua:eek:nUse
data/actions/scripts/quests/pits of inferno/levers.lua:32: bad argument #2 to 'max' (number expected, got nil)
stack traceback:
[C]: at 0x7ff657675db0
[C]: in function 'max'
data/actions/scripts/quests/pits of inferno/levers.lua:32: in function <data/actions/scripts/quests/pits of inferno/levers.lua:27>
 
Solution
That looks like ORTS. Adding GlobalStorage.PitsOfInfernoLevers in this table should fix it:
Lua:
local startupGlobalStorages = {GlobalStorage.TheAncientTombs.AshmunrahSwitchesGlobalStorage, GlobalStorage.TheAncientTombs.DiprathSwitchesGlobalStorage, GlobalStorage.TheAncientTombs.ThalasSwitchesGlobalStorage, GlobalStorage.PitsOfInfernoLevers}
OP
Simonalina

Simonalina

Member
Joined
May 10, 2008
Messages
179
Solutions
1
Reaction score
14
Location
Sweden
Maybe post script levers.lua?
Lua:
local text = {
    [1] = 'first', [2] = 'second', [3] = 'third', [4] = 'fourth', [5] = 'fifth',
    [6] = 'sixth', [7] = 'seventh', [8] = 'eighth', [9] = 'ninth', [10] = 'tenth',
    [11] = 'eleventh', [12] = 'twelfth', [13] = 'thirteenth', [14] = 'fourteenth', [15] = 'fifteenth'
}

local stonePositions = {
    Position(32851, 32333, 12),
    Position(32852, 32333, 12)
}

local function createStones()
    for i = 1, #stonePositions do
        Game.createItem(1304, 1, stonePositions[i])
    end

    Game.setStorageValue(GlobalStorage.PitsOfInfernoLevers, 0)
end

local function revertLever(position)
    local leverItem = Tile(position):getItemById(1946)
    if leverItem then
        leverItem:transform(1945)
    end
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid ~= 1945 then
        return false
    end

    local leverCount = math.max(0, Game.getStorageValue(GlobalStorage.PitsOfInfernoLevers))
    if item.uid > 2049 and item.uid < 2065 then
        local number = item.uid - 2049
        if leverCount + 1 ~= number then
            return false
        end

        Game.setStorageValue(GlobalStorage.PitsOfInfernoLevers, number)
        player:say('You flipped the ' .. text[number] .. ' lever. Hurry up and find the next one!', TALKTYPE_MONSTER_SAY, false, player, toPosition)
    elseif item.uid == 2065 then
        if leverCount ~= 15 then
            player:say('The final lever won\'t budge... yet.', TALKTYPE_MONSTER_SAY)
            return true
        end

        local stone
        for i = 1, #stonePositions do
            stone = Tile(stonePositions[i]):getItemById(1304)
            if stone then
                stone:remove()
                stonePositions[i]:sendMagicEffect(CONST_ME_EXPLOSIONAREA)
            end
        end

        addEvent(createStones, 15 * 60 * 1000)
    end

    item:transform(1946)
    addEvent(revertLever, 15 * 60 * 1000, toPosition)
    return true
end
 

forgee

Veteran OT User
Joined
May 9, 2011
Messages
321
Solutions
16
Reaction score
270
Location
Sweden
GitHub
forgee
That looks like ORTS. Adding GlobalStorage.PitsOfInfernoLevers in this table should fix it:
Lua:
local startupGlobalStorages = {GlobalStorage.TheAncientTombs.AshmunrahSwitchesGlobalStorage, GlobalStorage.TheAncientTombs.DiprathSwitchesGlobalStorage, GlobalStorage.TheAncientTombs.ThalasSwitchesGlobalStorage, GlobalStorage.PitsOfInfernoLevers}
 
Solution

Gesior.pl

Mega Noob&LOL 2012
Senator
Premium User
Joined
Sep 18, 2007
Messages
2,350
Solutions
42
Reaction score
1,778
Location
Poland
GitHub
gesior
Global storage "GlobalStorage.PitsOfInfernoLevers" is not defined. It should be defined in some 'onStartup' script. It's value should be probably 1.
 
OP
Simonalina

Simonalina

Member
Joined
May 10, 2008
Messages
179
Solutions
1
Reaction score
14
Location
Sweden
this one i already have :/
Lua:
local startupGlobalStorages = {GlobalStorage.TheAncientTombs.AshmunrahSwitchesGlobalStorage, GlobalStorage.TheAncientTombs.DiprathSwitchesGlobalStorage, GlobalStorage.TheAncientTombs.ThalasSwitchesGlobalStorage}
 

Gesior.pl

Mega Noob&LOL 2012
Senator
Premium User
Joined
Sep 18, 2007
Messages
2,350
Solutions
42
Reaction score
1,778
Location
Poland
GitHub
gesior
this one i already have :/
Lua:
local startupGlobalStorages = {GlobalStorage.TheAncientTombs.AshmunrahSwitchesGlobalStorage, GlobalStorage.TheAncientTombs.DiprathSwitchesGlobalStorage, GlobalStorage.TheAncientTombs.ThalasSwitchesGlobalStorage}
He meant you should add it there, so it will look like this (added at end):
Code:
local startupGlobalStorages = {GlobalStorage.TheAncientTombs.AshmunrahSwitchesGlobalStorage, GlobalStorage.TheAncientTombs.DiprathSwitchesGlobalStorage, GlobalStorage.TheAncientTombs.ThalasSwitchesGlobalStorage, GlobalStorage.PitsOfInfernoLevers}
 
OP
Simonalina

Simonalina

Member
Joined
May 10, 2008
Messages
179
Solutions
1
Reaction score
14
Location
Sweden
Global storage "GlobalStorage.PitsOfInfernoLevers" is not defined. It should be defined in some 'onStartup' script. It's value should be probably 1.
so i just need to change
Code:
    local leverCount = math.max(0, Game.getStorageValue(GlobalStorage.PitsOfInfernoLevers))

into

Code:
    local leverCount = math.max(1, Game.getStorageValue(GlobalStorage.PitsOfInfernoLevers))
 

Gesior.pl

Mega Noob&LOL 2012
Senator
Premium User
Joined
Sep 18, 2007
Messages
2,350
Solutions
42
Reaction score
1,778
Location
Poland
GitHub
gesior
so i just need to change
Code:
    local leverCount = math.max(0, Game.getStorageValue(GlobalStorage.PitsOfInfernoLevers))

into

Code:
    local leverCount = math.max(1, Game.getStorageValue(GlobalStorage.PitsOfInfernoLevers))
It may also fix this problem.
 
OP
Simonalina

Simonalina

Member
Joined
May 10, 2008
Messages
179
Solutions
1
Reaction score
14
Location
Sweden
He meant you should add it there, so it will look like this (added at end):
Code:
local startupGlobalStorages = {GlobalStorage.TheAncientTombs.AshmunrahSwitchesGlobalStorage, GlobalStorage.TheAncientTombs.DiprathSwitchesGlobalStorage, GlobalStorage.TheAncientTombs.ThalasSwitchesGlobalStorage, GlobalStorage.PitsOfInfernoLevers}
now im confused...

this is the script,


Code:
local startupGlobalStorages = {GlobalStorage.TheAncientTombs.AshmunrahSwitchesGlobalStorage, GlobalStorage.TheAncientTombs.DiprathSwitchesGlobalStorage, GlobalStorage.TheAncientTombs.ThalasSwitchesGlobalStorage}

function onStartup()
    print(string.format('>> Loaded %d npcs and spawned %d monsters.\n>> Loaded %d towns with %d houses in total.', Game.getNpcCount(), Game.getMonsterCount(), #Game.getTowns(), #Game.getHouses()))
    for i = 1, #startupGlobalStorages do
        Game.setStorageValue(startupGlobalStorages[i], 0)
    end

    db.query("TRUNCATE TABLE `players_online`")
    db.asyncQuery("DELETE FROM `guild_wars` WHERE `status` = 0")
    db.asyncQuery("DELETE FROM `players` WHERE `deletion` != 0 AND `deletion` < " .. os.time())
    db.asyncQuery("DELETE FROM `ip_bans` WHERE `expires_at` != 0 AND `expires_at` <= " .. os.time())
    db.asyncQuery("DELETE FROM `market_history` WHERE `inserted` <= " .. (os.time() - configManager.getNumber(configKeys.MARKET_OFFER_DURATION)))

    -- Move expired bans to ban history
    local resultId = db.storeQuery("SELECT * FROM `account_bans` WHERE `expires_at` != 0 AND `expires_at` <= " .. os.time())
    if resultId ~= false then
        repeat
            local accountId = result.getNumber(resultId, "account_id")
            db.asyncQuery("INSERT INTO `account_ban_history` (`account_id`, `reason`, `banned_at`, `expired_at`, `banned_by`) VALUES (" .. accountId .. ", " .. db.escapeString(result.getString(resultId, "reason")) .. ", " .. result.getNumber(resultId, "banned_at") .. ", " .. result.getNumber(resultId, "expires_at") .. ", " .. result.getNumber(resultId, "banned_by") .. ")")
            db.asyncQuery("DELETE FROM `account_bans` WHERE `account_id` = " .. accountId)
        until not result.next(resultId)
        result.free(resultId)
    end

    -- Check house auctions
    local resultId = db.storeQuery("SELECT `id`, `highest_bidder`, `last_bid`, (SELECT `balance` FROM `players` WHERE `players`.`id` = `highest_bidder`) AS `balance` FROM `houses` WHERE `owner` = 0 AND `bid_end` != 0 AND `bid_end` < " .. os.time())
    if resultId ~= false then
        repeat
            local house = House(result.getNumber(resultId, "id"))
            if house then
                local highestBidder = result.getNumber(resultId, "highest_bidder")
                local balance = result.getNumber(resultId, "balance")
                local lastBid = result.getNumber(resultId, "last_bid")
                if balance >= lastBid then
                    db.query("UPDATE `players` SET `balance` = " .. (balance - lastBid) .. " WHERE `id` = " .. highestBidder)
                    house:setOwnerGuid(highestBidder)
                end
                db.asyncQuery("UPDATE `houses` SET `last_bid` = 0, `bid_end` = 0, `highest_bidder` = 0, `bid` = 0 WHERE `id` = " .. house:getId())
            end
        until not result.next(resultId)
        result.free(resultId)
    end

    -- store towns in database
    db.query("TRUNCATE TABLE `towns`")
    for i, town in ipairs(Game.getTowns()) do
        local position = town:getTemplePosition()
        db.query("INSERT INTO `towns` (`id`, `name`, `posx`, `posy`, `posz`) VALUES (" .. town:getId() .. ", " .. db.escapeString(town:getName()) .. ", " .. position.x .. ", " .. position.y .. ", " .. position.z .. ")")
    end
end
 

forgee

Veteran OT User
Joined
May 9, 2011
Messages
321
Solutions
16
Reaction score
270
Location
Sweden
GitHub
forgee
now im confused...

this is the script,


Code:
local startupGlobalStorages = {GlobalStorage.TheAncientTombs.AshmunrahSwitchesGlobalStorage, GlobalStorage.TheAncientTombs.DiprathSwitchesGlobalStorage, GlobalStorage.TheAncientTombs.ThalasSwitchesGlobalStorage}

function onStartup()
    print(string.format('>> Loaded %d npcs and spawned %d monsters.\n>> Loaded %d towns with %d houses in total.', Game.getNpcCount(), Game.getMonsterCount(), #Game.getTowns(), #Game.getHouses()))
    for i = 1, #startupGlobalStorages do
        Game.setStorageValue(startupGlobalStorages[i], 0)
    end

    db.query("TRUNCATE TABLE `players_online`")
    db.asyncQuery("DELETE FROM `guild_wars` WHERE `status` = 0")
    db.asyncQuery("DELETE FROM `players` WHERE `deletion` != 0 AND `deletion` < " .. os.time())
    db.asyncQuery("DELETE FROM `ip_bans` WHERE `expires_at` != 0 AND `expires_at` <= " .. os.time())
    db.asyncQuery("DELETE FROM `market_history` WHERE `inserted` <= " .. (os.time() - configManager.getNumber(configKeys.MARKET_OFFER_DURATION)))

    -- Move expired bans to ban history
    local resultId = db.storeQuery("SELECT * FROM `account_bans` WHERE `expires_at` != 0 AND `expires_at` <= " .. os.time())
    if resultId ~= false then
        repeat
            local accountId = result.getNumber(resultId, "account_id")
            db.asyncQuery("INSERT INTO `account_ban_history` (`account_id`, `reason`, `banned_at`, `expired_at`, `banned_by`) VALUES (" .. accountId .. ", " .. db.escapeString(result.getString(resultId, "reason")) .. ", " .. result.getNumber(resultId, "banned_at") .. ", " .. result.getNumber(resultId, "expires_at") .. ", " .. result.getNumber(resultId, "banned_by") .. ")")
            db.asyncQuery("DELETE FROM `account_bans` WHERE `account_id` = " .. accountId)
        until not result.next(resultId)
        result.free(resultId)
    end

    -- Check house auctions
    local resultId = db.storeQuery("SELECT `id`, `highest_bidder`, `last_bid`, (SELECT `balance` FROM `players` WHERE `players`.`id` = `highest_bidder`) AS `balance` FROM `houses` WHERE `owner` = 0 AND `bid_end` != 0 AND `bid_end` < " .. os.time())
    if resultId ~= false then
        repeat
            local house = House(result.getNumber(resultId, "id"))
            if house then
                local highestBidder = result.getNumber(resultId, "highest_bidder")
                local balance = result.getNumber(resultId, "balance")
                local lastBid = result.getNumber(resultId, "last_bid")
                if balance >= lastBid then
                    db.query("UPDATE `players` SET `balance` = " .. (balance - lastBid) .. " WHERE `id` = " .. highestBidder)
                    house:setOwnerGuid(highestBidder)
                end
                db.asyncQuery("UPDATE `houses` SET `last_bid` = 0, `bid_end` = 0, `highest_bidder` = 0, `bid` = 0 WHERE `id` = " .. house:getId())
            end
        until not result.next(resultId)
        result.free(resultId)
    end

    -- store towns in database
    db.query("TRUNCATE TABLE `towns`")
    for i, town in ipairs(Game.getTowns()) do
        local position = town:getTemplePosition()
        db.query("INSERT INTO `towns` (`id`, `name`, `posx`, `posy`, `posz`) VALUES (" .. town:getId() .. ", " .. db.escapeString(town:getName()) .. ", " .. position.x .. ", " .. position.y .. ", " .. position.z .. ")")
    end
end
Look at the first line. It's missing GlobalStorage.PitsOfInfernoLevers.
 
OP
Simonalina

Simonalina

Member
Joined
May 10, 2008
Messages
179
Solutions
1
Reaction score
14
Location
Sweden
yea thanks didn't se first now i understand! now it works!

Now just need to understand why this damn Real-Map have "Action ID: 152/153/110" and so on on Pick...

I just know that pick work with 105.. if i change in
Lua:
actionIds = {
    sandHole = 100, -- hidden sand hole
    pickHole = 105, 152, -- hidden mud hole
    levelDoor = 1000, -- level door
}

that don't help.. still won't work.. damn this map.. haha
 
Top