Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Print a line of dashes for aesthetics
- local function lineBreak()
- local width, height = term.getSize()
- for i = 1, width do
- io.write("-")
- end
- io.write("\n")
- end
- -- Function to clear the screen
- local function clearScreen()
- term.clear()
- term.setCursorPos(1, 1)
- end
- clearScreen()
- -- Print the welcome message
- print("Artillery Controller")
- lineBreak()
- print("Select a weapon:")
- print("1. TNT")
- print("2. Nuke")
- lineBreak()
- local choice = read()
- if choice == "1" then
- projectileType = "TNT"
- elseif choice == "2" then
- print("Authorization Code:")
- local choice = read()
- if choice == "1234" then
- print("Codes Accepted")
- projectileType = "Nuke"
- end
- end
- clearScreen()
- -- Ask for shot size
- print("Artillery Controller")
- lineBreak()
- print("Weapon:"..projectileType)
- lineBreak()
- print("Size of Shot:")
- print("1. 1x1")
- print("2. 2x2")
- if projectileType == "TNT" then
- print("3. 3x3")
- print("4. 4x4")
- print("5. 5x5")
- local choice = read()
- if choice == "2" then
- projectilePattern = "2x2"
- elseif choice == "3" then
- projectilePattern = "3x3"
- elseif choice == "4" then
- projectilePattern = "4x4"
- elseif choice == "5" then
- projectilePattern = "5x5"
- else
- projectilePattern = "Single"
- end
- elseif projectileType == "Nuke" then
- local choice = read()
- if choice == "2" then
- projectilePattern = "2x2"
- else
- projectilePattern = "Single"
- end
- end
- clearScreen()
- print("Artillery Controller")
- lineBreak()
- print("Weapon:"..projectileType)
- print("Pattern:"..projectilePattern)
- lineBreak()
- print("Number of Itterations")
- lineBreak()
- local iterations = tonumber(read())
- clearScreen()
- print("Artillery Controller")
- lineBreak()
- print("Weapon:"..projectileType)
- print("Pattern:"..projectilePattern)
- lineBreak()
- print("Select a targeting method")
- print("1. Current Position")
- print("2. Custom Current")
- print("3. Offset Position")
- lineBreak()
- local choice = read()
- if choice == "2" then
- print("X: ")
- targetX = read()
- print("Y: ")
- targetY = read()
- print("Z: ")
- targetZ = read()
- elseif choice == "3" then
- X, Y, Z = gps.locate()
- print("X: ")
- targetX = X + read()
- print("Y: ")
- targetY = Y + read()
- print("Z: ")
- targetZ = Z + read()
- else
- targetX, targetY, targetZ = gps.locate()
- end
- clearScreen()
- print("Artillery Controller")
- lineBreak()
- print("Weapon:"..projectileType)
- print("Pattern:"..projectilePattern)
- print("X:"..targetX)
- print("Y:"..targetY)
- print("Z:"..targetZ)
- lineBreak()
- print("Please Confirm")
- print("1. Confirm Input")
- print("2. Cancel")
- lineBreak()
- local choice = read()
- if choice == "1" then
- clearScreen()
- print("Artillery Controller")
- lineBreak()
- print("Starting Programing")
- lineBreak()
- local modem = peripheral.find("modem") or error("No modem attached", 0)
- modem.open(43) -- Open 43 so we can receive replies
- modem.transmit(15, 43, projectileType)
- print("Weapon:"..projectileType)
- os.sleep(1)
- modem.transmit(15, 43, projectilePattern)
- print("Pattern:"..projectilePattern)
- os.sleep(1)
- modem.transmit(15, 43, iterations)
- print("Iterations:"..iterations)
- os.sleep(1)
- modem.transmit(15, 43, targetX)
- print("X:"..targetX)
- os.sleep(1)
- modem.transmit(15, 43, targetY)
- print("Y:"..targetY)
- os.sleep(1)
- modem.transmit(15, 43, targetZ)
- print("Z:"..targetZ)
- os.sleep(0.5)
- clearScreen()
- print("Artillery Controller")
- lineBreak()
- print("Programing Complete")
- lineBreak()
- print("Firing Now")
- clearScreen()
- print("Artillery Controller")
- lineBreak()
- print("Programing Complete")
- for i = 1, iterations+2 do
- local event, side, channel, replyChannel, message, distance
- repeat
- event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
- until channel == 43
- print(tostring(message))
- end
- else
- print("Cancelled")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement