• 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 Movement is not checking storage value TFS1.3

Taurus

Texass
Joined
Jan 11, 2009
Messages
616
Solutions
2
Reaction score
30
Location
United States
This piece of syntax is driving me nuts, I've tried every logical way I can think of... too many to post.

Why doesn't the script check the storage value?

LUA:
local destinations = {
    [41011] = Position(31809, 32277, 8),
    [41010] = Position(31805, 32277, 8),
}

function onStepIn(creature, item, position, fromPosition)
    local player = creature:getPlayer()
    if not player then
        return false
    end

    if player:getStorageValue(2213) == 1 then
        player:teleportTo(fromPosition)
        return true
    end

    player:teleportTo(destinations[item.uid])
    player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
    return true
end

Instead it just sends them right thru. (This script is a copy of the poi tible tile script. You can't pass unless you have the item, I'm just trying to make it where you have to have the storage instead.... Like a questdoor but not reliant on actionId.

Should be simple...
 
Solution
If the storage value 2213 is 1 then the player should be teleported back?
Did you mean 2213) == -1 then ..

So if the player hasn't got that storage value set s/he get's teleported to fromPosition = back.
If they have it set (I guess 1?) then it should teleport them to the destination.

So either change it to == -1 or ~= 1
If the storage value 2213 is 1 then the player should be teleported back?
Did you mean 2213) == -1 then ..

So if the player hasn't got that storage value set s/he get's teleported to fromPosition = back.
If they have it set (I guess 1?) then it should teleport them to the destination.

So either change it to == -1 or ~= 1
 
Solution
If the storage value 2213 is 1 then the player should be teleported back?
Did you mean 2213) == -1 then ..

So if the player hasn't got that storage value set s/he get's teleported to fromPosition = back.
If they have it set (I guess 1?) then it should teleport them to the destination.

So either change it to == -1 or ~= 1
So here's the thing, that's the way the script WAS originally, and it didn't work for some odd reason. I might have just gotten confused. So anyway I (being frustrated) copied what you wrote and put it in just to prove you wrong... of course it worked and my problem is solved.

A little bit of magic happened here, not the good kind lmfao. Thanks all the same.
 

Similar threads

Back
Top