• 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 TFS [1.2] Alternative Stair toPosition

Leo32

Getting back into it...
Joined
Sep 21, 2007
Messages
990
Solutions
14
Reaction score
551
I'm using a movement script to point stairs to an alternative position.
This is working as intended at the moment:

XhPEoTf.png


i12Kwrw.png


Code:
local pos = {x = 1191, y = 736, z = 8}

function onStepIn(creature, item, position, fromPosition)
   local player = creature:getPlayer()
   if player == nil then
     return false
   end
     player:teleportTo(pos)
     player:setDirection(SOUTH)
   return true
end

What I am having trouble with, is replicating teleporting ITEMS when you move them on-to the stairs as-well.
Anyone got any ideas on the cleanest way to do this?

Not looking for a hand-hold, just a pointer in the right direction.
 
I've tried this:

Code:
local pos = {x = 1079, y = 570, z = 7}

-- NOTE THIS SECTION HERE
function onAddItem(moveitem, tileitem, position)
   moveitem:teleportTo(pos)
   return true
end
-- END

function onStepIn(creature, item, position, fromPosition, cid)
   local player = creature:getPlayer()
   if player == nil then
     return false
   end
     player:teleportTo(pos)
     player:setDirection(NORTH)
   return true
end

Code:
  <movevent event="AddItem" actionid="110" script="stairtp_down.lua" />
   <movevent event="AddItem" actionid="111" script="stairtp_up.lua" />

And while there are no errors...
Nothing occurs, (this was tested using a normal ground tile to ensure the stair tile code was not interupting - i seem to just be failing with the syntax).
 
Code:
function onAddItem(moveitem, tileitem, position)
   doTeleportThing(moveitem, pos)
  return true
end

Works.
Won't work on stair tiles, default stair code seems to execute first, which makes sense.

Movements script:

Code:
local pos = {x = 1191, y = 736, z = 8}

function onAddItem(moveitem, tileitem, position)
   doTeleportThing(moveitem, pos)
  return true
end

function onStepIn(creature, item, position, fromPosition)
   local player = creature:getPlayer()
   if player == nil then
     return false
   end
     player:teleportTo(pos)
     player:setDirection(SOUTH)
   return true
end

The actionid is set directly on the stair tile, which works fine for PLAYERS and the normal stair code doesnt trigger.

For the items to work, I've had to do this underneath:
eyJQDwo.png


So items dragged to the stairs actually go:

x= 1079, y = 571 , z = 7 to;
x= 1079, y = 571 , z = 8 which THEN goes to;
x = 1191, y = 736, z = 8

This is working as intended, however is a work-around due to lack of expertise.
If anyone has a better solution, I'd love to hear it.
 
Last edited:
Back
Top