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