Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Requires advanced monitors and computers!!!
- local rsSide = "back"
- local monitorSide = "top"
- function toggle(n)
- if not n then
- return
- end
- button[n].state = true
- end
- function sayState(n)
- if not n then
- return
- end
- x = button[n].x - 1
- y = button[n].y
- term.setCursorPos(x,y)
- if button[n].active == true then
- if button[n].state == true then
- term.setTextColor(colors.lime)
- write("on ")
- term.setTextColor(colors.white)
- else
- term.setTextColor(colors.red)
- write("off")
- term.setTextColor(colors.white)
- end
- else
- term.setTextColor(colors.gray)
- write("---")
- term.setTextColor(colors.white)
- end
- end
- function getButton(xPos,yPos)
- for i=1,12 do
- bxPos = button[i].x
- byPos = button[i].y
- 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 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 mobTypeWrite(_line,_time)
- term.setCursorPos(1,_line)
- write(" ")
- local additive = (_time - 1) * 4
- local currentx = 3
- for i = 1,4 do
- local buttonNumber = additive + i
- write(button[buttonNumber].mob)
- if i == 4 then
- else
- currentx = currentx + 10
- term.setCursorPos(currentx,_line)
- end
- end
- term.setCursorPos(1, _line + 1)
- end
- function startText()
- term.setCursorPos(1,1)
- mPrint("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
- mPrint(" Welcome to spawn select! Control mob")
- mPrint(" spawn choice by right click on screen")
- mPrint(" ")
- mobTypeWrite(5,1)
- stateWriter()
- mPrint(" ")
- mobTypeWrite(10,2)
- stateWriter()
- mPrint(" ")
- mobTypeWrite(15,3)
- stateWriter()
- mPrint("_______________________________________")
- end
- function refresh(button)
- modem.transmit(301,300,button)
- end
- display = peripheral.wrap(monitorSide)
- modem = peripheral.wrap(rsSide)
- term.redirect(display)
- term.clear()
- term.setCursorPos(1,1)
- --This is the table that controls everything. Don't touch unless you know what you are doing.
- button = {
- [1] = {x = 5; y = 7; state = false; active = false; mob = "Skele"},
- [2] = {x = 15; y = 7; state = false; active = false; mob = "Wither"},
- [3] = {x = 25; y = 7; state = false; active = false; mob = "Ender"},
- [4] = {x = 35; y = 7; state = false; active = true; mob = "Zombie"},
- [5] = {x = 5; y = 12; state = false; active = true; mob = "Spider"},
- [6] = {x = 15; y = 12; state = false; active = true; mob = "Witch"},
- [7] = {x = 25; y = 12; state = false; active = false; mob = "Pigman"},
- [8] = {x = 35; y = 12; state = false; active = false; mob = "Cow"},
- [9] = {x = 5; y = 17; state = false; active = true; mob = "Blaze"},
- [10] = {x = 15; y = 17; state = false; active = false; mob = "Slime"},
- [11] = {x = 25; y = 17; state = false; active = false; mob = "Creep"},
- [12] = {x = 35; y = 17; state = false; active = true; mob = "All"}
- }
- local resume = true
- startText()
- for i = 1,12 do
- sayState(i)
- end
- while resume == true do
- local event, side, xPos, yPos = os.pullEvent("monitor_touch")
- local selectedButton = getButton(xPos,yPos)
- if button[selectedButton].active == true then
- for i=1,11 do
- button[i].state = false
- end
- if selectedButton == 12 then
- for i=1,11 do
- button[i].state = false
- end
- else
- toggle(selectedButton)
- end
- for i=1,12 do
- sayState(i)
- end
- refresh(selectedButton)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement