Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --set the side the monitor is connected to
- m = peripheral.wrap("bottom")
- --set the name of the container above the IO port
- c = peripheral.wrap("container_chest_0")
- --set the side to send the redstone signal to
- r = "left"
- m.setTextScale(.5)
- function MakeButton(l,n1,n2,c,c2)
- if c == nil then c = colors.blue end
- if c2 == nil then c2= colors.white end
- local n1p = 10 - (string.len(n1)/2)
- local n2p = 10 - (string.len(n2)/2)
- if l>3 then p2 = 13 else p2 = 1 end
- if l == 1 or l == 4 then p1 = 1
- elseif l < 4 then p1 = (l-1)*19
- elseif l > 4 then p1 = (l-4)*19
- end
- m.setBackgroundColor(c)
- m.setTextColor(c2)
- m.setCursorPos((p1+n1p),(p2+5))
- m.write(n1)
- m.setCursorPos((p1+n2p),(p2+6))
- m.write(n2)
- end
- function DrawScreen()
- m.setBackgroundColor(colors.black)
- m.clear()
- MakeButton(1,"Eden","Program",colors.green)
- MakeButton(2,"Dungeon","Program")
- MakeButton(3,"Unset","Program",colors.red,colors.black)
- MakeButton(4,"Unset","Program",colors.red,colors.black)
- MakeButton(5,"Unset","Program",colors.red,colors.black)
- MakeButton(6,"Unset","Program",colors.red,colors.black)
- end
- function Load(p)
- --push cell into port
- m.setBackgroundColor(colors.black)
- m.setTextColor(colors.white)
- m.clear()
- if c.pushItem("down",p) == 0 then
- m.clear()
- m.setCursorPos(2,12)
- m.setTextColor(colors.red)
- error("An error has occurred please contact engineering")
- end
- --turn on redstone to activate port
- redstone.setOutput(r,true)
- --fancy loading thing
- m.setCursorPos(23,10)
- m.write("Loading...")
- m.setCursorPos(18,11)
- m.setBackgroundColor(colors.white)
- m.write(" ")
- m.setCursorPos(18,12)
- m.write(" ")
- m.setCursorPos(39,12)
- m.write(" ")
- m.setCursorPos(18,13)
- m.write(" ")
- m.setCursorPos(19,12)
- m.setBackgroundColor(colors.red)
- m.setTextColor(colors.red)
- term.redirect(m)
- textutils.slowWrite("....................",5)
- term.native()
- --end fancy loading thing
- --reset the redstone output
- redstone.setOutput(r,false)
- --pull cell from port
- if c.pullItem("down",2) == 0 then
- m.clear()
- m.setCursorPos(2,12)
- m.setTextColor(colors.red)
- error("An error has occurred please contact engineering")
- end
- --draw unload button
- m.setBackgroundColor(colors.black)
- m.setTextColor(colors.white)
- m.clear()
- m.setCursorPos(18,11)
- m.setBackgroundColor(colors.red)
- m.write(" ")
- m.setCursorPos(18,12)
- m.write(" ")
- m.setCursorPos(39,12)
- m.write(" ")
- m.setCursorPos(18,13)
- m.write(" ")
- m.setCursorPos(26,12)
- m.setBackgroundColor(colors.black)
- m.setTextColor(colors.red)
- m.write("UNLOAD")
- --wait for screen click to unload
- local event, side, xPos, yPos = os.pullEvent(monitor_touch)
- --push cell into port
- if c.pushItem("down",p) == 0 then
- m.setBackgroundColor(colors.black)
- m.clear()
- m.setCursorPos(2,12)
- m.setTextColor(colors.red)
- error("An error has occurred please contact engineering")
- end
- --turn on redstone to activate port
- redstone.setOutput(r,true)
- --fancy loading thing
- m.setBackgroundColor(colors.black)
- m.setTextColor(colors.white)
- m.clear()
- m.setCursorPos(21,10)
- m.write("Unloading...")
- m.setCursorPos(18,11)
- m.setBackgroundColor(colors.white)
- m.write(" ")
- m.setCursorPos(18,12)
- m.write(" ")
- m.setCursorPos(39,12)
- m.write(" ")
- m.setCursorPos(18,13)
- m.write(" ")
- m.setCursorPos(19,12)
- m.setBackgroundColor(colors.red)
- m.setTextColor(colors.red)
- term.redirect(m)
- textutils.slowWrite("....................",10)
- term.native()
- --end fancy loading thing
- --pull cell from port
- if c.pullItem("down",2) == 0 then
- m.setBackgroundColor(colors.black)
- m.clear()
- m.setCursorPos(2,12)
- m.setTextColor(colors.red)
- error("An error has occurred please contact engineering")
- end
- --reset redstone output
- redstone.setOutput(r,false)
- --redraw the button screen
- DrawScreen()
- end
- --initialize screen
- DrawScreen()
- --main program loop
- while true do
- --wait for monitor touch event
- local event, side, xPos, yPos = os.pullEvent(monitor_touch)
- print(event,",",side,",",xPos,",",yPos)
- --Determine what area of the screen was clicked
- if yPos < 13 and xPos < 20 then prog = 1
- elseif yPos < 13 and (xPos > 19 and xPos < 39) then prog = 2
- elseif yPos < 13 and xPos > 38 then prog = 3
- elseif yPos > 12 and xPos < 20 then prog = 4
- elseif yPos > 12 and (xPos > 19 and xPos < 39) then prog = 5
- elseif yPos > 12 and xPos > 38 then prog = 6
- end
- print(prog)
- --send the choice to load function
- Load(prog)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement