local owner = text:getLink(VTextOwner)
local pos = owner:getPoint(VCharacterPosition)
pos.y = pos.y + 30
text:setValue(VTextPosition, pos)
return true
function adaptedTextPosition(text)
local owner = text:getLink(VTextOwner)
if text.Owner:getId().tableId == eCharacters then
local pos = graphics.getCharacterTextPosition(game.CurrentCharacter)
local char_current_scale = game.CurrentCharacter.CharacterSize
local txt = text.CurrentText
local dim = graphics.fontDimension(txt)
local count = 0
txt = graphics.performLinebreaks(txt)
for _ in pairs(txt) do count = count + 1 end
local gap = 20
pos.y = pos.y - (dim.y*count) + gap*(char_current_scale/100)
text.Position = pos
return true
end
return false
end
registerHookFunction("setTextPosition", "adaptedTextPosition")
function adaptedTextPosition(text)
local owner = text:getLink(VTextOwner)
if text.Owner:getId().tableId == eCharacters and owner:getName() == 'Exalmpe' then
-- edit me
local gap = 15 --move text pos Y
local spacing = 0 --min space to corners
local maxdim = 200
-------
local pos = graphics.getCharacterTextPosition(game.CurrentCharacter)
local char_current_scale = game.CurrentCharacter.CharacterSize
local txt = text.CurrentText
local dim = graphics.fontDimension(txt)
local count = 0
txt = graphics.performLinebreaks(txt)
for _ in pairs(txt) do count = count + 1 end
pos.y = pos.y - (dim.y*count) + gap*(char_current_scale/100)
local resx = game.CurrentScene.Sprite:getSize().x
if dim.x > maxdim then
dim.x = maxdim
end
local realposleft = pos.x - (dim.x/2)
local realposright = pos.x + (dim.x/2)
if realposleft resx then
pos.x = resx - dim.x/2 - spacing
end
text.Position = pos
return true
end
return false
end
registerHookFunction("setTextPosition", "adaptedTextPosition")