Advertisement
Guest User

startup

a guest
Apr 26th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. t=term
  2. side="left"
  3. term.clear()
  4. x,y=t.getSize()
  5. text="Use the arrow keys to change the radio's volume!"
  6. t.setCursorPos(math.ceil((x-string.len(text))/2), 1)
  7. t.write(text)
  8. t.setCursorPos(math.ceil((x-string.len("Volume Level"))/2),2)
  9. t.write("Volume Level")
  10. HalfX=math.floor(x/2)
  11. for i=1,16 do
  12.   term.setCursorPos(HalfX-1,i+2)
  13.   term.write("[ ]")
  14. end
  15. term.setCursorPos(HalfX,11)
  16. term.write("-")
  17. Selection=7
  18. rs.setAnalogOutput(side, 7)
  19. while true do
  20.   event, Key=os.pullEvent("key")
  21.   if Key==200 then
  22.     if Selection~=15 then
  23.       Selection=Selection+1
  24.     end
  25.   elseif Key==208 then
  26.     if Selection~=0 then
  27.       Selection=Selection-1
  28.     end
  29.   end
  30.   rs.setAnalogOutput(side, Selection)
  31.   t.setCursorPos(HalfX, 19-Selection)
  32.   t.write(" ")
  33.   if Selection~=15 then
  34.     t.setCursorPos(HalfX, 17-Selection)
  35.     t.write(" ")
  36.   end
  37.   t.setCursorPos(HalfX, 18-Selection)
  38.   t.write("-")
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement