-
Notifications
You must be signed in to change notification settings - Fork 0
/
policeNews.lua
47 lines (41 loc) · 1.1 KB
/
policeNews.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
local news = "Die Polizeistation ist Aufgrund von Umbaubarbeiten derzeit geschlossen."
local speed = 6
local textScaling = 2
local backgroundColor = colors.black
local foregroundColor = colors.white
local mon = peripheral.find("monitor")
local sizeX, sizeY = mon.getSize()
sizeX = sizeX/textScaling
sizeY = sizeY/textScaling
local newsLength = string.len(news)
local subFrom = 1
local subLength = 1
local offset = sizeX
local function ShiftLeft()
if offset > 1 then
offset = offset - 1
if subLength < newsLength then
subLength = subLength + 1
end
else
subFrom = subFrom + 1
if subLength < newsLength then
subLength = subLength + 1
end
if subFrom > subLength+1 then
subFrom = 1
subLength = 1
offset = sizeX
end
end
end
mon.setBackgroundColor(backgroundColor)
mon.setTextColor(foregroundColor)
mon.setTextScale(textScaling)
while true do
mon.clear()
mon.setCursorPos(offset, sizeY/2)
mon.write(string.sub(news, subFrom, subLength))
ShiftLeft()
os.sleep(1/speed)
end