Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Startup Computer 0 Commander01
- area = {
- {52,179},
- {53,179},
- {54,179},
- {54,180},
- {53,180},
- {52,180},
- {52,181},
- {52,182},
- {52,183},
- {52,184},
- {51,184},
- {50,184},
- {50,183},
- {50,182},
- {50,181},
- {50,180},
- {50,179},
- {50,178},
- {50,177},
- {50,176},
- {49,176},
- {48,176}
- }
- local xHome, yHome, zHome = commands.getBlockPosition()
- local mineBottom = yHome - 11
- local mineTop = yHome - 1
- local mineTopEdge = xHome + 17
- local mineBottomEdge = xHome + 2
- local mineLeftEdge = zHome + 1
- local mineRightEdge = zHome + 8
- local monitor = nil
- local modem = nil
- local termRow = 1
- local termCol = 1
- local monRow = 1
- local monCol = 1
- local page = {}
- local pageNo = 1
- local numPages = 1
- local numRows = 0
- local numCols = 0
- local fileName = ""
- function placeWater(clear)
- --for y = 56, 54, -1 do
- y = 56
- for i = 1, #area do
- if clear then
- --if checkBlockType(area[i][1], y, area[i][2], "minecraft:water") then
- print("x="..area[i][1].."y="..y.." z="..area[i][2].." :stone")
- commands.setblock(area[i][1], y, area[i][2], "minecraft:dirt")
- --end
- else
- --if checkBlockType(area[i][1], y, area[i][2], "minecraft:air") then
- print("x="..area[i][1].."y="..y.." z="..area[i][2].." :water")
- --commands.setblock(area[i][1], y, area[i][2], "minecraft:water", 0)
- --end
- end
- end
- for i = 1, #area do
- if clear then
- sleep(0.5)
- --if checkBlockType(area[i][1], y, area[i][2], "minecraft:stone") then
- print("x="..area[i][1].."y="..y.." z="..area[i][2].." :air")
- commands.setblock(area[i][1], y, area[i][2], "minecraft:air", 0)
- --end
- end
- end
- display("both", "write", "Layer "..y.." completed")
- --commands.say("Layer "..y.." completed")
- sleep(0.5)
- --end
- end
- function findTurtle()
- retX = 0
- retY = 0
- retZ = 0
- for y = 56, 53, -1 do
- for i = 1, #area do
- if checkBlockType(area[i][1], y, area[i][2], "ComputerCraftEDU:TurtleJunior") then
- retX = area[i][1]
- retY = y
- retZ = area[i][2]
- break
- end
- end
- if x > 0 and z > 0 then
- break
- end
- end
- return retX, retY, retZ
- end
- function display(device, action, text)
- -- display("both", "print", text)
- if action == "clear" then
- if device == "term" or device == "both" then
- term.clear()
- term.setCursorPos(1, 1)
- termRow = 1
- termCol = 1
- end
- if device == "mon" or device == "both" then
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.setTextColor(colors.white)
- monRow = 1
- monCol = 1
- end
- elseif action == "print" then
- if device == "term" or device == "both" then
- term.write(text)
- termRow = termRow + 1
- term.setCursorPos(1, termRow)
- end
- if device == "mon" or device == "both" then
- monitor.write(text)
- monRow = monRow + 1
- monitor.setCursorPos(1, monRow)
- end
- commands.say(text)
- elseif action == "write" then
- if device == "term" or device == "both" then
- if termRow > 1 then
- termRow = termRow - 1
- end
- term.setCursorPos(1, termRow)
- term.write(" ")
- term.setCursorPos(1, termRow)
- term.write(text)
- termRow = termRow + 1
- term.setCursorPos(1, termRow)
- end
- if device == "mon" or device == "both" then
- if monRow > 1 then
- monRow = monRow - 1
- end
- monitor.setCursorPos(1, monRow)
- monitor.write(" ")
- monitor.setCursorPos(1, monRow)
- monitor.write(text)
- monRow = monRow + 1
- monitor.setCursorPos(1, monRow)
- end
- end
- end
- function checkBlockType(x, y, z, checkBlockType)
- local result = false
- local blockType = {}
- blockType = commands.getBlockInfo(x, y, z)
- if blockType.name == checkBlockType then
- result = true
- end
- return result
- end
- function getChoice()
- term.clear()
- term.setCursorPos(1,1)
- print("Choose function:")
- print()
- print(" 1 - Place Water Sources")
- print(" 2 - Clear Water Sources")
- print(" 3 - Find Turtle Position")
- print(" 4 - Retrieve Turtle")
- print(" 5 - Quit")
- print()
- print("Enter your choice:")
- local result = read()
- return result
- end
- function getPeripheralSide(pType)
- local side = ""
- for k,v in pairs(rs.getSides()) do
- if peripheral.getType(v)== pType then
- side = v
- break
- end
- end
- return side
- end
- function main()
- local choice = 0
- local side = ""
- side = getPeripheralSide("monitor")
- if side ~= "" then
- monitor = peripheral.wrap(side)
- numCols, numRows = monitor.getSize()
- monitor.setTextColor(colors.white)
- display("both", "clear")
- display("both", "print", "Submarine Controller:Waiting for modem")
- end
- side = getPeripheralSide("modem")
- if side ~= "" then
- modem = peripheral.wrap(side)
- modem.open(0)
- end
- commands.gamerule("commandBlockOutput", false)
- while true do
- local action = getChoice()
- display("both", "clear")
- if action == "1" then
- display("both", "print", "Placing water sources")
- sleep(0.1)
- placeWater(false)
- display("both", "print", "Water sources operational")
- elseif action == "2" then
- display("both", "print", "Clearing water sources")
- sleep(0.1)
- placeWater(true)
- display("both", "print", "Water sources cleared")
- elseif action == "3" then
- display("both", "print", "Searching for Turtle")
- sleep(0.1)
- cfindTurtle()
- display("both", "print", "Turtle found at ")
- elseif action == "4" then
- display("both", "print", "Retrieving Turtle")
- sleep(0.1)
- -- send wireless turtle to fetch CCEDU
- display("both", "print", "Turtle Recovered")
- elseif action == "5" then
- display("both", "print", "Goodbye")
- break
- end
- end
- --[[while true do
- event, p1, p2, p3, p4 = os.pullEvent()
- if event == "monitor_touch" or event == "modem_message" then
- if event == "monitor_touch" then
- --display("mon", "clear")
- sleep(0.5)
- display("both", "print", "Monitor Touch")
- elseif event == "modem_message" then --Advanced computer networked to allow control non-creative
- display("both", "clear")
- if p4 == "1" then
- display("both", "print", "Placing water sources")
- sleep(0.1)
- placeWater(false)
- display("both", "print", "Water sources operational")
- elseif p4 == "2" then
- display("both", "print", "Clearing water sources")
- sleep(0.1)
- placeWater(true)
- display("both", "print", "Water sources cleared")
- elseif p4 == "3" then
- display("both", "print", "Searching for Turtle")
- sleep(0.1)
- cfindTurtle()
- display("both", "print", "Turtle found at ")
- elseif p4 == "4" then
- display("both", "print", "Retrieving Turtle")
- sleep(0.1)
- -- send wireless turtle to fetch CCEDU
- display("both", "print", "Turtle Recovered")
- elseif p4 == "5" then
- display("both", "print", "Goodbye")
- break
- end
- end
- elseif event == "mouse_click" then
- sleep(0.5)
- display("both", "print", "Mouse Click")
- end
- end]]--
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement