Guest User

Movie

a guest
Oct 28th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. _G["mov"] = {}
  2.  
  3. function mov.draw(image,x,y,mon1,mon2)
  4.   local mon1 = tostring(mon1)
  5.   local mon2 = tostring(mon2)
  6.   if peripheral.isPresent(mon1) ~= true or peripheral.isPresent(mon2) ~= true then
  7.     error("Peripheral is not on network")
  8.   elseif peripheral.getType(mon1) ~= "monitor" or peripheral.getType(mon2) ~= "monitor" then
  9.     error("Peripheral is not a monitor")
  10.   end
  11.   local x = math.floor(tonumber(x)) or 1
  12.   local y = math.floor(tonumber(y)) or 1
  13.   local image = tostring(image)
  14.   local t1 = peripheral.wrap(mon1)
  15.   local t2 = peripheral.wrap(mon2)
  16.   local t1x, t1y = t1.getSize()
  17.   local t2x, t2y = t2.getSize()
  18.   local maX, maY = t1x + t2x, t1y + t2y
  19.   local x2 = 1 - (t1x - x)
  20.   if not t1.isColor() or not t2.isColor() then
  21.     error("Monitor is not advanced")
  22.   end
  23.   if x > maX then
  24.     error("x > max X")
  25.   elseif y > maY then
  26.     error("y > max Y")
  27.   end
  28.   if not term.restore then
  29.     restore = term.current()
  30.   end
  31.  
  32.   term.redirect(t1)
  33.   paintutils.drawImage(paintutils.loadImage(image),x,y)
  34.   term.redirect(restore)
  35.   term.redirect(t2)
  36.   paintutils.drawImage(paintutils.loadImage(image),x2,y)
  37.   term.redirect(restore)
  38.  
  39. end
Add Comment
Please, Sign In to add comment