Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ Config ]]--
- -- Colors --
- topBar = colors.blue
- middleBar = colors.lightBlue
- bottomBar = colors.white
- textHeader = colors.white
- textBody = colors.black
- --[[ Functions ]]--
- -- GUI --
- function drawGUI()
- x, y = term.getCursorPos()
- term.setCursorPos(1, 1)
- term.setBackgroundColor(topBar)
- local w, h = term.getSize()
- print(string.rep(" ", w))
- print(string.rep(" ", w))
- term.setBackgroundColor(middleBar)
- print(string.rep(" ", w))
- x2, y2 = term.getCursorPos()
- i2 = h - y2
- term.setBackgroundColor(bottomBar)
- for i = 1, i2 do
- print(string.rep(" ", w))
- end
- write(string.rep(" ", w))
- term.setBackgroundColor(colors.black)
- term.setCursorPos(x2, y2 + 1)
- end
- function drawInfo()
- term.setCursorPos(1, 2)
- term.setBackgroundColor(topBar)
- term.setTextColor(textHeader)
- print("Printer V1.0!")
- w, h = term.getSize()
- term.setBackgroundColor(middleBar)
- print(string.rep("-", w))
- term.setBackgroundColor(bottomBar)
- term.setTextColor(textBody)
- term.setCursorPos(1, 5)
- end
- --[[ Interface ]]--
- -- Draw GUI & Information --
- drawGUI()
- drawInfo()
- -- Receive User Input --
- MaxLength = 8
- WidthLength = 40
- Line = 1
- x, y = term.getCursorPos()
- Message = { }
- while true do
- term.setCursorPos(x, y)
- -- term.setCursorBlink(true)
- for k, v in pairs(Message) do
- print(v)
- end
- event, key = os.pullEvent()
- if event == "char" then
- if #Message > MaxLength then
- else
- if Message[Line] then
- if #Message[Line] > WidthLength then
- Line = Line + 1
- table.insert( Message, "" )
- else
- Message[Line] = Message[Line] .. key
- end
- else
- table.insert(Message, "")
- end
- end
- elseif event == "key" then
- if key == 28 then
- Line = Line + 1
- table.insert(Message, "")
- elseif key == 29 then
- --term.setCursorBlink(false)
- break
- elseif key == 14 then
- if #Message[Line] > 1 then
- local x, y = term.getCursorPos()
- local old = Message[Line]
- Message[Line] = old:sub( 1, string.len( old ) - 1 )
- term.setCursorPos( x-1, y )
- write(" ")
- term.setCursorPos(x, y)
- else
- table.remove(Message[Line], "")
- Line = Line - 1
- end
- end
- end
- end
- term.clear()
- term.setCursorPos(1, 1)
- drawGUI()
- drawInfo()
- write("Enter Message Name: ")
- Message = read()
- write("\nThis would be your message name: \n" .. Message)
Advertisement
Add Comment
Please, Sign In to add comment