Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local redside = "back" -- Redstone Output Seite
- local monside = "top" -- Seite des Monitors
- local option1 = 60 -- Zeit fuer Option1 in s
- local option2 = 120 -- Zeit fuer Option2 in s
- local option3 = 180 -- Zeit fuer Option3 in s
- local option4 = 300 -- Zeit fuer Option4 in s
- local option5 = 600 -- zeit fuer Option5 in s
- local input = 0 -- Diesen Wert nicht veraendern
- local time = 0 -- Diesen Wert nicth veraendern
- m = peripheral.wrap(monside)
- m.clear()
- redstone.setOutput(redside,false)
- function Layout()
- m.setBackgroundColor(colors.cyan)
- m.clear()
- m.setCursorPos(1,1)
- m.write(option1)
- m.write(" ")
- m.setBackgroundColor(colors.green)
- m.setCursorPos(1,2)
- m.write(option2)
- m.write(" ")
- m.setBackgroundColor(colors.yellow)
- m.setCursorPos(1,3)
- m.write(option3)
- m.write(" ")
- m.setBackgroundColor(colors.orange)
- m.setCursorPos(1,4)
- m.write(option4)
- m.write(" ")
- m.setBackgroundColor(colors.red)
- m.setCursorPos(1,5)
- m.write(option5)
- m.write(" ")
- end
- Layout()
- function SetTime()
- if input == 1 then
- time = option1
- elseif input == 2 then
- time = option2
- elseif input == 3 then
- time = option3
- elseif input == 4 then
- time = option4
- elseif input == 5 then
- time = option5
- end
- end
- function CancelButton()
- m.setBackgroundColor(colors.green)
- m.setTextColor(colors.red)
- m.setCursorPos(1,5)
- m.write("Cancel")
- m.setBackgroundColor(colors.red)
- m.setTextColor(colors.white)
- end
- local function isIn( tbl, value ) --#table search function.
- for k, v in pairs( tbl ) do
- if v == value then
- return true
- end
- end
- return false
- end
- function doRedstone( side, time )
- rs.setOutput( side, true ) --#turn on redstone
- local ids = {}
- for i = 0.1, time, 0.1 do --#make a bunch of timers.
- ids[ #ids + 1 ] = os.startTimer( i )
- end
- local num = 0
- while true do --#loop
- local event = {os.pullEvent()} --#pull an event
- if event[ 1 ] == "timer" and event[ 2 ] == ids[ #ids ] then --#last timer is up
- break --#exit the loop
- elseif event[ 1 ] == "monitor_touch" and event[ 3 ] >= 1 and event[ 4 ] == 5 then --#button was pushed
- break --#exit the loop
- elseif event[ 1 ] == "timer" and isIn( ids, event[ 2 ] ) then --#the event was a timer we made, but not the last one
- num = num + 0.1
- term.setCursorPos( 1, 1 )
- term.write( num )
- end
- end
- rs.setOutput( side, false ) --#turn off redstone
- end
- function Toggle()
- Layout()
- SetTime()
- doRedstone()
- Layout()
- end
- while true do
- event,side,x,y = os.pullEvent()
- if event == "monitor_touch" then
- if x >= 1 and y == 1 then
- input = 1
- Toggle()
- elseif x >= 1 and y == 2 then
- input = 2
- Toggle()
- elseif x >= 1 and y == 3 then
- input = 3
- Toggle()
- elseif x >= 1 and y == 4 then
- input = 4
- Toggle()
- elseif x >= 1 and y == 5 then
- input = 5
- Toggle()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment