Advertisement
Guest User

startup

a guest
May 25th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. colors = {
  2.   colors.white, colors.orange, colors.magenta,
  3.   colors.lightBlue, colors.yellow,
  4.   colors.lime, colors.pink, colors.gray,
  5.   colors.lightGray, colors.cyan, colors.purple,
  6.   colors.blue, colors.brown, colors.green,
  7.   colors.red, colors.black
  8. }
  9.  
  10. function getNumTNT()
  11.   term.clear()
  12.   term.setCursorPos(1, 1)
  13.   write("Number of TNT: ")
  14.   input = math.ceil(tonumber(read()))
  15.  
  16.   if (input >= 1 and input <= 64) then
  17.     write("success!")
  18.     return input
  19.   else
  20.     write("you entered a number too big or small")
  21.     sleep(3)
  22.     return false
  23.   end
  24. end
  25.  
  26. function placeLaunchedTNT()
  27.   rs.setOutput("right", true)
  28.   sleep(0.1)
  29.   rs.setOutput("right", false)
  30. end
  31.  
  32. function placePropulsionTNT(input)
  33.   inputCables = input/4
  34.  
  35.   sum = 0
  36.   for i = 1, inputCables do
  37.     sum = sum + colors[i]
  38.   end
  39.    
  40.   -- Places the TNT for the propulsion.
  41.   rs.setBundledOutput("back", sum)
  42.   sleep(0.1)
  43.   rs.setBundledOutput("back", 0)
  44. end
  45.  
  46. function activateTNT()
  47.   rs.setOutput("left", true)
  48.   sleep(0.1)
  49.   rs.setOutput("left", false)
  50. end
  51.  
  52. function restart()
  53.   main()
  54. end
  55.  
  56. -- Where the magic happens.
  57. function main()
  58.   numTNT = getNumTNT()
  59.  
  60.   if (numTNT) then
  61.     placeLaunchedTNT()
  62.     placePropulsionTNT(numTNT)
  63.     activateTNT()
  64.   else
  65.     restart()
  66.   end
  67. end
  68.  
  69. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement