Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --A small API made to allow a long list of text to be broken up into two lists, side by side.
- --This works fine on monitors.
- --Takes in string, delay between lines (seconds), line rollover X, line rollover Y, and the Y where it rolls over.
- function sprint(input, delay, nextLineX, nextLineY, itemThreshold)
- if input == nil then
- error("no input inputted, dude.")
- else
- if type(input) ~= "table" then
- input = {input}
- end
- posX, posY = term.getCursorPos()
- scr_x, scr_y = term.getSize()
- if nextLineX == nil then
- nextLineX = 25
- end
- if nextLineY == nil then
- nextLineY = 2
- end
- if itemThreshold == nil then
- itemThreshold = scr_y
- end
- scrollOver = 0
- itemX = posX
- itemY = posY
- startX = posX
- startY = posY
- itemXPosses = {}
- itemYPosses = {}
- doesntFit = false
- for a = 1, #input do
- if input[a] ~= nil and doesntFit == false then
- if itemY >= itemThreshold then
- scrollOver = scrollOver + 1
- itemX = startX + (nextLineX * scrollOver)
- itemY = nextLineY
- end
- term.setCursorPos(itemX,itemY)
- itemY = itemY + 1
- if delay ~= 0 and delay ~= nil then
- sleep(delay)
- end
- posX, posY = term.getCursorPos()
- scr_x, scr_y = term.getSize()
- if scr_x - posX >= nextLineX then
- write(input[a])
- else
- doesntFit = true
- return false
- end
- table.insert(itemXPosses, itemX)
- table.insert(itemYPosses, itemY)
- end
- end
- posX, posY = term.getCursorPos()
- if doesntFit == false then
- if input[#input] ~= nil then
- endPosX = posX - string.len(input[#input])
- end
- endPosY = posY + 1
- term.setCursorPos(endPosX,endPosY)
- end
- return true
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement