Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. os.loadAPI('itw-core/texthelp')
  2. os.loadAPI('itw-core/tracker')
  3. os.loadAPI('itw-core/content')
  4.  
  5. local function updateText(station)
  6. if station.state == true then
  7. if station.data.videoLink then
  8. print('video link found')
  9. local loc = "x="..station.x..",y="..station.y..",z="..station.z
  10. commands.tellraw('@a[r=10,'..loc..']','["",{"text":"Press T and "},{"text":"click here","underlined":true,"color":"aqua","clickEvent":{"action":"open_url","value":"'..station.data.videoLink..'"}},{"text":" to watch a video"}]')
  11. end
  12. texthelp.printToScreen(station.monitor,station.data.onText,station.w-2,station.data.onKeys,2,2)
  13. else
  14. texthelp.printToScreen(station.monitor,station.data.offText,station.w-2,station.data.offKeys,2,2)
  15. end
  16. end
  17.  
  18. function init()
  19. local station = {}
  20. station.monitor = peripheral.wrap('left') or peripheral.wrap('right')
  21. station.monitor.setTextScale(2)
  22. station.w,station.h = station.monitor.getSize()
  23. station.state = false
  24. station.data = {
  25. onText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla eros nisl, rhoncus sed ex vitae, fermentum finibus metus. Aliquam iaculis risus ut orci venenatis auctor. Pellentesque non odio in purus egestas mattis in at neque.",
  26. onKeys = {
  27. {word="nisl",color="red"},
  28. {word="finibus",color="blue"},
  29. {word="risus",color="green"}
  30. },
  31. offText = "DEFAULT PROVIDER /n /n This is a text provider. You can read the hidden text by standing on the diamond block.",
  32. offKeys = {
  33. {word='diamond',color='lightBlue'},
  34. {word='hidden',color='magenta'},
  35. {word='standing',color='green'}
  36. }
  37. }
  38. station.x,station.y,station.z = commands.getBlockPosition()
  39. stationFromContent = tracker.findClosestStation(station.x,station.y,station.z)
  40. if stationFromContent then station.data = stationFromContent.data end
  41. return station
  42. end
  43.  
  44. local timer = 0
  45. function updateStation(station)
  46. updateText(station)
  47. while true do
  48. local signal = redstone.getInput("back")
  49. if not signal == station.state then
  50. station.state = signal
  51. updateText(station)
  52. end
  53. if station.state and timer>10 then
  54. timer = 0
  55. updateText(station)
  56. end
  57. timer = timer +1
  58. sleep(1)
  59. end
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement