Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- monitor = peripheral.wrap("top")
- function xwrite(text,x,y)
- monitor.setCursorPos(x,y)
- monitor.write(text)
- end
- function writefit(text,xStart,yStart,xEnd)
- local rowLength = xEnd-xStart
- local restString = text
- if text == nil then restString ="" end
- local yline = 0
- local spacePos = 0
- local printString = ""
- local teststring = ""
- while string.len(restString) > rowLength do
- spacePos = rowLength
- teststring = string.sub(restString,1,rowLength)
- while string.find(teststring," ",spacePos) == nil and spacePos > 1 do
- spacePos = spacePos-1
- end
- if spacePos == 1 then spacePos = rowLength end
- printString = string.sub(restString,1,spacePos)
- xwrite(printString,xStart,yStart+yline)
- restString = string.sub(restString,spacePos+1)
- yline = yline+1
- end
- xwrite(restString,xStart,yStart+yline)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement