Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local advTerm = {}
- --Ultime Studios AdvTerm Library
- --Includes: Write(v2), Clear(v2), ClearWrite(v1)
- function advTerm.ClearWrite(str)
- --termClearWrite v1
- terminalClear()
- terminalWrite(str)
- end
- function advTerm.write(str)
- -- terminalWrite v2
- currentX = 1
- currentY = 1
- xLimit, yLimit = term.getSize()
- -- Checking string length, checking screen if full or need new line.
- local strLength = string.len(str)
- currentX = currentX + strLength
- if strLength <= xLimit then --Check if string is too long for the screen
- term.clear()
- term.setCursorPos(1,1)
- term.write("TermAPI Terminal Write error 1")
- term.setCursorPos(1,2)
- term.write("Requested string too long to print")
- error('',0)
- end
- if currentX + strLength > xLimit then
- currentY = currentY + 1
- end
- if currentY > yLimit then
- terminalClear()
- term.setCursorPos(1,1)
- currentX = 1
- curentY = 1
- end
- -- Correcting for X axis
- local charX = currentX - strLength
- if charX <= 1 then
- charX = 1
- end
- -- Setting cursorpos with corrected X and Y.
- term.setCursorPos(charX, currentY)
- -- Write new text
- term.write(str)
- end
- function advTerm.Clear()
- -- terminalClear v2
- term.clear()
- term.setCursorPos(1,1)
- --comment out rest of function if 'terminalWrite' not present
- currentX = 1
- currentY = 1
- end
- return advTerm
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement