Marco Oliveira
Well-Known Member
- Joined
- Jan 5, 2019
- Messages
- 78
- Solutions
- 3
- Reaction score
- 88
- Location
- Minas Gerais - Brazil
- GitHub
- omarcopires
- Twitch
- omarcopires
When going up a ladder on the server from position 1070, 1032, 5 to position 1070, 1031, 4, the console returns an error message regarding an out-of-range value for an unsigned short argument.
teleport.lua
function Position:moveUpstairs
Note: I tried some corrections but I didn't get success. My server is based on TFS (master) and the only change in this part of the code was to take the teleport.lua to revscript after adding some missing stairs, however the error already existed before when it was recorded in XML.
LUA:
Lua Script Error: [Scripts Interface]
D:\Repositorios Git\baiak-yurots\data\scripts\actions\others\teleport.lua:callback
LuaScriptInterface::getNumber(). Argument -1 has out-of-range value for unsigned short: -1
stack traceback:
data/lib/core/position.lua:43: in function 'moveUpstairs'
...it\baiak-yurots\data\scripts\actions\others\teleport.lua:7: in function <...it\baiak-yurots\data\scripts\actions\others\teleport.lua:5>
teleport.lua
LUA:
local upFloorIds = {1386, 3678, 5543, 22845, 22846, 31312, 33785, 33786, 33918, 36899}
local teleport = Action()
function teleport.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if table.contains(upFloorIds, item.itemid) then
fromPosition:moveUpstairs()
else
fromPosition.z = fromPosition.z + 1
end
if player:isPzLocked() and Tile(fromPosition):hasFlag(TILESTATE_PROTECTIONZONE) then
player:sendCancelMessage(RETURNVALUE_PLAYERISPZLOCKED)
return true
end
player:teleportTo(fromPosition, false)
return true
end
teleport:id(1386, 3678, 5543, 22845, 22846, 31312, 33785, 33786, 33918, 36899)
teleport:register()
function Position:moveUpstairs
LUA:
function Position:moveUpstairs()
local swap = function(lhs, rhs)
lhs.x, rhs.x = rhs.x, lhs.x
lhs.y, rhs.y = rhs.y, lhs.y
lhs.z, rhs.z = rhs.z, lhs.z
end
self.z = self.z - 1
local defaultPosition = self + Position.directionOffset[DIRECTION_SOUTH]
local toTile = Tile(defaultPosition)
if not toTile or not toTile:isWalkable() then
for direction = DIRECTION_NORTH, DIRECTION_NORTHEAST do
if direction == DIRECTION_SOUTH then
direction = DIRECTION_WEST
end
local position = self + Position.directionOffset[direction]
toTile = Tile(position)
if toTile and toTile:isWalkable() then
swap(self, position)
return self
end
end
end
swap(self, defaultPosition)
return self
end
Note: I tried some corrections but I didn't get success. My server is based on TFS (master) and the only change in this part of the code was to take the teleport.lua to revscript after adding some missing stairs, however the error already existed before when it was recorded in XML.