Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- this code is poorly optimised and written.
- the functionality of this code is to controll doors. that's it. nothing special.
- future improvements include: larger buttons, key disk support and password support all of which i can do myself.
- reffer to line 42 for detailed info on my issues...
- ]]
- term.clear()
- term.setCursorPos(1,1)
- local oldBgC = term.getBackgroundColor()
- local BgC = colors.red
- local sOut = false
- local w,h = term.getSize()
- while true do
- --defining button color
- local out = rs.getOutput("bottom")
- if out then
- BgC = colors.green
- else
- BgC = colors.red
- end
- --button "write"
- term.setCursorPos(1,1)
- term.clearLine()
- term.setCursorPos(2,2)
- term.setBackgroundColor(BgC)
- term.write(" ")
- term.setBackgroundColor(oldBgC)
- --button "handeler"
- local event, mb, x, y = os.pullEvent("mouse_click")
- if x == 2 and y == 2 then
- sOut = not out
- end
- rs.setOutput("bottom",sOut)
- --here's where i'm stuck;
- --calling exit() causes the program to halt until it's satisfied or errors.
- --parallel imo isn't what i'd need rather coroutines.
- --but i can't, for the life of me, get them to cooperate dispite
- --the lua 5.1, 5.3 manual refferancing.
- --all i need help with is getting an input field at the very bottom to be able to
- --pass comands and args to the program while still pulling mouse_click events
- --exit "handeler"
- function exit()
- term.setCursorPos(1,h-2)
- term.clearLine()
- term.setCursorPos(1,h-1)
- term.write('type "exit()" to exit')
- term.setCursorPos(1,h)
- if read() == "exit()" then
- ex = true
- end
- end
- if ex == true then break end
- --debug, ignore this
- --[[
- local w,h = term.getSize()
- term.setCursorPos(1,h)
- term.clearLine()
- print("cordinates> "..x..","..y)
- term.setCursorPos(1,7)
- term.clearLine()
- --]]
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement