Hello,
When I trie to use this on the script:
, the console gives the error:
Here is the full script.
When I put the storage inside the globalstorage, it works, but when I put the list of storages, it gets this error. Any help?
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>
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?