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