Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. function adaptedTextPosition(text)
  2.  
  3. local owner = text:getLink(VTextOwner)
  4.  
  5. if text.Owner:getId().tableId == eCharacters and owner:getName() == 'Exalmpe' then
  6. -- edit me
  7. local gap = 15 --move text pos Y
  8. local spacing = 0 --min space to corners
  9. local maxdim = 200
  10. -------
  11. local pos = graphics.getCharacterTextPosition(game.CurrentCharacter)
  12. local char_current_scale = game.CurrentCharacter.CharacterSize
  13. local txt = text.CurrentText
  14. local dim = graphics.fontDimension(txt)
  15. local count = 0
  16. txt = graphics.performLinebreaks(txt)
  17. for _ in pairs(txt) do count = count + 1 end
  18. pos.y = pos.y - (dim.y*count) + gap*(char_current_scale/100)
  19. local resx = game.CurrentScene.Sprite:getSize().x
  20. if dim.x > maxdim then
  21. dim.x = maxdim
  22. end
  23. local realposleft = pos.x - (dim.x/2)
  24. local realposright = pos.x + (dim.x/2)
  25. if realposleft < 0 then
  26. pos.x = dim.x/2 + spacing
  27. end
  28. if realposright > resx then
  29. pos.x = resx - dim.x/2 - spacing
  30. end
  31. text.Position = pos
  32. return true
  33. end
  34. return false
  35.  
  36. end
  37.  
  38. registerHookFunction("setTextPosition", "adaptedTextPosition")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement