Guest User

Untitled

a guest
Jan 9th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #this is a method to get the number of visible rows and the largest character length (Godot / GDScript)
  2.  
  3. var totalLines = 0
  4. var maxLineCharset = 0
  5. func calcTotaisInText(st):
  6. var aSt = st.split("\n")
  7. totalLines = aSt.size()
  8.  
  9. var i = 0
  10. while i < totalLines:
  11. print(aSt[i])
  12. if aSt[i].length() > maxLineCharset:
  13. maxLineCharset = aSt[i].length()
  14. i+=1
  15.  
  16. func get_total_lines():
  17. return totalLines
  18. func get_total_max_charset():
  19. return maxLineCharset
  20.  
  21.  
  22. func _ready():
  23. #insert the call to the function
  24. calcTotaisInText(get_node("richText").get_text())
Add Comment
Please, Sign In to add comment