Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local event = require('event')
- local modem = require('component').modem
- modem.open(1)
- local image = require('image')
- local function get(address,CT)
- for c in require('component').list(CT,true) do
- if c:sub(1,address:len()) == address then
- return c
- end
- end
- end
- local mon = {}
- local raid = '/Mounts/'..get('RAID ADDRESS')..'/'
- local sr = require('serialization')
- local function pack(data)
- return sr.serializate(data)
- end
- local function unpack(data)
- return sr.unserializate(data)
- end
- while true do
- local _, _, _, _, _, e1, e2, e3 = event.pull('modem_message')
- if e1 == 'image' then
- local img = image.load(raid..e2)
- for x =1,6 do
- mon[x] = {}
- for y = 1,5 do
- mon[x][y] = {}
- end
- end
- local w = img[1]
- local h = img[2]
- for x = 1,w do
- for y = 1,h do
- local bg,fg,_,symbol = image.get(img,x,y)
- local x = x + x1 - 1
- local y = y + y1 -1
- local xx = math.ceil(x / 126)
- local yy = math.ceil(y / 63)
- local localX = x - (xx - 1) * 126
- local localY = y - (yy - 1) * 63
- table.insert(mon[xx][yy],{localX,localY,bg,fg,symbol})
- end
- end
- for x = 1,6
- for y=1,5 do
- modem.broadcast(1,x,y,'mon = '..pack(mon[x][y]))
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement