• 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 Problem with getSlotPosition() function

Gover

Member
Joined
Sep 3, 2009
Messages
72
Reaction score
19
Hello everyone,
I'm facing an issue with function getSlotPosition().
I'm using below attached script (I have edited /attr function to test this getSlotPosition)

LUA:
local talkaction = TalkAction("/read")

function talkaction.onSay(player, words, param)
    if not player:getGroup():getAccess() then
        return true
    end

    local position = player:getPosition()
    position:getNextPosition(player:getDirection())

    local tile = Tile(position)
    local thing = tile:getTopVisibleThing(player)
    if not thing then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "There is an empty tile in front of you.")
        return false
    end

    local itemType = thing:getType()
    local slot = itemType:getSlotPosition() - SLOTP_LEFT - SLOTP_RIGHT
        if slot == SLOTP_HEAD or slot == SLOTP_ARMOR or slot == SLOTP_LEGS or slot == SLOTP_FEET or slot == SLOTP_NECKLACE or slot == SLOTP_RING then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "Supported")
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Not Supported. Value: " .. itemType:getSlotPosition() .. "")
            return false
        end

end

talkaction:register()

In standard Nekiro 1.5 772 this function is working great, but in my new engine - it is not working at all.

I found on this github post, that standard values for feet and head should be 176 and 49.

Slot position (feet): 176
Slot position (head): 49

And in Nekiro 1.5 772 it is returning the same values as on this github, but in my new engine - i dont know why - all the values are increased by 512.

The helmets (slot Head) is returning 561 (561-49=512), the boots (slot Feet) is returning 688 (688-176=512). It looks like it is hardcoded somewhere in C++. I tried to compare source files with standard nekiro 1.5 with WinMerge and the sections containing SLOTP_VALUE are everywhere the same


C++:
    // Use with itemType:getSlotPosition
    registerEnum(SLOTP_WHEREEVER)
    registerEnum(SLOTP_HEAD)
    registerEnum(SLOTP_NECKLACE)
    registerEnum(SLOTP_BACKPACK)
    registerEnum(SLOTP_ARMOR)
    registerEnum(SLOTP_RIGHT)
    registerEnum(SLOTP_LEFT)
    registerEnum(SLOTP_LEGS)
    registerEnum(SLOTP_FEET)
    registerEnum(SLOTP_RING)
    registerEnum(SLOTP_AMMO)
    registerEnum(SLOTP_DEPOT)
    registerEnum(SLOTP_TWO_HAND)

Getting the weapon type is working great. The issue is only with armors, legs, helmets, rings, necklaces, boots. The below is returning correcttly:
LUA:
   local weaponType = thing:getWeaponType()
    if weaponType > 0 then
        if weaponType == WEAPON_AMMO then
            return false
        end
        if
            weaponType == WEAPON_SHIELD or weaponType == WEAPON_DISTANCE or weaponType == WEAPON_WAND or
                isInArray({WEAPON_SWORD, WEAPON_CLUB, WEAPON_AXE}, weaponType)
         then
            return true
        end

Do maybe someone have an idea how I can solve this issue?

Thanks in advance.


EDIT:
Found a solution.
Chanigng:
local slot = itemType:getSlotPosition() - SLOTP_LEFT - SLOTP_RIGHT
to:
local slot = (itemType:getSlotPosition() - SLOTP_LEFT - SLOTP_RIGHT)-512

Solved the issue.
 
Last edited:

Similar threads

Back
Top