Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local signText = "Default sign text. To change the text, type 'edit sign' in your computer terminal"
- local textSize = 1
- local signMonitor = nil
- if peripheral.getType("back") == "monitor" then
- signMonitor = peripheral.wrap("back")
- print("found monitor on the back")
- elseif peripheral.getType("left") == "monitor" then
- signMonitor = peripheral.wrap("left")
- print("found monitor on the left")
- elseif peripheral.getType("right") == "monitor" then
- signMonitor = peripheral.wrap("right")
- print("found monitor on the right")
- elseif peripheral.getType("top") == "monitor" then
- signMonitor = peripheral.wrap("top")
- print("found monitor on the top")
- elseif peripheral.getType("bottom") == "monitor" then
- signMonitor = peripheral.wrap("bottom")
- print("found monitor on the bottom")
- else
- print("No Monitor found")
- end
- if signMonitor then
- signMonitor.clear()
- signMonitor.setCursorPos(1,1)
- signMonitor.setTextScale(textSize)
- local w,h = signMonitor.getSize()
- local len = string.len(signText)
- local totalLines = math.ceil(len/w)
- local lines = {}
- local words = {}
- print("should be "..totalLines.." lines")
- for word in signText:gmatch("%S+") do table.insert(words,word) end
- while #words>0 do
- local lineFinished=false
- local newLine = ""
- while lineFinished == false do
- if #words>0 and #newLine + #words[1] +1 < w then
- local word = table.remove(words,1)
- newLine = newLine.." "..word
- else
- table.insert(lines,newLine)
- print("added a new line")
- lineFinished=true
- end
- end
- end
- print(w.."/"..h)
- local y = 1
- for i,v in ipairs(lines) do
- signMonitor.setCursorPos(1,y)
- signMonitor.write(v)
- y = y +1
- end
- else
- print("place a monitor next to the computer and try again")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement