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

Animated Texts Script

Marco Oliveira

Well-Known Member
Joined
Jan 5, 2019
Messages
76
Solutions
3
Reaction score
77
Location
Minas Gerais - Brazil
GitHub
omarcopires
Twitch
omarcopires
Short description:
This GlobalEvent creates an event called "Animated Texts" that runs every 20 seconds. Inside the onThink function, a loop is looped through a list of effects (which is not defined in this code) and for each effect it is checked if there are players within a given area around the effect position. If there are players in the area, it checks to see if there is text and an effect associated with the effect. If the text exists, it is sent to all players within the area. If the effect exists, it is sent to the effect position. At the end of the function, true is returned to keep the event running.

animatedTextsEvent.lua
Lua:
-- Table containing the effects to be applied to the positions
local effects = {
    {text = "Depots", position = Position(1000, 1000, 7), effect = CONST_ME_TUTORIALSQUARE},
}

-- Create the global event
local animatedTextsEvent = GlobalEvent("Animated Texts")

-- Function that will be called every 20 seconds by the event
function animatedTextsEvent.onThink(interval)
    -- Iterate over the effects table
    for i, effect in ipairs(effects) do
        -- Retrieve the list of players that are watching the specific position
        local spectators = Game.getSpectators(effect.position, false, true, 8, 8, 8, 8)
        if #spectators > 0 then
            -- If there's a text to display, make all the spectators say the text
            if effect.text then
                for i = 1, #spectators do
                    spectators[i]:say(effect.text, TALKTYPE_MONSTER_SAY, false, spectators[i], effect.position)
                end
            end

            -- If there's an effect to display, send the effect to the position
            if effect.magicEffect then
                effect.position:sendMagicEffect(effect.magicEffect)
            end
        end
    end
    return true
end

-- Register the event and set the interval between onThink calls to 20 seconds
animatedTextsEvent:interval(20 * 1000)
animatedTextsEvent:register()
 
don't know why is not working for me, have added all the commits into my tfs and edited compat.lua
 
don't know why is not working for me, have added all the commits into my tfs and edited compat.lua

Any errors? His script has default functions
No clue why he calls it animatedText
confusing for new players
 
Tested on Canary source (based on tfs). Nice!

EDIT: I find an issue:

For those who are experiencing issues with the animations, you need to do the following:

Text are displayed correctly, but not the animated effects. This is because the variable name is not the same as the array:

Lua:
local effects = {
    {text = "Depots", position = Position(1000, 1000, 7), effect = CONST_ME_TUTORIALSQUARE},
}

Lua:
            if effect.magicEffect then
                effect.position:sendMagicEffect(effect.magicEffect)
            end

To fix this you only need to change "effect" to "magicEffect"

Saludos amigo!
 
Last edited:
Short description:
This GlobalEvent creates an event called "Animated Texts" that runs every 20 seconds. Inside the onThink function, a loop is looped through a list of effects (which is not defined in this code) and for each effect it is checked if there are players within a given area around the effect position. If there are players in the area, it checks to see if there is text and an effect associated with the effect. If the text exists, it is sent to all players within the area. If the effect exists, it is sent to the effect position. At the end of the function, true is returned to keep the event running.

animatedTextsEvent.lua
Lua:
-- Table containing the effects to be applied to the positions
local effects = {
    {text = "Depots", position = Position(1000, 1000, 7), effect = CONST_ME_TUTORIALSQUARE},
}

-- Create the global event
local animatedTextsEvent = GlobalEvent("Animated Texts")

-- Function that will be called every 20 seconds by the event
function animatedTextsEvent.onThink(interval)
    -- Iterate over the effects table
    for i, effect in ipairs(effects) do
        -- Retrieve the list of players that are watching the specific position
        local spectators = Game.getSpectators(effect.position, false, true, 8, 8, 8, 8)
        if #spectators > 0 then
            -- If there's a text to display, make all the spectators say the text
            if effect.text then
                for i = 1, #spectators do
                    spectators[i]:say(effect.text, TALKTYPE_MONSTER_SAY, false, spectators[i], effect.position)
                end
            end

            -- If there's an effect to display, send the effect to the position
            if effect.magicEffect then
                effect.position:sendMagicEffect(effect.magicEffect)
            end
        end
    end
    return true
end

-- Register the event and set the interval between onThink calls to 20 seconds
animatedTextsEvent:interval(20 * 1000)
animatedTextsEvent:register()


Is there any other way we can do this so it does not uses players, monsters or npcs with tibia 13?

I have issue with it now, when I have like 25 texts in various locations.

For example in temple I have 2 texts and when any player says something his words sort of shake and looks a bit wrong I will send gif example soon.

client_HBPKVvyKVJ.gif
 
Last edited:
Back
Top