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

[TFS 1.2] Teleport Pad System (Rewrite)

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,391
Solutions
7
Reaction score
550
Hello Otland!
I have rewrote the tele pad system original made by @Fresh which can be found HERE My one however is a bit different. It was inspired by Harry Potters Floo powder.

Example of how the system looks:
(Gif rec screwed the colours and hides mouse.. Basically you have to use the floo powder bottle on yourself to activate the window.)
N6zTESY.gif

This script also requires @Non Sequitur modal window system which can be found HERE

You will have to install that in order to be able to use this system.

Why use this one instead?
Much cleaner then the last version you just need to add the action script and the lib files. There is no need to register the scripts on login.lua or add creaturescripts!

Information on the system
It has an easy config section for you to customize it how you would like it! You just need to fill out the config table found in the action script (pictured below)

Adding a Telepad Spot
To add a telepad you need to add a unique ID to the tile you want to to make as the spot.

CONFIG TABLE

Code:
floo_powder = {
    tileID = 25262,
    unlockMsg = "You have unlocked ",
-- Window Configuration
    titleMsg = "Floo Powder Teleport System",
    mainMsg = "Select a location to be teleported too.\n\nYou are currently at:\n",
-- End Window Configuration

-- Teleport Spots
    teleport_spots = {
        [1] = {
            name = "Thais Depot", -- Name of the spot (What is shown in the window)
            storage = 10001, -- This storage tells the system what spots are unlocked
            uid = 2291, -- The unique ID of the teleport spot "This is more for your records really.. "
            direction = DIRECTION_SOUTH, -- This is the direction your player will face when he is teleported to another pad IT MUST BE CAPITALS!
            description = "The Thais Depot",
        },

Installation


1) Install the modal window helper HERE
2) Register the script in /data/actions/actions.xml by adding this line (Replacing "ITEMID" with the item you want to be required to use on yourself
Code:
<action itemid="ITEMID" script="floo_powder.lua"/>
3) Create a new text document in /data/actions/scripts and name it "floo_powder.lua" and paste the following:
Code:
floo_powder = {
    tileID = 25262,
    unlockMsg = "You have unlocked ",
-- Window Configuration
    titleMsg = "Floo Powder Teleport System",
    mainMsg = "Select a location to be teleported too.\n\nYou are currently at:\n",
-- End Window Configuration

-- Teleport Spots
    teleport_spots = {
        [1] = {
            name = "Thais Depot", -- Name of the spot (What is shown in the window)
            storage = 10001, -- This storage tells the system what spots are unlocked
            uid = 2291, -- The unique ID of the teleport spot "This is more for your records really.. "
            direction = DIRECTION_SOUTH, -- This is the direction your player will face when he is teleported to another pad IT MUST BE CAPITALS!
            description = "The Thais Depot",
        },
      
        [2] = {
            name = "Harry Potter",
            storage = 10023,
            uid = 2311,
            direction = DIRECTION_SOUTH,
            description = "Shops!",
        },
    },
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local tile = target:getTile()
local items = tile:getItems()
local spot = nil
    if items then
        for i = 1, #items do
            if items[i]:getId() == floo_powder.tileID then
                local spot = items[i]:getUniqueId()
                if target:isPlayer() then
                    player:sendFlooPowderWindow(spot, target)
                    return true
                else
                    player:say("Maybe I should get in the fireplace first..", TALKTYPE_MONSTER_SAY)
                end
            end 
        end
    end
end


4) Add the following line to your global.lua:
Code:
dofile('data/lib/floo_powder.lua')
5) Create a new text document in /data/lib/ and name it "floo_powder.lua" and paste the following:
Code:
function Player:sendFlooPowderWindow(spot, target)

    -- This loop is used to determine which teleport pad they are using.
    local function buttonCallback(button, choice)
    local spotName = nil
    for i = 1, #floo_powder.teleport_spots do
        if floo_powder.teleport_spots[i].uid == spot then
            spotName = floo_powder.teleport_spots[i].name
            break
        end
    end
    -- Modal window functionallity
        if button.text == "Confirm" then
            if spotName == floo_powder.teleport_spots[choice.id].name then
                self:say("I'm already at "..spotName, TALKTYPE_MONSTER_SAY)
                return true
            end
            self:removeItem(25260, 1)
            target:getPosition():sendMagicEffect(174)
            target:say(floo_powder.teleport_spots[choice.realid].name, TALKTYPE_MONSTER_SAY)
            self:teleportTo(Item(floo_powder.teleport_spots[choice.realid].uid):getPosition())
            self:setDirection(floo_powder.teleport_spots[choice.realid].direction)
            self:getPosition():sendMagicEffect(174)
            self:say(floo_powder.teleport_spots[choice.realid].name, TALKTYPE_MONSTER_SAY)
        end
      
        if button.text == "Info" then
            self:showTextDialog(25260, floo_powder.teleport_spots[choice.realid].description)
            self:sendFlooPowderWindow(spot)
        end
    end
  
-- Modal window design

    -- This loop is used to determine which teleport pad they are using.
    local spotName = nil
    for i = 1, #floo_powder.teleport_spots do
        if floo_powder.teleport_spots[i].uid == spot then
            spotName = floo_powder.teleport_spots[i].name
            break
        end
    end
  
    local window = ModalWindow {
        title = floo_powder.titleMsg, -- Title of the modal window
        message = floo_powder.mainMsg..spotName,
    }
    -- Add buttons to the window (Note: if you change the names of these you must change the functions in the modal window functionallity!)
    window:addButton("Exit")
    window:addButton("Info", buttonCallback)
    window:addButton("Confirm", buttonCallback)

    -- Set what button is pressed when the player presses enter or escape
    window:setDefaultEnterButton("Confirm")
    window:setDefaultEscapeButton("Exit")

    -- Add choices from the action script
    for i = 1, #floo_powder.teleport_spots do
        if self:getStorageValue(floo_powder.teleport_spots[i].storage) > 0 then
            local o = floo_powder.teleport_spots[i].name
            local choice = window:addChoice(o)
            choice.realid = i
        end
    end

    -- Send the window to player
    window:sendToPlayer(self)
end

6) Add the following line to /data/movements/movements.xml Replacing TILE ID with your telepad itemID
Code:
        <movevent event="StepIn" itemid="TILE ID" script="floo_powder.lua"/>
7) Make a new text file in /data/movements/scripts and name it floo_powder.lua
8) Paste the following:

Code:
function onStepIn(player, item, position, fromPosition)

local index = nil
for i = 1, #floo_powder.teleport_spots do
    if floo_powder.teleport_spots[i].uid == item.uid then
        index = i
        break
    end
end

    if index == nil then
        print("Error::Cannot find the tile Unique ID in your config table.")
        return true
    end
    
    if player:getStorageValue(floo_powder.teleport_spots[index].storage) < 1 then
        player:setStorageValue(floo_powder.teleport_spots[index].storage, 1)
        player:say(floo_powder.unlockMsg..floo_powder.teleport_spots[index].name.."!", TALKTYPE_MONSTER_SAY)
    end
end

Enjoy =)
 
Last edited:
@strutZ
I tried this with another item (cursed gold, 24115), I changed ids in lib/script.lua and in actions/actions.xml.
And I got a debug info (teleporter works after logging again):
bfZPaLx.png
 
@strutZ
I tried this with another item (cursed gold, 24115), I changed ids in lib/script.lua and in actions/actions.xml.
And I got a debug info (teleporter works after logging again):
bfZPaLx.png

Oh whoops sorry man i just realized i used a custom effect in this script..
Replace this
Code:
self:getPosition():sendMagicEffect(174)

With this
Code:
self:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)

on both line 19 and 23 of the lib file.

If you get stuck just give me a bit re writing most of my scripts so everything is easily done from the config table.
 
Oh whoops sorry man i just realized i used a custom effect in this script..
Replace this
Code:
self:getPosition():sendMagicEffect(174)

With this
Code:
self:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)

on both line 19 and 23 of the lib file.

If you get stuck just give me a bit re writing most of my scripts so everything is easily done from the config table.
Everything is fine now, thank you for that system :)
btw. I used (CONST_ME_THUNDER) , quite cool :p
 
Lua Script Error: [Action Interface]
data/actions/scripts/floo_powder.lua:eek:nUse
data/actions/scripts/floo_powder.lua:30: attempt to call method 'getTile' (a nil value)
stack traceback:
[C]: in function 'getTile'
data/actions/scripts/floo_powder.lua:30: in function <data/actions/scripts/floo_powder.lua:29>
 
Lua Script Error: [Action Interface]
data/actions/scripts/floo_powder.lua:eek:nUse
data/actions/scripts/floo_powder.lua:30: attempt to call method 'getTile' (a nil value)
stack traceback:
[C]: in function 'getTile'
data/actions/scripts/floo_powder.lua:30: in function <data/actions/scripts/floo_powder.lua:29>
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local tile = Tile(target:getPosition)
local items = tile:getItems()
local spot = nil
    if items then
        for i = 1, #items do
            if items[i]:getId() == floo_powder.tileID then
                local spot = items[i]:getUniqueId()
                if target:isPlayer() then
                    player:sendFlooPowderWindow(spot, target)
                    return true
                else
                    player:say("Maybe I should get in the fireplace first..", TALKTYPE_MONSTER_SAY)
                end
            end
        end
    end
end
 
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local tile = Tile(target:getPosition)
local items = tile:getItems()
local spot = nil
    if items then
        for i = 1, #items do
            if items[i]:getId() == floo_powder.tileID then
                local spot = items[i]:getUniqueId()
                if target:isPlayer() then
                    player:sendFlooPowderWindow(spot, target)
                    return true
                else
                    player:say("Maybe I should get in the fireplace first..", TALKTYPE_MONSTER_SAY)
                end
            end
        end
    end
end

[Warning - Event::checkScript] Can not load script: scripts/floo_powder.lua
data/actions/scripts/floo_powder.lua:30: function arguments expected near ')'
 
[Warning - Event::checkScript] Can not load script: scripts/floo_powder.lua
data/actions/scripts/floo_powder.lua:30: function arguments expected near ')'
oops. amended my previous post
 
Looks like i cant edit posts...


Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local tile = Tile(target:getPosition())
local items = tile:getItems()
local spot = nil
    if items then
        for i = 1, #items do
            if items[i]:getId() == floo_powder.tileID then
                local spot = items[i]:getUniqueId()
                if target:isPlayer() then
                    player:sendFlooPowderWindow(spot, target)
                    return true
                else
                    player:say("Maybe I should get in the fireplace first..", TALKTYPE_MONSTER_SAY)
                end
            end
        end
    end
end
 
Dont say me that this item doesn't exist in tibia because I just f**ked all the RAW Palette to find it..
 
Trying This out ... And here is my errors
Tfs Used : 1.2
Error 1:
Lua:
Error::Cannot find the tile Unique ID in your config table.
The error above shows when i step in the configured Tile

Error 2 :
Lua:
Lua Script Error: [Action Interface]
data/actions/scripts/floo_powder.lua:onUse
data/actions/scripts/floo_powder.lua:30: attempt to call method 'getPosition' (a
nil value)
stack traceback:
        [C]: in function 'getPosition'
        data/actions/scripts/floo_powder.lua:30: in function <data/actions/scrip
ts/floo_powder.lua:29>
The error above happends when i Use the item Configured "Inside Or outside the already configured TIle"

Anythoughts ?

More Info
The Whole onuse function (Line 29 and below)
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local tile = Tile(target:getPosition())
local items = tile:getItems()
local spot = nil
    if items then
        for i = 1, #items do
            if items[i]:getId() == floo_powder.tileID then
                local spot = items[i]:getUniqueId()
                if target:isPlayer() then
                    player:sendFlooPowderWindow(spot, target)
                    return true
                else
                    player:say("Maybe I should get in the fireplace first..", TALKTYPE_MONSTER_SAY)
                end
            end
        end
    end
end
 
Trying This out ... And here is my errors
Tfs Used : 1.2
Error 1:
Lua:
Error::Cannot find the tile Unique ID in your config table.
The error above shows when i step in the configured Tile

Error 2 :
Lua:
Lua Script Error: [Action Interface]
data/actions/scripts/floo_powder.lua:onUse
data/actions/scripts/floo_powder.lua:30: attempt to call method 'getPosition' (a
nil value)
stack traceback:
        [C]: in function 'getPosition'
        data/actions/scripts/floo_powder.lua:30: in function <data/actions/scrip
ts/floo_powder.lua:29>
The error above happends when i Use the item Configured "Inside Or outside the already configured TIle"

Anythoughts ?

More Info
The Whole onuse function (Line 29 and below)
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local tile = Tile(target:getPosition())
local items = tile:getItems()
local spot = nil
    if items then
        for i = 1, #items do
            if items[i]:getId() == floo_powder.tileID then
                local spot = items[i]:getUniqueId()
                if target:isPlayer() then
                    player:sendFlooPowderWindow(spot, target)
                    return true
                else
                    player:say("Maybe I should get in the fireplace first..", TALKTYPE_MONSTER_SAY)
                end
            end
        end
    end
end
anybody could solve this?
 
Back
Top