Advertisement
fishermedders

mem

Dec 21st, 2016
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. m = peripheral.wrap("top")
  2. m.setTextScale(0.5)
  3. p = peripheral.wrap("back")
  4. noplayer = "No Player"
  5. cplayer = noplayer
  6. color = {}
  7. color.bc = colors.gray
  8. color.vc = colors.lime
  9. color.tc = colors.black
  10.  
  11. function draw_bar(y)
  12. size = {term.getSize()}
  13. term.setCursorPos(1,y)
  14. for i = 1,size[1] do
  15. term.write(" ")
  16. end
  17. end
  18.  
  19. function cprint(y,text)
  20. size = {term.getSize()}
  21. term.setCursorPos(math.ceil((size[1]/2)-(#text/2)+1),y)
  22. term.write(text)
  23. end
  24.  
  25. while true do
  26. --print(cplayer)
  27. term.redirect(m)
  28. term.setBackgroundColor(color.bc)
  29. term.clear()
  30. term.setBackgroundColor(color.vc)
  31. size = {term.getSize()}
  32. draw_bar(1)
  33. draw_bar(size[2])
  34. term.setTextColor(color.tc)
  35. term.setCursorPos(1,1)
  36. evnt = {os.pullEvent()}
  37. if evnt[1] == "player_on" then
  38. if cplayer == noplayer then
  39. cplayer = evnt[2]
  40. end
  41. elseif evnt[1] == "player_off" then
  42. if cplayer ~= noplayer then
  43. cplayer = noplayer
  44. end
  45. end
  46. cprint(1,cplayer)
  47. term.restore()
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement