Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- xXm0dzXx Default Programming API ---
- -- All my programs will have this :DD --
- ----------------------------------------
- local x,y = term.getSize()
- local function cPrint( txt ) --Version 2.0 of cPrint
- local function printC( text )
- x2,y2 = term.getCursorPos()
- term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
- write(text.. "\n")
- end
- if type(txt) == "string" then
- printC( txt )
- elseif type(txt) == "table" then
- for i=1,#txt do
- printC( txt[i] )
- end
- end
- end
- local function lPrint( txt )
- local x2, y2 = term.getCursorPos()
- term.setCursorPos( (x-(#txt))+1, y2 )
- write( text )
- end
- local drawingBoard = {
- ["A"] = colors.white,
- ["B"] = colors.orange,
- ["C"] = colors.magenta,
- ["D"] = colors.lightBlue,
- ["E"] = colors.yellow,
- ["F"] = colors.lime,
- ["G"] = colors.pink,
- ["H"] = colors.gray,
- ["I"] = colors.lightGray,
- ["J"] = colors.cyan,
- ["K"] = colors.purple,
- ["L"] = colors.blue,
- ["M"] = colors.brown,
- ["N"] = colors.green,
- ["O"] = colors.red,
- ["P"] = colors.black,
- }
- local function advWrite( pos1, pos2, str )
- for i=1,#str do
- local symb = drawingBoard[ string.sub( str, i, i) ]
- term.setCursorPos( pos1 + (i-1) , pos2 )
- if symb then
- term.setBackgroundColour( symb )
- write(" ")
- end
- end
- end
- local function setBG( col, colz )
- term.setBackgroundColour( col )
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColour( colz )
- end
- local function getLines( path )
- local tLines = {}
- local file = fs.open( path, "r" )
- if file then
- line = file.readLine()
- while line do
- tLines[ #tLines+1 ] = line
- line = file.readLine()
- end
- file.close()
- end
- return tLines
- end
- -- End of API --
- local selection = 1
- local function newButton( name, sel )
- if selection == sel then
- cPrint( "[ " ..name.. " ]" )
- else
- cPrint( name )
- end
- end
- os.startTimer( 0 )
- while true do
- term.clear()
- term.setCursorPos(1,1)
- cPrint( "xXm0dzXx Light Control" )
- print( string.rep( "-", x ) )
- print()
- term.setTextColour( colors.green )
- newButton( "Turn on lights", 1 )
- newButton( "Turn off lights", 2 )
- print()
- term.setTextColour( colors.red )
- newButton( "Exit", 3 )
- term.setTextColour( colors.white )
- term.setCursorPos( y-1 )
- print( string.rep( "-", x ) )
- lPrint( textutils.formatTime( os.time() ) )
- local event, key = os.pullEvent()
- if event == "key" then
- if key == keys.up then
- if selection ~= 1 then
- selection = selection -1
- end
- elseif key == keys.down then
- if selection ~= 3 then
- selection = selection +1
- end
- elseif key == keys.enter then
- if selection == 1 then
- rs.setOutput( "back", true )
- elseif selection == 2 then
- rs.setOutput( "back", false )
- elseif selection == 3 then
- term.clear()
- term.setCursorPos(1,1)
- print( "AWESOMEOS v1.0.43.34.5.5.63.365.346.53465..35356" )
- error()
- end
- end
- end
- os.startTimer( 0 )
- end
Advertisement
Add Comment
Please, Sign In to add comment