Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------------------------------------------------------
- -- ___ ___ __ ____________ __ ___ ___ __ --
- -- |:| /:/ /::\ |::::::::::| /::\ |::\ /::| /::\ --
- -- |:| /:/ /::::\ |::/-------- /::::\ |:::\ /:::| /::::\ --
- -- |:| /:/ /::/\::\ |::| /::/\::\ |::::\/::::| /::/\::\ --
- -- |:|/:/ /::/__\::\ |::\________ /::/__\::\ |::|\::/|::| /::/__\::\ --
- -- |:|\:\ /::/::::\::\ |::::::::::| /::/::::\::\ |::| \/ |::| /::/::::\::\ --
- -- |:| \:\ /::/------\::\ --------\::| /::/------\::\ |::| |::| /::/------\::\ --
- -- |:| \:\ /::/ \::\ /::| /::/ \::\ |::| |::| /::/ \::\ --
- -- |:| \:\ /::/ \::\ |::::::::::| /::/ \::\ |::| |::| /::/ \::\ --
- -- --- --- --- --- ------------ --- --- ---- ---- --- --- --
- ----------------------------------------------------------------------------------------Scripts---
- ----------------------------------------Spawner_Controler-----------------------------------------
- --------------------------------------------------------------------------------------------------
- function toggleState(state)
- if (state == true) then
- state = false
- else
- state = true
- end
- return state
- end
- function updateRedstone()
- if (door1State == true) then
- rednet.broadcast("door1","jackSpawner")
- else
- rednet.broadcast("door1c","jackSpawner")
- end
- if (door2State == true) then
- rednet.broadcast("door2","jackSpawner")
- else
- rednet.broadcast("door2c","jackSpawner")
- end
- if (door3State == true) then
- rednet.broadcast("door3","jackSpawner")
- else
- rednet.broadcast("door3c","jackSpawner")
- end
- if (door4State == true) then
- rednet.broadcast("door4","jackSpawner")
- else
- rednet.broadcast("door4c","jackSpawner")
- end
- if (spawn1State == true) then
- rednet.broadcast("spawn1","jackSpawner")
- else
- rednet.broadcast("spawn1c","jackSpawner")
- end
- if (spawn2State == true) then
- rednet.broadcast("spawn2","jackSpawner")
- else
- rednet.broadcast("spawn2c","jackSpawner")
- end
- end
- function checkClick(x, y)
- wx, wy = door1.getPosition()
- wsx, wsy = door1.getSize()
- if (intersects(x,y, wx, wy, wsx, wsy)) then
- return 1
- end
- wx, wy = door2.getPosition()
- wsx, wsy = door2.getSize()
- if (intersects(x,y, wx, wy, wsx, wsy)) then
- return 2
- end
- wx, wy = door3.getPosition()
- wsx, wsy = door3.getSize()
- if (intersects(x,y, wx, wy, wsx, wsy)) then
- return 3
- end
- wx, wy = door4.getPosition()
- wsx, wsy = door4.getSize()
- if (intersects(x,y, wx, wy, wsx, wsy)) then
- return 4
- end
- wx, wy = spawn1.getPosition()
- wsx, wsy = spawn1.getSize()
- if (intersects(x,y, wx, wy, wsx, wsy)) then
- return 5
- end
- wx, wy = spawn2.getPosition()
- wsx, wsy = spawn2.getSize()
- if (intersects(x,y, wx, wy, wsx, wsy)) then
- return 6
- end
- return 0
- end
- function intersects(x, y, wx, wy, wsx, wsy)
- if ((x >= wx) and (x <= (wx+wsx)) and (y >= wy) and (y <= (wy + wsy))) then
- return true
- else
- return false
- end
- end
- function update()
- ------------Door 1---------------
- monitor.setBackgroundColor(colors.blue)
- monitor.setCursorPos(3,4)
- monitor.write("Door 1")
- door1 = window.create(monitor, 10, 4, 6, 1, true)
- if (door1State == false) then
- door1.setBackgroundColor(colors.red)
- door1.write("Closed")
- else
- door1.setBackgroundColor(colors.green)
- door1.write(" Open ")
- end
- ------------Door 2---------------
- monitor.setBackgroundColor(colors.blue)
- monitor.setCursorPos(3,6)
- monitor.write("Door 2")
- door2 = window.create(monitor, 10, 6, 6, 1, true)
- if (door2State == false) then
- door2.setBackgroundColor(colors.red)
- door2.write("Closed")
- else
- door2.setBackgroundColor(colors.green)
- door2.write(" Open ")
- end
- ------------Door 3---------------
- monitor.setBackgroundColor(colors.blue)
- monitor.setCursorPos(3,8)
- monitor.write("Door 3")
- door3 = window.create(monitor, 10, 8, 6, 1, true)
- if (door3State == false) then
- door3.setBackgroundColor(colors.red)
- door3.write("Closed")
- else
- door3.setBackgroundColor(colors.green)
- door3.write(" Open ")
- end
- ------------Door 4---------------
- monitor.setBackgroundColor(colors.blue)
- monitor.setCursorPos(3,10)
- monitor.write("Door 4")
- door4 = window.create(monitor, 10, 10, 6, 1, true)
- if (door4State == false) then
- door4.setBackgroundColor(colors.red)
- door4.write("Closed")
- else
- door4.setBackgroundColor(colors.green)
- door4.write(" Open ")
- end
- ----------Spawner 1-------------
- monitor.setBackgroundColor(colors.blue)
- monitor.setCursorPos(19,4)
- monitor.write("Spawner 1")
- spawn1 = window.create(monitor, 19, 5, 8, 1, true)
- if (spawn1State == false) then
- spawn1.setBackgroundColor(colors.red)
- spawn1.write("Disabled")
- else
- spawn1.setBackgroundColor(colors.green)
- spawn1.write("Enabled ")
- end
- ----------Spawner 2-------------
- monitor.setBackgroundColor(colors.blue)
- monitor.setCursorPos(19,8)
- monitor.write("Spawner 2")
- spawn2 = window.create(monitor, 19, 9, 8, 1, true)
- if (spawn2State == false) then
- spawn2.setBackgroundColor(colors.red)
- spawn2.write("Disabled")
- else
- spawn2.setBackgroundColor(colors.green)
- spawn2.write("Enabled ")
- end
- ----------------------------------
- end
- rednet.open("back")
- monitor = peripheral.wrap("top")
- monitor.setBackgroundColor(colors.blue)
- monitor.setTextScale(1)
- monitor.clear()
- monitor.setCursorPos(4, 1)
- monitor.write("Quad Spawner Controller")
- update()
- door1State = false
- door2State = false
- door3State = false
- door4State = false
- spawn1State = false
- spawn2State = false
- while (true) do
- update()
- updateRedstone()
- event, side, x, y = os.pullEvent("monitor_touch")
- click = checkClick(x, y)
- if (click == 1) then
- door1State = toggleState(door1State)
- elseif (click == 2) then
- door2State = toggleState(door2State)
- elseif (click == 3) then
- door3State = toggleState(door3State)
- elseif (click == 4) then
- door4State = toggleState(door4State)
- elseif (click == 5) then
- spawn1State = toggleState(spawn1State)
- elseif (click == 6) then
- spawn2State = toggleState(spawn2State)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement