Advertisement
Mackan90096

Untitled

Aug 14th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2.  
  3.  
  4. lights = false
  5. door = false
  6. Help = false
  7. show = true
  8. local p = peripheral.wrap("top")
  9. local bgcol = 0xFF0000
  10. local txtcol = 0x00FFFF
  11.  
  12. sen = sensor.wrap("sensor_11")
  13.  
  14. function error(msg)
  15. p.clear()
  16. mybox = p.addBox(1,1, 100, 50, bgcol, 0.5)
  17. local w = mybox.getX()
  18. mytext = p.addText(50, 10, tostring(msg), txtcol)
  19. end
  20.  
  21. function bydoor()
  22. p.clear()
  23. mybox = p.addBox(1,1, 100, 50, bgcol, 0.5)
  24. mytext = p.addText(1, 1, "By Door:", txtcol)
  25. for i, v in pairs(sen.getTargets()) do
  26.     mytext = p.addText(1,10, i, txtcol)
  27. end
  28. sleep(5)
  29. start()
  30. end
  31.  
  32. function help()
  33. p.clear()
  34. p.clear()
  35. mybox = p.addBox(1,1, 120, 150, bgcol, 0.5)
  36. mytext = p.addText(1, 10, "Help", txtcol)
  37. mytext = p.addText(1, 20, "Shows or hides the help", txtcol)
  38. mytext = p.addText(1, 40, "=1+1", txtcol)
  39. mytext = p.addText(1, 50, "Shows what 1+1 is,", txtcol)
  40. mytext = p.addText(1, 60, "Works with any number", txtcol)
  41. mytext = p.addText(1, 70, "and operator", txtcol)
  42. mytext = p.addText(1, 90, "Hide / Show", txtcol)
  43. mytext = p.addText(1, 100, "Hides or shows the", txtcol)
  44. mytext = p.addText(1, 110, "overlay", txtcol)
  45. end
  46.  
  47. function start()
  48. p.clear()
  49. mybox = p.addBox(1,1, 100, 50, bgcol, 0.5)
  50. mytext = p.addText(1, 1, "Version: 1.0", txtcol)
  51. mytext = p.addText(1, 20, "Try $$help", txtcol)
  52. end
  53.  
  54. start()
  55.  
  56. while true do
  57. _, p1 = os.pullEvent("chat_command")
  58.  if p1 == "help" then
  59.  if show then
  60.   if Help then
  61.   Help = false
  62.   start()
  63.  else
  64.  Help = true
  65.  help()
  66.  end
  67.  end
  68.  if string.find(p1, "=") then
  69.  if show then
  70.  txt = (tostring(p1):match("=(.+)"))
  71.  num = loadstring("return "..txt)()
  72.   mytext = p.addText(1, 40, tostring(num), textcol)
  73.  sleep(5)
  74.  start()
  75.   end
  76.   end
  77.  if string.find(p1, "reverse ") then
  78.    if show then
  79.      txt = tostring(p1):match("reverse(.+)")
  80.      num = string.reverse(txt)
  81.      mytext = p.addText(1, 40, tostring(num), txtcol)
  82.      sleep(5)
  83.      start()
  84.      
  85.    end
  86.  end
  87.   elseif p1 == "hide" then
  88.   if show then
  89.   p.clear()
  90.   show = false
  91.   end
  92.   elseif p1 == "show" then
  93.   if not show then
  94.   show = true
  95.   start()
  96.   end
  97.   elseif p1 == "bydoor" then
  98.   if show then
  99.   bydoor()
  100.   end
  101. else
  102. if not show then
  103.     error("Error!")
  104.     sleep(1)
  105.     start()
  106.   end
  107.  end
  108. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement