registerEventHandler("textStarted", "onTextStarted")
registerEventHandler("textStopped", "onTextStopped")
function onTextStarted(text)
local currentCharacter = game.CurrentCharacter
local owner = text:getLink(VTextOwner)
if owner:getId().tableId == eCharacters then
local isLeft = owner:getName() == currentCharacter:getName()
showTextBalloon(isLeft)
showHead(isLeft, owner:getName())
end
end
function onTextStopped(text)
local currentCharacter = game.CurrentCharacter
local owner = text:getLink(VTextOwner)
if owner:getId().tableId == eCharacters then
local isLeft = owner:getName() == currentCharacter:getName()
hideTextBalloon(isLeft)
hideHead(isLeft, owner:getName())
end
end
function getBaloon(isLeft)
if isLeft then
return getObject("Interfaces[baloon_left]")
end
return getObject("Interfaces[baloon_right]")
end
function getHead(isLeft, character)
if isLeft then
return getObject("Interfaces[head_left_"..string.lower(character).."]")
end
return getObject("Interfaces[head_right_"..string.lower(character).."]")
end
function showTextBalloon(isLeft)
local baloon = getBaloon(isLeft)
baloon.InterfaceVisible = true
baloon.InterfaceVisibility = 100
end
function hideTextBalloon(isLeft)
local baloon = getBaloon(isLeft)
baloon.InterfaceVisible = false
baloon.InterfaceVisibility = 0
end
function showHead(isLeft, character)
local head = getHead(isLeft, character)
head.InterfaceVisible = true
head.InterfaceVisibility = 100
end
function hideHead(isLeft, character)
local head = getHead(isLeft, character)
head.InterfaceVisible = false
head.InterfaceVisibility = 0
end