Enjl

areaNames

Apr 19th, 2019 (edited)
934
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.35 KB | None | 0 0
  1. --        ______________
  2. --       |AREANAMES.LUA|
  3. --       --------------
  4. -- by Enjl, V1.0
  5. -- of note:
  6. --   not multiplayer compatible
  7.  
  8. --ADD TO THIS to have names show up on section transitions
  9. local areanames = {}
  10.  
  11. local textplus
  12.  
  13. local currentName = ""
  14. local timer = 0
  15.  
  16. local font
  17.  
  18. areanames.sectionNames = {}
  19.  
  20. --CALL THIS to manually show names
  21. function areanames.show(name)
  22.     timer = 0
  23.     currentName = name
  24. end
  25.  
  26. function areanames.onLoadSection()
  27.     if areanames.sectionNames[player.section] then
  28.         areanames.show(areanames.sectionNames[player.section])
  29.     end
  30. end
  31.  
  32. --OVERWRITE THIS to implement custom drawing functions
  33. function areanames.draw(name, t)
  34.     if t < #name * 4 + 80 then
  35.         if font == nil then
  36.             textplus = require("textplus")
  37.             font = textplus.loadFont("textplus/font/6.ini")
  38.         end
  39.         textplus.print{
  40.             x = 20,
  41.             y = 100,
  42.             text = name,
  43.             priority = 5,
  44.             limit = math.floor(t / 4),
  45.             font = font,
  46.             xscale = 2,
  47.             yscale = 2
  48.         }
  49.     end
  50. end
  51.  
  52. function areanames.onDraw()
  53.     areanames.draw(currentName, timer)
  54.     timer = timer + 1
  55. end
  56.  
  57. function areanames.onInitAPI()
  58.     registerEvent(areanames, "onLoadSection")
  59.     registerEvent(areanames, "onDraw")
  60. end
  61.  
  62. return areanames
Add Comment
Please, Sign In to add comment