Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = peripheral.wrap("back")
- lx,ly = mon.getSize()
- mon.setBackgroundColor(colors.blue)
- mon.clear()
- mon.setTextScale(2)
- mon.setCursorPos(lx/2-3,1)
- mon.setTextColor(colors.yellow)
- mon.write("SPAWNERS")
- sp1_side = "right" -- Cursed Earth
- sp2_side = "front"
- sp3_side = "left"
- rs.setOutput(sp1_side, true)
- rs.setOutput(sp2_side, true)
- rs.setOutput(sp3_side, true)
- --fonctions
- function switch_signal(side)
- if rs.getInput(side) == true then
- rs.setOutput(side, false)
- else
- rs.setOutput(side, true)
- end
- end
- function boutons()
- create_button(math.floor(0.05*lx)+1,math.floor(0.3*lx)+1,(ly/3),(ly/3)+2,colors.red,"SPA1 OFF",colors.orange)
- create_button(math.floor(0.35*lx)+1,math.floor(0.65*lx)+1,(ly/3),(ly/3)+2,colors.red,"SPA2 OFF",colors.orange)
- create_button(math.floor(0.7*lx)+1,math.floor(0.95*lx)+1,(ly/3),(ly/3)+2,colors.red,"SPA3 OFF",colors.orange)
- create_button(math.floor(0.05*lx)+1,math.floor(0.3*lx)+1,((ly/3)*2),((ly/3)*2)+2,colors.green,"SPA1 ON",colors.black)
- create_button(math.floor(0.35*lx)+1,math.floor(0.65*lx)+1,((ly/3)*2),((ly/3)*2)+2,colors.green,"SPA2 ON",colors.black)
- create_button(math.floor(0.7*lx)+1,math.floor(0.95*lx)+1,((ly/3)*2),((ly/3)*2)+2,colors.green,"SPA3 ON",colors.black)
- end
- function create_button(xmin, xmax, ymin, ymax, color, text, tcolor)
- local aire = 0
- local xtemp, ytemp = xmin, ymin
- while aire < (((xmax-xmin)+1)*((ymax-ymin)+1)) do
- mon.setBackgroundColor(color)
- mon.setCursorPos(xtemp,ytemp)
- mon.write(" ")
- if xtemp == xmax then
- xtemp = xmin
- ytemp = ytemp + 1
- else
- xtemp = xtemp + 1
- end
- aire = aire + 1
- end
- mon.setTextColor(tcolor)
- mon.setCursorPos((xmin+xmax)/2 - (string.len(text)/2) + 1, (ymax+ymin)/2)
- mon.write(text)
- mon.setBackgroundColor(colors.blue)
- end
- function touch_detect(lx, ly)
- local tevent, cote, x, y = os.pullEvent("monitor_touch")
- mon.setTextColor(colors.yellow)
- if y <=ly/2 then
- if x < lx/3 then
- rs.setOutput(sp1_side, true)
- elseif x>lx/3 and x<(lx/3)*2 then
- rs.setOutput(sp2_side, true)
- else
- rs.setOutput(sp3_side, true)
- end
- else
- if x < lx/3 then
- rs.setOutput(sp1_side, false)
- elseif x>lx/3 and x<(lx/3)*2 then
- rs.setOutput(sp2_side, false)
- else
- rs.setOutput(sp3_side, false)
- end
- end
- end
- function status_set(side)
- mon.setCursorPos(0.25*lx,0.9*ly)
- if rs.getInput(sp1_side) == false then
- mon.write("ON ")else mon.write("OFF")
- end
- mon.setCursorPos(0.6*lx,0.9*ly)
- if rs.getInput(sp2_side) == false then
- mon.write("ON ")else mon.write("OFF")
- end
- mon.setCursorPos(0.92*lx,0.9*ly)
- if rs.getInput(sp3_side) == false then
- mon.write("ON ")else mon.write("OFF")
- end
- end
- function set_status()
- mon.setTextColor(colors.yellow)
- mon.setCursorPos((lx/20)*1.5,0.9*ly)
- mon.write("Status:")
- mon.setCursorPos((lx/20)*8,0.9*ly)
- mon.write("Status:")
- mon.setCursorPos((lx/20)*14.5,0.9*ly)
- mon.write("Status:")
- end
- function stat_off()--mep
- mon.setCursorPos(0.25*lx,0.9*ly)
- mon.write("OFF")
- mon.setCursorPos(0.6*lx,0.9*ly)
- mon.write("OFF")
- mon.setCursorPos(0.92*lx,0.9*ly)
- mon.write("OFF")
- end
- function spawn()
- mon.setCursorPos(lx/2-3,1)
- mon.setTextColor(colors.yellow)
- mon.write("SPAWNERS")
- end
- --main
- stat_off()
- while true do
- mon.clear()
- set_status()
- spawn()
- boutons()
- status_set()
- touch_detect(lx,ly)
- end
- --code par appollon41, version OpenSource
Add Comment
Please, Sign In to add comment