Advertisement
Rolcam

Computercraft Tutorial - Section 3 - Variables

Jun 14th, 2021 (edited)
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 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 3: Variables \n")
  26. print("a = \"test\" - Declares the variable \"a\" as a string with the text \"test\" ")
  27. print("a = 2 - Declares the variable \"a\" with a numerical value of 2")
  28. print("a = read() - makes whatever you type next the value of the variable \"a\"")
  29. print("print(a) - Prints the value of the variable \"a\"")
  30. term.restore()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement