SHOW:
|
|
- or go back to the newest paste.
1 | rednet.open('back') | |
2 | local monitorScan = {peripheral.find('monitor')} | |
3 | local speakers = {peripheral.find('speaker')} | |
4 | local idr = 14 | |
5 | ||
6 | local monitors={} | |
7 | ||
8 | local monitorList={'6','7'} | |
9 | ||
10 | for i,v in pairs(monitorScan) do | |
11 | local isValid = false | |
12 | for ii,vv in pairs(monitorList) do | |
13 | if peripheral.getName(v)==('monitor_'..vv) then | |
14 | isValid=true | |
15 | end | |
16 | end | |
17 | if isValid then | |
18 | table.insert(monitors,v) | |
19 | end | |
20 | end | |
21 | ||
22 | for i,v in pairs(monitors) do | |
23 | v.setTextScale(0.5) | |
24 | v.setBackgroundColor(colors.black) | |
25 | v.clear() | |
26 | end | |
27 | ||
28 | function drawScreen(monitor,image) | |
29 | local oldTerm = term.redirect(monitor) | |
30 | paintutils.drawImage(image,5,4) | |
31 | term.redirect(oldTerm) | |
32 | end | |
33 | ||
34 | function playNote(speaker,details) | |
35 | speaker.playNote(details[1],details[2]) | |
36 | end | |
37 | ||
38 | while true do | |
39 | local id,data,type=rednet.receive() | |
40 | if id == idr and data and type then | |
41 | if type == '0' then | |
42 | for i,v in pairs(monitors) do | |
43 | drawScreen(v,data) | |
44 | end | |
45 | elseif type == '1' then | |
46 | for i,v in pairs(speakers) do | |
47 | playNote(v,data) | |
48 | end | |
49 | end | |
50 | end | |
51 | end |