• 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] sendAnimatedNumber

Dbzl

New Member
Joined
Jan 22, 2017
Messages
34
Reaction score
1
Thanks to @Colandus for showing me how it's done in tfs 1.x in a thread while ago.

Code:
function Position:sendAnimatedNumber(message_type, text, value, color)
    local message_type = message_type or MESSAGE_EXPERIENCE
    local color = color or TEXTCOLOR_BLUE

    local valid_message_types = {
        MESSAGE_DAMAGE_DEALT,
        MESSAGE_DAMAGE_OTHERS,
        MESSAGE_DAMAGE_RECEIVED,
        MESSAGE_EXPERIENCE,
        MESSAGE_HEALED,
        MESSAGE_HEALED_OTHERS,
    }

    assert(isInArray(valid_message_types, message_type), "invalid 'message_type', must output to server log")

    for _, v in ipairs(Game.getSpectators(self, false, true)) do
        if v:isPlayer() then
            v:sendTextMessage(message_type, text, self, value, color)
        end
    end
end

This isn't the best code ever, but it was what I could do with some info @Colandus sent me. =p

@ edited the code so it can follow the tfs coding pattern
 
Last edited:
you could put the table outside of the function that way it doesn't get redefined every time it executes
 
what exactly it do, or you can give an exemple of the usage of this
 
Last edited:
what exactly it do, or you can give an exemple of the usage of this
I am on phone now but this is a simple function that tries to imitate the old TFS animated text the best way possible (since it cant be done anymore with strings)
a simple way to use it is sending a mana healing text:
Code:
function onSay(player)
     local healing_value = 100
     player:addMana(healing_value)
     player:getPosition():sendAnimatedNumber(MESSAGE_HEALED, "You got healed.", healing_value, 200)

     return false
end
(coding on phone is tough lol)

@Xeraphus Thanks for the tip. Imma edit it as soon as I get to pc.
 
Problem is only that as the code I showed you had 2 parts where it sends the text. One for the player who is being healed and another for the spectators. That's because the message would be different. You want to tell the actual player "You got healed." But to the spectators "name was healed."
 
Problem is only that as the code I showed you had 2 parts where it sends the text. One for the player who is being healed and another for the spectators. That's because the message would be different. You want to tell the actual player "You got healed." But to the spectators "name was healed."
You are right, I missed it. Sadly I can't edit it now since I am without intetnet connection cus I am moving homes. But as soon as I get to my new home Imma correct all these things.
 
Back
Top