Advertisement
Rolcam

Computercraft Tutorial - Section 7.1 - Loops Cont

Jun 14th, 2021 (edited)
549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. --This is part of a Computercraft Programming Teaching Program
  2.  
  3. tSides = {"left","right","bottom","top","front","back"}
  4.  
  5. for i = 1, #tSides do
  6.   monitor = peripheral.wrap(tSides[i])
  7.   if monitor then
  8.         side = tSides[i]
  9.         break
  10.   end
  11. end
  12. --Prevents program termination
  13. os.pullEvent = os.pullEventRaw
  14. term.redirect(peripheral.wrap(side))
  15.  
  16. -- Resets Screen
  17. function reset()
  18.     term.setTextColor(colors.white)
  19.     term.setBackgroundColor(colors.black)
  20.     term.clear()
  21.     term.setCursorPos(1,1)
  22. end
  23.  
  24. reset()
  25. print("Section 7.1 - Loops \n ")
  26. print("repeat - Opposite of a while loop. This will keep repeating until the condition is true")
  27. print("blah blah blah - fake code stuff")
  28. print("until a == 5 - This is used to close this loop instead of \"end\"")
  29. print("If the above condition is true, the loop will end. As this is on the bottom, this loop will run at least once")
  30. term.restore()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement