Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 < 0 then
- pos.x = dim.x/2 + spacing
- end
- if realposright > resx then
- pos.x = resx - dim.x/2 - spacing
- end
- text.Position = pos
- return true
- end
- return false
- end
- registerHookFunction("setTextPosition", "adaptedTextPosition")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement