DEv0on

style

May 13th, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. function ver()
  2.   return 0.4
  3. end
  4.  
  5. function center(inp_text)
  6.   if string.len(inp_text) > 49 then
  7.     return "style.center(): string longer than 49"
  8.   else
  9.     spaces = ""
  10.     limit = 24 - math.floor(string.len(inp_text) / 2)
  11.     for i=1, limit do
  12.       spaces = spaces.." "
  13.       i = i + 1
  14.     end
  15.     return spaces..inp_text
  16.   end
  17. end
  18.  
  19. function right(inp_text)
  20.   if string.len(inp_text) > 49 then
  21.     return "style.left(): string longer than 49"
  22.   else
  23.     spaces = ""
  24.     limit = 49 - string.len(inp_text)
  25.     for i=1, limit do
  26.       spaces = spaces.." "
  27.       i = i + 1
  28.     end
  29.     return spaces..inp_text
  30.   end
  31. end
  32.  
  33. function shorten(inp_text, lenth)
  34.   if string.len(inp_text) > lenth then
  35.     inp_text = ".."..string.sub(inp_text, (string.len(inp_text) - (lenth - 3)))
  36.   end
  37.   return inp_text
  38. end
  39.  
  40. function itemName(inp_text)
  41.   if inp_text == nil then
  42.     return "<unknown item>"
  43.   else
  44.     itemNameCuts = {"item.", "tile.", ".name"}
  45.     for i=1, table.getn(itemNameCuts) do
  46.       inp_text = string.gsub(inp_text, itemNameCuts[i], "")
  47.     end
  48.     return inp_text
  49.   end
  50. end
Add Comment
Please, Sign In to add comment