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

TFS 1.X+ [TFS 1.4.2] NPC Error: Argument -1 has out-of-range value for unsigned int: -1

Unknown Soldier

Mapping a map
Joined
Oct 30, 2010
Messages
263
Solutions
11
Reaction score
621
Hello,

I'm getting an error when I want to trade with NPC. It appears in console after saying "trade". Trade window pops up, everythign seems to be working. What is messed up here?

Thanks in advance!

Code:
Lua Script Error: [Npc interface]
data/npc/scripts/runes.lua:onCreatureSay
LuaScriptInterface::getNumber(). Argument -1 has out-of-range value for unsigned int: -1
stack traceback:
        [C]: in function 'openShopWindow'
        data/npc/lib/npcsystem/modules.lua:1089: in function 'callback'
        data/npc/lib/npcsystem/keywordhandler.lua:26: in function 'processMessage'
        data/npc/lib/npcsystem/keywordhandler.lua:151: in function 'processNodeMessage'
        data/npc/lib/npcsystem/keywordhandler.lua:126: in function 'processMessage'
        data/npc/lib/npcsystem/npchandler.lua:408: in function 'onCreatureSay'
        data/npc/scripts/runes.lua:7: in function <data/npc/scripts/runes.lua:7>
 

Attachments

Solution
Well, I won't act like I understand... 😵

I only want to point out, that this happens in official 1.4.2 release, with none changes from me in fact, only with replaced map and items folder, it might be a problem for everyone that would want to use 1.4.2.

Is there any other solution except changing the TFS version? Possibly repairing 1.4.2 release?
You do not need to change the version, just apply the changes that I mention, in your case you should only make these changes:
Currently they haven't been applied to the official TFS 1.4.2 branch but they will be over time, don't worry.
Do you get a similar error when equipping items (with attributes) to empty slots, And also when equipping items from corpses and/or ground?
 
Do you get a similar error when equipping items (with attributes) to empty slots, And also when equipping items from corpses and/or ground?
Didn't notice anything like that. Taking an item from the ground/corpse to an empty slot works good, no errors appearing. Tried with various types of eq.

When equipping items from ground or corpses the only thing I noticed is cancel "There is not enough room" when trying to swap equipment. But it seems intentional.
Post automatically merged:

Do you get a similar error when equipping items (with attributes) to empty slots, And also when equipping items from corpses and/or ground?
But I just noticed I get similar error when trying to go upstairs on a ladder placed like that (no additional script used here for the ladder, just default)

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/teleport.lua:onUse
LuaScriptInterface::getNumber(). Argument -1 has out-of-range value for unsigned short: -1
stack traceback:
        [C]: in function '__add'
        data/lib/core/position.lua:38: in function 'moveUpstairs'
        data/actions/scripts/other/teleport.lua:4: in function <data/actions/scripts/other/teleport.lua:2>

error ladder.png
 
Last edited:
the getNumber method was modified and now exact number types are validated
in this case an unsigned integer is expected and you are trying to pass a signed number as an argument
in tfs master these corrections were applied after the change

REF:
 
the getNumber method was modified and now exact number types are validated
in this case an unsigned integer is expected and you are trying to pass a signed number as an argument
in tfs master these corrections were applied after the change

REF:
So this would solve it? I had to revert those to solve the issue.
Was writing reverting as a solution tho, In the meantime, you wrote this. I will try.
Didn't notice anything like that. Taking an item from the ground/corpse to an empty slot works good, no errors appearing. Tried with various types of eq.

When equipping items from ground or corpses the only thing I noticed is cancel "There is not enough room" when trying to swap equipment. But it seems intentional.
Post automatically merged:


But I just noticed I get similar error when trying to go upstairs on a ladder placed like that (no additional script used here for the ladder, just default)

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/teleport.lua:onUse
LuaScriptInterface::getNumber(). Argument -1 has out-of-range value for unsigned short: -1
stack traceback:
        [C]: in function '__add'
        data/lib/core/position.lua:38: in function 'moveUpstairs'
        data/actions/scripts/other/teleport.lua:4: in function <data/actions/scripts/other/teleport.lua:2>

View attachment 69389
You'll get an error when you equip items if you tried to use/add onMoveItem script I believe.
 
Last edited:
So this would solve it? I had to revert those to solve the issue.
If many warnings appear in your console it is because you have scripts that pass invalid numbers to methods. reversing the PR is omitting our misuse of numbers.
example:
If we're trying to get a creature by ID, we have to use something like: local creature = Creature(1)
If we try to do local creature = Creature(-1) makes no sense, since an unsigned number is expected.
The same with others methods.

This is not necessarily about unsigned or signed numbers, but also about the limits of each type of number, so if a method expects int8_t, it will throw a warning if it passes a higher or much lower number.
 
the getNumber method was modified and now exact number types are validated
in this case an unsigned integer is expected and you are trying to pass a signed number as an argument
in tfs master these corrections were applied after the change

REF:
Well, I won't act like I understand... 😵

I only want to point out, that this happens in official 1.4.2 release, with none changes from me in fact, only with replaced map and items folder, it might be a problem for everyone that would want to use 1.4.2.

Is there any other solution except changing the TFS version? Possibly repairing 1.4.2 release?
 
Well, I won't act like I understand... 😵

I only want to point out, that this happens in official 1.4.2 release, with none changes from me in fact, only with replaced map and items folder, it might be a problem for everyone that would want to use 1.4.2.

Is there any other solution except changing the TFS version? Possibly repairing 1.4.2 release?
You do not need to change the version, just apply the changes that I mention, in your case you should only make these changes:
Currently they haven't been applied to the official TFS 1.4.2 branch but they will be over time, don't worry.
 
Solution
You do not need to change the version, just apply the changes that I mention, in your case you should only make these changes:
Currently they haven't been applied to the official TFS 1.4.2 branch but they will be over time, don't worry.

Okay, I'll try, thanks!
 
You do not need to change the version, just apply the changes that I mention, in your case you should only make these changes:
Currently they haven't been applied to the official TFS 1.4.2 branch but they will be over time, don't worry.
So it helped, no more errors during trade :) Thank you!

However the error with ladder remains. I guess I could just create another script for ladders that are placed like this, they are minority anyway. But maybe there is some quick solution to the script, that are use for ladders, could you just take a look at the script below?

error-ladder-png.69389

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/teleport.lua:onUse
LuaScriptInterface::getNumber(). Argument -1 has out-of-range value for unsigned short: -1
stack traceback:
        [C]: in function '__add'
        data/lib/core/position.lua:38: in function 'moveUpstairs'
        data/actions/scripts/other/teleport.lua:4: in function <data/actions/scripts/other/teleport.lua:2>

Lua:
local upFloorIds = {1386, 3678, 5543, 22845, 22846, 33892, 33893}
function 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
 
Last edited:
So it helped, no more errors during trade :) Thank you!

However the error with ladder remains. I guess I could just create another script for ladders that are placed like this, they are minority anyway. But maybe there is some quick solution to the script, that are use for ladders, could you just take a look at the script below?

error-ladder-png.69389

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/teleport.lua:onUse
LuaScriptInterface::getNumber(). Argument -1 has out-of-range value for unsigned short: -1
stack traceback:
        [C]: in function '__add'
        data/lib/core/position.lua:38: in function 'moveUpstairs'
        data/actions/scripts/other/teleport.lua:4: in function <data/actions/scripts/other/teleport.lua:2>

Lua:
local upFloorIds = {1386, 3678, 5543, 22845, 22846, 33892, 33893}
function 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
its map error you should have there an transparent "move floor down tile"
 
You do not need to change the version, just apply the changes that I mention, in your case you should only make these changes:
Currently they haven't been applied to the official TFS 1.4.2 branch but they will be over time, don't worry.
Its strange, i'v had the issues with the npc and those changes i applied them and fixed the NPC error but stairs are still giving console error as @Unknown Soldier had, i have diffrent type of "downstair" but same type of up stair. Is there any new fixs for this? I could not find any threads about it xD
1671605411051.png
1671605440073.png
 
the getNumber method was modified and now exact number types are validated
in this case an unsigned integer is expected and you are trying to pass a signed number as an argument
in tfs master these corrections were applied after the change

REF:
Old post, but I love you!
 
You do not need to change the version, just apply the changes that I mention, in your case you should only make these changes:
Currently they haven't been applied to the official TFS 1.4.2 branch but they will be over time, don't worry.
@Sarah Wesker where do i put this code, i am not that good at scripting so If you could explain to me please.
 
So it helped, no more errors during trade :) Thank you!

However the error with ladder remains. I guess I could just create another script for ladders that are placed like this, they are minority anyway. But maybe there is some quick solution to the script, that are use for ladders, could you just take a look at the script below?

error-ladder-png.69389

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/teleport.lua:onUse
LuaScriptInterface::getNumber(). Argument -1 has out-of-range value for unsigned short: -1
stack traceback:
        [C]: in function '__add'
        data/lib/core/position.lua:38: in function 'moveUpstairs'
        data/actions/scripts/other/teleport.lua:4: in function <data/actions/scripts/other/teleport.lua:2>

Lua:
local upFloorIds = {1386, 3678, 5543, 22845, 22846, 33892, 33893}
function 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

how did you fix the npcs problem?

I run tfs 1.4.2, removed the red lines and added the green ones on the sources, but now i get this error

1703315099311.png
 
Back
Top