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

[Event] Walkthrough everything Ctrl + Arrow keys [TFS 1.X]

Printer

if Printer then print("LUA") end
Senator
Premium User
Joined
Dec 27, 2009
Messages
5,782
Solutions
31
Reaction score
2,284
Location
Sweden?
Hello,

Well some people have requested this missing feature which could be found in 0.3 series. Well i have made one for TFS 1.x.

I will send a pull request to the forgottenserver project, but in case it may not be accepted. Due to, this is mby a personal future. This way is alot better than 0.3, since 0.3 was hardcoded while this is made by lua with few lines. Which make it even more easier to edit stuff.

Go to events/events.xml and onTurn make sure write from 0 to 1.
Now go to events/scripts and open player.lua and find Player:eek:nTurn(direction) and replace with this:
Code:
function Player:onTurn(direction)
    if self:getGroup():getAccess() and self:getDirection() == direction then
        local nextPosition = self:getPosition()
        nextPosition:getNextPosition(direction)

        self:teleportTo(nextPosition, true)
    end

    return true
end

Cheers.
 
Last edited:
Hello :)
I'm testing it and I found two problems:
  1. You can't just turn your character direction without moving too
  2. The whole account get this benefit, while it should only affect the GOD character
 
Hello :)
I'm testing it and I found two problems:
  1. You can't just turn your character direction without moving too
  2. The whole account get this benefit, while it should only affect the GOD character
That is what it meant todo, it should not autowalk to that direction ^^

About the second thing you could replace:
Code:
if self:getAccountType() == ACCOUNT_TYPE_GOD then
with:
Code:
if self:getGroup():getId() == 3 then
 
I know this is what it's meant todo, but in 0.3 you could turn yourself (without moving), and then after a sec (with the keys pressed) the character started to walkthrough. I mean, you can't turn yourself without moving, do you get it now?
 
I know this is what it's meant todo, but in 0.3 you could turn yourself (without moving), and then after a sec (with the keys pressed) the character started to walkthrough. I mean, you can't turn yourself without moving, do you get it now?
No? Just hold ctrl + arrow key. Then it should walkthrough walls.
 
No? Just hold ctrl + arrow key. Then it should walkthrough walls.
It shouldn't move the player if the parameter direction is not the same as player direction.

Replace
Code:
if self:getAccountType() == ACCOUNT_TYPE_GOD then
with
Code:
if self:getDirection() == direction and self:getGroup():getAccess() then
 
It shouldn't move the player if the parameter direction is not the same as player direction.

Replace
Code:
if self:getAccountType() == ACCOUNT_TYPE_GOD then
with
Code:
if self:getDirection() == direction and self:getGroup():getAccess() then
Oh, now i see. But i like the way i did :p
 
Here is same way as it works on 0.4:
Code:
local dir = {}
function Player:onTurn(direction)
  if self:getAccountType() == ACCOUNT_TYPE_GOD then
     local cid = self:getId()
     if not dir[cid] then
       dir[cid] = direction
       return true
     end
   
     if dir[cid] == direction then
       local nextPosition = self:getPosition()
       nextPosition:getNextPosition(direction)
       dir[cid] = direction
       self:teleportTo(nextPosition, true)
     else
       dir[cid] = direction
     end
  end
  return true
end

info: if script doesn't work and there are no errors set this in events.xml to "1" as here:
Code:
<event class="Player" method="onTurn" enabled="1" />
 
Why are you using table to store player direction? :p
 
@zbizu But you don't need to store player direction in a table in order to make it work like TFS 0.4 :p

Code:
function Player:onTurn(direction)
    if self:getDirection() == direction and self:getGroup():getAccess() then
        local nextPosition = self:getPosition()
        nextPosition:getNextPosition(direction)

        self:teleportTo(nextPosition, true)
    end
    return true
end
 
Should edit main paste with ninjas code as printers wont work with TFS 1.2 =)
 
Hi guys, this script is really nice, I tried to remake it for monster spell(so monster can go through players and other monsters, but no blocking objects like walls), but I failed. This is where I get so far. I wanted to make it for TFS 1.2.
Code:
function onCastSpell(creature, var) 
    local direction = creature:getDirection()
    local nextPosition = creature:getPosition()
    if (queryTileAddThing(creature, nextPosition) == RETURNVALUE_NOERROR) then
        nextPosition:getNextPosition(direction)
         
        creature:teleportTo(nextPosition, true)
    end
    return true
end
Actually it works only for players + it checks if item is blockable only when you are already teleported on it :/, it wouldn't be so bad, but it still don't work for monsters, dunno why. It only works when I remove queryTileAddThing line, but it gives monster opportunity to walk on walls etc. I am sorry if it's not good thread for that, but I didn't wanted to make new one just to fix some easy(I suppose :D) thing. Would be also good if it moves creatures on its way(just like giant spider pushes minotaur for example).
Thanks for any help :).
 
Last edited:
Hello I want this ability on my server, but im using OThire 2.0 so how should my script look like and where should I put it? I dont have events on my OT since its not newer versions
 
How do you do instead of moving with Ctrl+Arrows (direction look), just press arrows and moves on.
Also, if this is possible it should be allowed only between players and in pz tiles, nothing else.
 
Back
Top