• 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 [1.2] Problem with movement script

Cornwallis

Member
Joined
Jan 3, 2010
Messages
480
Reaction score
16
I think it has to do with the storage value. Currently I have the storage set as 15000 value 15000 and it teleports me through the 15001 action id, but won't let me through 15000.

HTML:
local t = {
[{15000, {x = 988, y = 1005, z = 8}}] = "",
[{15001, {x = 1152, y = 988, z = 10}}] = ""
}

function onStepIn(creature, item, position, fromPosition)
    local player = Player(creature)
    if not Player(player) then
        return false
    end
    for k, v in pairs(t) do
        if item.actionid == k[1] and player:getStorageValue(15000) >= item.actionid then
            player:teleportTo(k[2], false)
            player:sendTextMessage(MESSAGE_INFO_DESCR, v)
            return true
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have not made it to this dungeon yet.")
            player:teleportTo(fromPosition, false)
            return false
        end
    end
end
 
what for you are using the value of the table?
Just curios because this function could look WAAAAAAY better..

don't understand what you wanted to do, but maybe because you are using static storage key 15000 in your function instead of the the storage key from table. k[1]
 
you should not structure your tables that way
you assign a key to a value, not assigning an empty string with array with values inside the key
you cant access them unless you loop using pairs

Code:
local t = {
    [15000] = {Position(988, 1005, 8), "this", 90001},
    [15001] = {Position(1152, 998, 10), "that", 90000}
}

function onStepIn(creature, item, position, fromPosition)
    local player = player:getCreature()
    local tmp = t[item.actionid]
    if not player then
        return false
    end
    if tmp then
        if player:getStorageValue(tmp[3]) == -1 then
          player:teleportTo(tmp[1])
          player:sendTextMessage(MESSAGE_INFO_DESCR, tmp[2])
          player:setStorageValue(tmp[3], 1)
       else
          player:sendTextMessage(MESSAGE_INFO_DESCR, "You have not made it to this dungeon yet.")
          player:teleportTo(fromPosition, true)
       end
    end
    return true
end
use this

edit: rewrote your script
 
Last edited:
Back
Top