• 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 Effect Script Convert from tfs 1.2 to 1.5

abdala ragab

Veteran OT User
Joined
Aug 18, 2018
Messages
461
Solutions
11
Reaction score
340
Location
gamelaot.sytes.net
XML:
<globalevent name="Text_Effect" interval="2000" script="text_effect.lua" />
Lua:
focus = 1
talk_start = 1
target = 1
following = true
attacking = true
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
end
function onCreatureTurn(creature)
end
function onCreatureSay(cid, type, msg)
end
function onCreatureChangeOutfit(creature)
end


local gdzie = {
                co = {-- w tej tabeli podajemy podtabele z wyswietlanym tekstem i miejscem w ktorym ma sie wyswietlic
                      {"Wellcome", {x=50, y=49, z=7}},
                      {"UpgrdeItems Info", {x=2995, y=3123, z=7}},
                      {"Hunting", {x=2988, y=3111, z=7}},
                      {"Quests", {x=2988, y=3113, z=7}},
                      {"City", {x=2995, y=3109, z=7}},
                      {"Npc", {x=2994, y=3127, z=7}},
                      {"Trainer", {x=2988, y=3115, z=7}},
                      {"Sms", {x=2998, y=3109, z=7}},
                      {"Info", {x=2988, y=3109, z=7}},
                      {"GameShop", {x=2988, y=3117, z=7}},   
                      {"{Vip Quest}", {x=1017, y=325, z=10}},
                      {"{Vip Hunt}", {x=1045, y=826, z=9}},
                      {"{Lms Event}", {x=869, y=1537, z=14}},
                      {"{Battle Event}", {x=863, y=1537, z=14}},
                      {"{Collecting Event}", {x=865, y=1537, z=14}},
                      {"{Zombie Event}", {x=867, y=1537, z=14}},
                      
                      --hunt --
                      {"150", {x=2580, y=3052, z=7}},
                      {"200", {x=2584, y=3052, z=7}},             
                      {"225", {x=2588, y=3052, z=7}},     
                      {"250", {x=2592, y=3052, z=7}},         
                      {"300", {x=2596, y=3052, z=7}},                     
                      {"350", {x=2600, y=3052, z=7}},                     
                      {"375", {x=2604, y=3052, z=7}},                     
                      {"400", {x=2608, y=3052, z=7}},                     
                      {"450", {x=2612, y=3052, z=7}},                     
                      {"500", {x=2616, y=3052, z=7}},                     
                      {"525", {x=2620, y=3052, z=7}},                     
                      {"550", {x=2624, y=3052, z=7}},                     
                      {"575", {x=2628, y=3052, z=7}},                     
                      {"600", {x=2632, y=3052, z=7}},                     
                      {"650", {x=2636, y=3052, z=7}},                     
                      {"675", {x=2640, y=3052, z=7}},
                      {"700", {x=2644, y=3052, z=7}},
                      {"800", {x=2648, y=3052, z=7}},
                      {"600", {x=2652, y=3052, z=7}},
                      {"750", {x=2656, y=3052, z=7}},
                      {"700", {x=2660, y=3052, z=7}},
                      {"500", {x=2628, y=3062, z=7}},
                      {"600", {x=2633, y=3062, z=7}},
                      {"700", {x=2638, y=3062, z=7}},
                      {"750", {x=2643, y=3062, z=7}},
                      {"800", {x=2648, y=3062, z=7}},
                      {"850", {x=2654, y=3062, z=7}},
                      --Rotworm--
                      {"Rotworm", {x=2580, y=3061, z=7}},
                      {"Orc", {x=2584, y=3061, z=7}},
                      {"Cyclops", {x=2588, y=3061, z=7}},
                      {"Dragon", {x=2592, y=3061, z=7}},
                      {"Dragon2", {x=2594, y=3061, z=7}},
                      {"Hydra", {x=2598, y=3061, z=7}},
                      {"Dragon Lord", {x=2602, y=3061, z=7}},
                      {"Behemoth", {x=2606, y=3061, z=7}},
                      {"Warlock", {x=2610, y=3061, z=7}},
                      {"Demon", {x=2614, y=3061, z=7}},
                      {"Orshabaal", {x=2618, y=3061, z=7}},
                      {"Ferumbras", {x=2622, y=3061, z=7}},
                      {"Orshabaal", {x=2626, y=3061, z=7}},
                      --quest Vip--
                      {"1000", {x=2591, y=3044, z=8}},
                      {"1000", {x=2591, y=3047, z=8}},
                      {"1000", {x=2591, y=3050, z=8}},
                      {"900", {x=2591, y=3053, z=8}},
                      {"1000", {x=2591, y=3056, z=8}},
                      {"1000", {x=2591, y=3059, z=8}},
                      {"1000", {x=2591, y=3062, z=8}},
                      {"1000", {x=2591, y=3065, z=8}},
                      {"1100", {x=2591, y=3068, z=8}},
                      --Hunt Vip--
                      {"700", {x=2598, y=3044, z=8}},
                      {"525", {x=2598, y=3047, z=8}},
                      {"700", {x=2598, y=3050, z=8}},
                      {"500", {x=2598, y=3053, z=8}},
                      {"500", {x=2598, y=3056, z=8}},
                      {"600", {x=2598, y=3059, z=8}},
                      {"750", {x=2598, y=3062, z=8}},
                      {"800", {x=2598, y=3065, z=8}},
                      {"600", {x=2598, y=3068, z=8}},
           --Normal Quest --
                      {"300", {x=2591, y=3044, z=9}},
                      {"550", {x=2591, y=3047, z=9}},
                      {"650", {x=2591, y=3050, z=9}},
                      {"700", {x=2591, y=3053, z=9}},
                      {"800", {x=2591, y=3056, z=9}},
                      {"800", {x=2591, y=3059, z=9}},
                      {"800", {x=2591, y=3062, z=9}},
                      {"850", {x=2591, y=3065, z=9}},
                      {"900", {x=2591, y=3068, z=9}},
                      
                      {"150", {x=2598, y=3044, z=9}},
                      {"550", {x=2598, y=3047, z=9}},
                      {"600", {x=2598, y=3050, z=9}},
                      {"700", {x=2598, y=3053, z=9}},
                      {"700", {x=2598, y=3056, z=9}},
                      {"777", {x=2598, y=3059, z=9}},
                      {"777", {x=2598, y=3062, z=9}},
                      {"850", {x=2598, y=3065, z=9}},
                      {"900", {x=2598, y=3068, z=9}},
                      --------- dp event --------
                                            {"Zombie", {x=2995, y=3117, z=7}},
                                          {"Collect", {x=2996, y=3117, z=7}},
                                          {"Lms", {x=2997, y=3117, z=7}},
                                          {"Battle", {x=2998, y=3117, z=7}},

                      

                  
                     },
                textcolors = {5, 18, 30, 35, 65, 95, 108, 129, 143, 154, 155, 180, 194, 198, 210, 215},
                efekty = {39, 20, 30, 40, 42, 44, 45, 46, 47, 48}, -- efekty ktore pojawiaja sie na danym miejscu
                coile = 1.5 -- czas w sekundach miedzy pojawieniami sie efektow
              }
function wyswietl(gdzie)
    for i=1, #gdzie.co do
        doSendAnimatedText(gdzie.co[i][1], gdzie.co[i][2], gdzie.textcolors[math.random(1, #gdzie.textcolors)])
        doSendMagicEffect(gdzie.co[i][2], gdzie.efekty[math.random(1, #gdzie.efekty)])
    end
    addEvent(wyswietl,(gdzie.coile*1300),gdzie)
    efektstart = 1
end
function onThink()
    if efektstart ~= 1 then
        addEvent(wyswietl,1,gdzie)
    end
end
The error
Code:
Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
LuaScriptInterface::luaDebugPrint(). Deprecated function.
stack traceback:
        [C]: in function 'debugPrint'
        data/lib/compat/compat.lua:665: in function 'doSendAnimatedText'
        data/globalevents/scripts/text_effect.lua:137: in function <data/globalevents/scripts/text_effect.lua:135>

Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
LuaScriptInterface::luaDebugPrint(). Deprecated function.
stack traceback:
        [C]: in function 'debugPrint'
        data/lib/compat/compat.lua:665: in function 'doSendAnimatedText'
        data/globalevents/scripts/text_effect.lua:137: in function <data/globalevents/scripts/text_effect.lua:135>
Help me solve this error, thank you in advance
 
Solution
Your script is quite messy and ugly... but I understand that you wanted random colored text to appear along with the right effect, correct? There is already something similar in Otland, so I adapted it to be very similar to yours... Try it out and give me feedback!

data/scripts.
Lua:
local effects = {
    {position = Position(50, 49, 7), text = 'Wellcome'},
    {position = Position(2995, 3123, 7), text = 'UpgradeItems Info'},
    {position = Position(2988, 3111, 7), text = 'Hunting'},
    {position = Position(2988, 3113, 7), text = 'Quests'},
    -- Add more here if desired
}

local globalevent = GlobalEvent("Text_Effect")
local effectsColors = {39, 20, 30, 40, 42, 44, 45, 46, 47, 48}

function globalevent.onThink(interval)
    for i =...
Your script is quite messy and ugly... but I understand that you wanted random colored text to appear along with the right effect, correct? There is already something similar in Otland, so I adapted it to be very similar to yours... Try it out and give me feedback!

data/scripts.
Lua:
local effects = {
    {position = Position(50, 49, 7), text = 'Wellcome'},
    {position = Position(2995, 3123, 7), text = 'UpgradeItems Info'},
    {position = Position(2988, 3111, 7), text = 'Hunting'},
    {position = Position(2988, 3113, 7), text = 'Quests'},
    -- Add more here if desired
}

local globalevent = GlobalEvent("Text_Effect")
local effectsColors = {39, 20, 30, 40, 42, 44, 45, 46, 47, 48}

function globalevent.onThink(interval)
    for i = 1, #effects do
        local settings = effects[i]
        local spectators = Game.getSpectators(settings.position, false, true, 7, 7, 5, 5)
        if #spectators > 0 then
            if settings.text then
                local textcolor = math.random(1, 215) -- Generates a random text color between 1 and 215
                Game.sendAnimatedText(settings.text, settings.position, textcolor)
            end
            local randomEffect = effectsColors[math.random(#effectsColors)]
            settings.position:sendMagicEffect(randomEffect)
        end
    end
    return true
end

globalevent:interval(2000) -- Interval in milliseconds
globalevent:register()
or
Lua:
local config = {
    locations = {
        {text = "Welcome", coords = {x=721, y=606, z=7}},
        {text = "Upgrade Items Info", coords = {x=722, y=607, z=7}},
      -- Add more locations as needed
    },
    textColors = {5, 18, 30, 35, 65, 95, 108, 129, 143, 154, 155, 180, 194, 198, 210, 215},
    effects = {39, 20, 30, 40, 42, 44, 45, 46, 47, 48},
    interval = 1.5 --czas w sekundach pomiędzy pojawieniem się efektów
}

function displayLocations()
    for _, location in ipairs(config.locations) do
        local text = location.text
        local coords = location.coords
       
        local randomColor = config.textColors[math.random(1, #config.textColors)]
        local randomEffect = config.effects[math.random(1, #config.effects)]
       
        local position = Position(coords.x, coords.y, coords.z)
        position:sendMagicEffect(randomEffect)
        Game.sendAnimatedText(text, position, randomColor)
    end
end

local globalevent = GlobalEvent("Text_Effect")

function globalevent.onThink(interval)
    displayLocations()
    return true
end

globalevent:interval(config.interval * 2000)
globalevent:register()
 
Last edited:
Solution
Your script is quite messy and ugly... but I understand that you wanted random colored text to appear along with the right effect, correct? There is already something similar in Otland, so I adapted it to be very similar to yours... Try it out and give me feedback!
Thank you it works well
 
Back
Top