4Marsupilami
Intermediate OT User
- Joined
- Feb 25, 2016
- Messages
- 64
- Reaction score
- 120
Hey Tibian Brothers,
I don't like it when I see new scripts that duplicate the same code many times. That's why today I offer you a new feature that will say goodbye to the senseless duplication of one code.
The Game.sendTextOnPosition(message, position[, effect = false]) function has three parameters:
I will show this on the example of TP room text / effects:
I don't like it when I see new scripts that duplicate the same code many times. That's why today I offer you a new feature that will say goodbye to the senseless duplication of one code.
The Game.sendTextOnPosition(message, position[, effect = false]) function has three parameters:
- message - message content
- position - text and effects display position
- effect - Type of effect (optional parameter)
I will show this on the example of TP room text / effects:
- This is the standard script: GlobalEvent - [TFS 1.0/1.1] TP room text/effects (https://otland.net/threads/tfs-1-0-1-1-tp-room-text-effects.228820/)
- This is a script with the Game.sendTextOnPosition function:
Lua:
local effects = {
{position = Position(1000, 1000, 7), text = false, effect = CONST_ME_GROUNDSHAKER},
{position = Position(1000, 1002, 7), text = 'TP Room', effect = false}, -- text only
{position = Position(1002, 1000, 7), text = 'Event', effect = CONST_ME_GROUNDSHAKER},
}
function onThink(interval)
for i = 1, #effects do
local settings = effects[i]
Game.sendTextOnPosition(settings.text, settings.position, settings.effect)
end
return true
end
- Installation:
Lua:
function Game.sendTextOnPosition(message, position, effect)
local spectators = Game.getSpectators(position, false, false, 7, 7, 5, 5)
if #spectators > 0 then
if message then
for i = 1, #spectators do
spectators[i]:say(message, TALKTYPE_MONSTER_SAY, false, spectators[i], position)
end
end
if effect then
position:sendMagicEffect(effect)
end
end
return true
end
Simple and effective