Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Computer ID = 6
- --# load the touchpoint API
- os.unloadAPI("touchpoint")
- os.loadAPI("touchpoint")
- local monitorSide = "back"
- local wlmSide = "right"
- local rcSide = "top"
- -- Connecting Peripheral
- local wirelessModem = peripheral.wrap(wlmSide)
- local replyChannel = 1
- local listenChannel = 3
- --Fill this table with the names of mobs
- --local inputs = {"Zombie", "Enderman", "Wither Skeleton", "Peach Forager", "Creeper", "Blaze"}
- local inputs = {"Enderman"}
- local currMob = "NONE"
- local t = touchpoint.new(monitorSide)
- --Init
- spawnerStatus = false
- ligthStatus = false
- grinderStatus = false
- doorStatus = false
- exactSp = ""
- function callTurtle(message,argument)
- myMes={message=message, argument=argument}
- mySerMes=textutils.serialize(myMes)
- wirelessModem.transmit(3, 1, mySerMes)
- wirelessModem.open(1)--Open channel 1 so that we can listen on it
- --local event, modemSide, senderChannel, replyChannel, mySerMes, senderDistance = os.pullEvent("modem_message")
- --myUnsMes=textutils.unserialize(mySerMes)
- --print (myUnsMes)
- --return myUnsMes
- end
- function setMob2Spawn(mobId)
- callTurtle("setMob2Spawn",mobId)
- end
- function removeMob()
- callTurtle("removeMob",0)
- end
- function powerOnDrawBridge()
- t:toggleButton("Door")
- rs.setBundledOutput(rcSide,colors.orange)
- if doorStatus == true then
- print ("Door Opened")
- else
- print ("Door Closed")
- end
- sleep(0.5)
- rs.setBundledOutput(rcSide,0)
- doorStatus = not doorStatus
- end
- -- Check if this is really working
- function powerOnGrinder()
- t:toggleButton("Grinder")
- rs.setBundledOutput(rcSide,colors.red)
- if grinderStatus == true then
- print ("Grinder Activated")
- else
- print ("Grinder Deactivated")
- end
- sleep(0.5)
- rs.setBundledOutput(rcSide,0)
- grinderStatus = not grinderStatus
- end
- function ligthSwitch()
- t:toggleButton("Light")
- rs.setBundledOutput(rcSide,colors.white)
- if ligthStatus == true then
- print ("Light Activated")
- else
- print ("Light Deactivated")
- end
- sleep(0.5)
- rs.setBundledOutput(rcSide,0)
- ligthStatus = not ligthStatus
- end
- function powerOnSpawner()
- t:toggleButton("Spawner")
- rs.setBundledOutput(rcSide,colors.black)
- if spawnerStatus == true then
- print ("Spawner Activated")
- else
- print ("Spawner Deactivated")
- end
- sleep(0.5)
- rs.setBundledOutput(rcSide,0)
- spawnerStatus = not spawnerStatus
- end
- function testCable()
- rs.setBundledOutput(rcSide,0)
- ligthStatus = rs.testBundledInput(rcSide, colors.magenta)
- if ligthStatus == true then
- t:toggleButton("Light")
- end
- doorStatus = rs.testBundledInput(rcSide, colors.lightBlue)
- if doorStatus == true then
- t:toggleButton("Door")
- end
- grinderStatus = rs.testBundledInput(rcSide, colors.yellow)
- if grinderStatus == false then
- t:toggleButton("Grinder")
- end
- spawnerStatus = rs.testBundledInput(rcSide, colors.lime)
- if spawnerStatus == false then
- t:toggleButton("Spawner")
- end
- end
- function creatingScreen()
- local title="Light"
- local sx=2
- local fx =(sx+#title+1)
- t:add(title, ligthSwitch, sx, 2, fx, 4, colors.red, colors.lime)
- title="Door"
- sx=fx+2
- fx =(sx+#title+2)
- t:add(title, powerOnDrawBridge, sx, 2, fx, 4, colors.red, colors.lime)
- title="Grinder"
- sx=fx+2
- fx =(sx+#title+2)
- t:add(title, powerOnGrinder, sx, 2, fx, 4, colors.red, colors.lime)
- title="Spawner"
- sx=fx+2
- fx =(sx+#title+2)
- t:add(title, powerOnSpawner, sx, 2, fx, 4, colors.red, colors.lime)
- sx=2
- sy=6
- for mobId, mobName in pairs(inputs) do
- fx= sx + #mobName + 1
- fy=sy+2
- t:add(mobName, function () setMob2Spawn(mobId) end, sx, sy, fx, fy, colors.red, colors.lime)
- sx = fx + 2
- if fx > 30 then
- sx=2
- sy=sy+4
- end
- end
- --print("Draw Menu")
- t:draw()
- end
- --Run
- --print("Screen Creation")
- creatingScreen()
- testCable()
- while true do
- local event, p1 = t:handleEvents(os.pullEvent())
- if event == "button_click" then
- t.buttonList[p1].func()
- end
- if event == "modem_message" then
- myUnsMes=textutils.unserialize(mySerMes)
- print (myUnsMes)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement