• 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 GlobalStorageValue error

d4rkbl0od

Member
Joined
Mar 21, 2008
Messages
160
Reaction score
7
Hello,

When I trie to use this on the script:

Code:
local config = { 
    [1092] = Storage.Grimvale.lever1,
    [1093] = Storage.Grimvale.lever2,
    [1094] = Storage.Grimvale.lever3,
    [1095] = Storage.Grimvale.lever4,
    [1096] = Storage.Grimvale.lever5   
}

, the console gives the error:
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/Grimvale/levers.lua:onUse
data/lib/core/game.lua:67: table index is nil
stack traceback:
        [C]: in function '__newindex'
        data/lib/core/game.lua:67: in function 'setStorageValue'
        data/lib/compat/compat.lua:955: in function 'setGlobalStorageValue'
        data/actions/scripts/Grimvale/levers.lua:13: in function <data/actions/scripts/Grimvale/levers.lua:10>
Here is the full script.

Code:
local config = { 
    [1092] = Storage.Grimvale.lever1,
    [1093] = Storage.Grimvale.lever2,
    [1094] = Storage.Grimvale.lever3,
    [1095] = Storage.Grimvale.lever4,
    [1096] = Storage.Grimvale.lever5   
}


function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local lever = config[target.actionid]
    if getGlobalStorageValue(lever) <= 0 then
        setGlobalStorageValue(lever, 1)
        local claro = Tile(Position(toPosition.x, (toPosition.y + getGlobalStorageValue(lever)) + 1, toPosition.z)):getItemById(424)   
        claro:transform(457)
        local normal = Tile(Position(toPosition.x, toPosition.y + getGlobalStorageValue(lever), toPosition.z)):getItemById(457)   
        normal:transform(424)
    elseif getGlobalStorageValue(lever) > 0 and getGlobalStorageValue(lever) < 4 then
        setGlobalStorageValue(lever, getGlobalStorageValue(lever) + 1)
        local claro = Tile(Position(toPosition.x, (toPosition.y + getGlobalStorageValue(lever)) + 1, toPosition.z)):getItemById(424)   
        claro:transform(457)
        local normal = Tile(Position(toPosition.x, toPosition.y + getGlobalStorageValue(lever), toPosition.z)):getItemById(457)   
        normal:transform(424)
    elseif getGlobalStorageValue(lever) == 4 then
        setGlobalStorageValue(lever, 0)
        local claro = Tile(Position(toPosition.x, (toPosition.y + getGlobalStorageValue(lever)) + 1, toPosition.z)):getItemById(424)   
        claro:transform(457)
        local normal = Tile(Position(toPosition.x, toPosition.y + getGlobalStorageValue(lever) + 5, toPosition.z)):getItemById(457)   
        normal:transform(424)
    end
return true
end

When I put the storage inside the globalstorage, it works, but when I put the list of storages, it gets this error. Any help?
 
Yup...

Code:
    Grimvale = {
        cursedStorage = 1076,
        questLine = 1077,
        monstersKill = 1078,
        blossom1 = 1079,
        blossom2 = 1080,
        blossom3 = 1081,
        blossomCount = 1082,
        grimvaleGlobal = 1083,
        vein1 = 1084,
        vein2 = 1085,
        vein3 = 1086,
        vein4 = 1087,
        vein5 = 1088,
        vein6 = 1089,
        vein7 = 1090,
        vein8 = 1091,
        vein9 = 1092,
        vein10 = 1093,
        vein11 = 1094,
        vein12 = 1095,
        vein13 = 1096,
        vein14 = 1097,
        lever1 = 1098,
        lever2 = 1099,
        lever3 = 1100,
        lever4 = 1101,
        lever5 = 1102   
    },
 
If its tfs 1.2 you should use
Game.getStorageValue and Game.setStorageValue
 
If its tfs 1.2 you should use
Game.getStorageValue and Game.setStorageValue
The strange thing, i'm trying to find the problem,

player:sendTextMessage(MESSAGE_EVENT_ADVANCE, configs[target.actionid])

The console : 23:00
Nothing more.. O.O


player:sendTextMessage(MESSAGE_EVENT_ADVANCE, target.actionid)
Console: 23:03 0

lol?

---- EDIT

Found the error:
The list of actionids was different from the storages.
 
Back
Top