Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("bigfont.lua")
- local text = nil
- if not fs.exists("text.txt") then
- printError("Must create text.txt")
- else
- local textFile = fs.open("text.txt", "r")
- text = {}
- for line in textFile.readLine do
- table.insert(text, line)
- end
- textFile.close()
- end
- local function draw(name)
- local mon = peripheral.wrap(name)
- mon.setTextScale(1)
- local w, h = mon.getSize()
- mon.setBackgroundColour(colours.green)
- mon.setTextColour(colours.white)
- mon.clear()
- if text then
- bigfont.writeOn(mon, 1, text[2])
- mon.setCursorPos(math.floor((w - (#text[2] * 3)) / 2) - #(text[1]), math.floor(h / 2) + 1)
- mon.write(text[1])
- mon.setCursorPos(math.floor((w - (#text[2] * 3)) / 2) + (#text[2] * 3) + 2, math.floor(h / 2) + 1)
- mon.write(text[3])
- else
- bigfont.writeOn(mon, 1, "New Street", nil, 1)
- local hint1 = "Help name this street!"
- local hint2 = "Send name + coordinates to Yemmel#2747!"
- mon.setCursorPos(math.floor((w - #hint1) / 2) + 1, math.floor(h / 2) + 2)
- mon.write(hint1)
- mon.setCursorPos(math.floor((w - #hint2) / 2) + 1, math.floor(h / 2) + 3)
- mon.write(hint2)
- end
- end
- peripheral.find("monitor", draw)
- while true do
- local _, name = os.pullEvent("peripheral")
- if peripheral.getType(name) == "monitor" then draw(name) end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement