SHOW:
|
|
- or go back to the newest paste.
1 | rednet.open('top') | |
2 | local printer = peripheral.wrap('right') | |
3 | local speaker = peripheral.wrap('bottom') | |
4 | function printF() | |
5 | while true do | |
6 | local rn = {rednet.receive()} | |
7 | if rn[3] == 'print' and rn[2][1] then | |
8 | local txt = rn[1]..' printed document ' | |
9 | local docfile = #fs.list('files/')+1 | |
10 | - | txt = txt..tostring(docfile)..'at ['..string.sub(os.date(),12,-6)..']' |
10 | + | txt = txt..tostring(docfile)..' at ['..string.sub(os.date(),12,-6)..']' |
11 | local file = fs.open('files/'..tostring(docfile),'w') | |
12 | file.write(rn[2]) | |
13 | file = fs.open('log.txt','a') | |
14 | file.writeLine(txt) | |
15 | file.close() | |
16 | if printer.newPage() then | |
17 | speaker.playNote('harp',1,1) | |
18 | sleep(0.2) | |
19 | speaker.playNote('harp',1,1) | |
20 | local counter = 0 | |
21 | for i,v in ipairs(rn[2]) do | |
22 | counter = counter + 1 | |
23 | local line = nil | |
24 | if counter > 21 then | |
25 | counter = 1 | |
26 | printer.endPage() | |
27 | printer.newPage() | |
28 | end | |
29 | printer.setCursorPos(1,counter) | |
30 | printer.write(v) | |
31 | end | |
32 | printer.endPage() | |
33 | end | |
34 | end | |
35 | end | |
36 | end | |
37 | ||
38 | function checkF() | |
39 | term.setCursorPos(1,1) | |
40 | term.clear() | |
41 | shell.run('shell') | |
42 | end | |
43 | parallel.waitForAll(printF,checkF) |