Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.unloadAPI("button")
- sleep(1)
- os.loadAPI("button")
- local m = peripheral.wrap("top")
- defaultSide = "back"
- autoModeBool = false
- -- BundledCable Color Declarations
- local witherColor = colors.black
- local forwardColor = colors.blue
- local autoModeColor = colors.green
- local autoModeColor2 = colors.cyan
- local power = colors.purple
- -- Fixes some API changes
- function colors.subtract(r, ...)
- for n, c in ipairs({ ... }) do
- r = bit.band(r, bit.bnot(c)%2^31)
- end
- return r
- end
- -- Pulses a bundled redstone color
- function redstonePulse(color, side)
- addColor(color, side)
- sleep(.5)
- delColor(color, side)
- end
- -- Turns on a color of a bundled cable
- function addColor(color , side)
- rs.setBundledOutput(side, colors.combine(rs.getBundledOutput(side) + color))
- end
- -- Turns a color off of a bundled cable
- function delColor(color, side)
- rs.setBundledOutput(side, colors.subtract(redstone.getBundledOutput(side), color))
- end
- -- Turns on the UberMiner AutoMode
- function autoMode()
- bool = checkColor(autoModeColor, defaultSide)
- -- If the Server is running the AutoMode it'll turn it on
- if bool then
- addColor(power, defaultSide)
- delColor(autoModeColor, defaultSide)
- term.setTextColor(colors.lime)
- print("AutoMode now Online!")
- -- Or Else it'll turn AutoMode off.
- else
- delColor(power, defaultSide)
- addColor(autoModeColor, defaultSide)
- term.setTextColor(colors.red)
- print("AutoMode now Offline!")
- end
- button.toggleButton("AutoMode ON/OFF")
- end
- -- Edit's the startup to boot up on this pastebin
- function startupClear()
- f = fs.open("startup", "w")
- f.write("shell.run('pastebin run BUDyRH0T')")
- f.close()
- end
- --Asks and saves where the bundled cable is locatated
- function redstoneVar()
- print("Where will the redstone output be? [left,right,bottom,top]")
- command = read()
- if command == "left" or command == "right" or command == "bottom" or command == "top" then
- print("Redstone set to "..command.." side")
- f = fs.open("redstoneVar", "w")
- f.writeLine(command)
- f.close()
- os.reboot()
- else
- term.setTextColor(colors.red)
- print("Invalid Input")
- sleep(1)
- redstoneVar()
- end
- end
- -- Checks if a file containing where the modem exists, and where the bundled redstone side is, if not
- -- Then it asks the user where they want it to be and saves it to modemVar and redstoneVar
- function startupVars()
- if fs.exists("redstoneVar") == false then
- redstoneVar()
- else
- -- If they have already been configured than it loads the configs,
- -- and Prints the current configs to the screen.
- f1 = fs.open("redstoneVar", "r")
- defaultSide = f1.readLine()
- f1.close()
- term.setTextColor(colors.cyan)
- print("Loaded with configuration :")
- term.setTextColor(colors.red)
- print("Redstone Side : "..defaultSide)
- term.setTextColor(colors.gray)
- end
- end
- -- Checks if a specific color in bundled cable is on or off / Returns a boolean
- function checkColor(color, side)
- boolean = rs.testBundledInput(side, color)
- --print("CheckColor : "..side.." - Side Color - "..color.." Bool -"..tostring(boolean))
- return boolean
- end
- function wither()
- button.flash("WitherSpawn")
- redstonePulse(witherColor, defaultSide)
- end
- function forward()
- redstonePulse(forwardColor, defaultSide)
- button.flash("Forward")
- end
- function updateNumbers(number, total)
- if checkColor(autoModeColor2, defaultSide) then
- term.setTextColor(colors.lime)
- print("Iteration : "..number.."/"..total)
- end
- end
- function manMode()
- button.flash("Manual Iterations")
- term.setTextColor(colors.cyan)
- print("How many iterations would you like?")
- term.setTextColor(colors.blue)
- command = read()
- autoMode()
- i = 0
- while i <= tonumber(command) do
- event , p1, p2, p3 = os.pullEvent()
- if event == "redstone" then
- updateNumbers(i, command)
- if i == 0 then
- i = i + 1 else
- i = i + 0.5
- fillMenu()
- m.setCursorPos(0,19)
- button.centerText("Iterations : "..i.."/"..command)
- end
- else if event == "monitor_touch" then
- button.checkxy(p2,p3)
- end
- end
- end
- autoMode()
- fillMenu()
- end
- function newTouchMenu()
- m.clear()
- button.clearTable()
- m.setBackgroundColor(colors.black)
- m.setTextColor(colors.white)
- end
- function fillMenu()
- newTouchMenu()
- button.clearTable()
- button.setTable("AutoMode ON/OFF", autoMode, 2,28 ,3,5)
- button.setTable("Manual Iterations", manMode, 2,28, 7,9)
- button.setTable("Forward", forward, 2,28, 11,13)
- button.setTable("WitherSpawn", wither, 2,28, 15,17)
- print("Main Menu Filled")
- button.screen()
- if checkColor(autoModeColor, defaultSide) then
- button.toggleButton("AutoMode ON/OFF")
- end
- end
- addColor(autoModeColor, defaultSide)
- startupClear()
- startupVars()
- fillMenu()
- local function getClick()
- while true do
- local _,_,x,y = os.pullEvent("monitor_touch")
- button.checkxy(x,y)
- end
- end
- while true do
- getClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement