Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Requires advanced monitors and computers!!!
- function toggle(n)
- if not n then
- return
- end
- local state=lightState[n]
- if state then
- state = false
- else
- state = true
- end
- lightState[n] = state
- return state
- end
- function sayState(n)
- if not n then
- return
- end
- x = buttonX[n]-1
- y = buttonY[n]
- term.setCursorPos(x,y)
- if lightState[n] then
- term.setTextColor(colors.lime)
- write("on ")
- term.setTextColor(colors.white)
- else
- term.setTextColor(colors.red)
- write("off")
- term.setTextColor(colors.white)
- end
- end
- function getButton(xPos,yPos)
- for i=1,12 do
- bxPos=buttonX[i]
- byPos=buttonY[i]
- xMax=bxPos+2
- xMin=bxPos-2
- yMax=byPos+1
- yMin=byPos-1
- if xPos >= xMin and xPos <= xMax and yPos >= yMin and yPos <= yMax then
- return i
- end
- end
- end
- function mPrint(w)
- write(w)
- x,y=term.getCursorPos()
- term.setCursorPos(1,y+1)
- end
- function allTheSame()
- local state = lightState[1]
- for i=2,10 do
- if state==lightState[i] then
- else return false
- end
- end
- return true
- end
- function stateWriter()
- mPrint(" _____ _____ _____ _____")
- write(" ")
- for i=1,4 do
- write("|")
- term.setTextColor(colors.red)
- write("off")
- term.setTextColor(colors.white)
- if i<4 then
- write("| ")
- else
- mPrint("|")
- end
- end
- mPrint(" ~~~~~ ~~~~~ ~~~~~ ~~~~~")
- end
- function startText()
- term.setCursorPos(1,1)
- mPrint("_______________________________________")
- mPrint(" Welcome to spawn select! Control mob")
- mPrint(" spawn choice by right click on screen")
- mPrint(" ")
- mPrint(" Skele Wither Ender Zombie")
- stateWriter()
- mPrint(" ")
- mPrint(" Creep Witch Pigman Cow")
- stateWriter()
- mPrint(" ")
- mPrint(" Blaze Slime Toggle Master")
- stateWriter()
- mPrint("_______________________________________")
- end
- function bundleState()
- end
- display = peripheral.wrap("right")
- term.redirect(display)
- term.clear()
- term.setCursorPos(1,1)
- buttonX = {
- 5,15,25,35,
- 5,15,25,35,
- 5,15,25,35
- }
- buttonY = {
- 7,7,7,7,
- 12,12,12,12,
- 17,17,17,17
- }
- lightState = {false,false,false,false,false,false,false,false,false,false,false,false}
- spawnerColor = {
- colors.white, colors.orange, colors.magenta, colors.lightBlue,
- colors.yellow, colors.lime, colors.pink, colors.gray,
- colors.lightGray, colors.cyan, colors.purple, colors.blue
- }
- local resume=true
- startText()
- for i=1,10 do
- sayState(i)
- end
- term.setCursorPos(buttonX[12]-1,buttonY[12])
- term.setTextColor(colors.red)
- write("off")
- term.setTextColor(colors.white)
- term.setCursorPos(buttonX[11]-1,buttonY[11])
- term.setTextColor(colors.cyan)
- write("TGL")
- term.setTextColor(colors.white)
- while resume == true do
- local event, side, xPos, yPos = os.pullEvent("monitor_touch")
- local button = getButton(xPos,yPos)
- if button==11 then
- for i=1,10 do
- toggle(i)
- end
- elseif button==12 then
- toggle(12)
- for i=1,10 do
- lightState[i]=lightState[12]
- end
- sayState(12)
- allSame=true
- else
- term.setCursorPos(buttonX[12]-1,buttonY[12])
- term.setTextColor(colors.lightGray)
- write("---")
- term.setTextColor(colors.white)
- toggle(button)
- end
- for i=1,10 do
- sayState(i)
- end
- if allTheSame() then
- lightState[12]=lightState[1]
- sayState(12)
- else
- term.setCursorPos(buttonX[12]-1,buttonY[12])
- term.setTextColor(colors.lightGray)
- write("---")
- term.setTextColor(colors.white)
- end
- end
- --[==[Tables are used to quite an extent throughout this program.
- The order of said tables is important as these must remain consistent in order for the script to execute.]==]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement