SHOW:
|
|
- or go back to the newest paste.
1 | chat=peripheral.wrap("right") | |
2 | monitor=peripheral.wrap("bottom") | |
3 | monitor.clear() | |
4 | - | monitor.setBackgroundColor(green) |
4 | + | monitor.setBackgroundColor(32) |
5 | line=1 | |
6 | while true do | |
7 | monitor.setCursorPos(1,line) | |
8 | local event, player, message= os.pullEvent("chat") | |
9 | toprint=player .. (": ") .. message | |
10 | playerlen=string.len(player)+2 | |
11 | if string.len(toprint)>82 then | |
12 | if line>39 then | |
13 | line=line-1 | |
14 | monitor.scroll(1) | |
15 | monitor.setCursorPos(1,line) | |
16 | end | |
17 | pos=string.find(message," ") | |
18 | if pos<82-playerlen then | |
19 | prevpos=pos | |
20 | pos=string.find(message," ", pos+1) | |
21 | while pos<82-playerlen do | |
22 | prevpos=pos | |
23 | pos = string.find(message," ",pos+1) | |
24 | end | |
25 | monitor.write(player .. (": ") .. string.sub(message, 0 ,prevpos-1)) | |
26 | line=line+1 | |
27 | monitor.setCursorPos(1,line) | |
28 | monitor.write(string.sub(message, prevpos)) | |
29 | else | |
30 | monitor.write(player .. (": ") .. string.sub(message, 0, 82-playerlen)) | |
31 | line=line+1 | |
32 | monitor.setCursorPos(1,line) | |
33 | monitor.write(string.sub(message,83-playerlen)) | |
34 | end | |
35 | else | |
36 | monitor.write(player .. (": ") .. message) | |
37 | end | |
38 | line=line+1 | |
39 | if line > 40 then | |
40 | monitor.scroll(1) | |
41 | line=line-1 | |
42 | end | |
43 | end |