Advertisement
karelvysinka

mode cammera

Apr 14th, 2023
731
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.83 KB | None | 0 0
  1. -- Načtení periférií
  2. local modem = peripheral.wrap("top") -- Připojení ender modemu
  3. local camera = peripheral.wrap("back") -- Připojení kamery
  4.  
  5. -- Nastavení parametrů obrazovky
  6. local resolution_width = 160 -- Šířka obrazovky
  7. local resolution_height = 50 -- Výška obrazovky
  8.  
  9. -- Funkce pro načtení snímku obrazovky z kamery
  10. function takePicture()
  11.   local imageData = camera.snapshot()
  12.   local image = paintutils.createImage(imageData, "rgba", resolution_width, resolution_height)
  13.   return image
  14. end
  15.  
  16. -- Funkce pro odeslání obrazu přes ender modem
  17. function sendImage(image)
  18.   local serializedImage = textutils.serialize(image)
  19.   modem.transmit(1, 1, serializedImage)
  20. end
  21.  
  22. -- Hlavní smyčka programu
  23. while true do
  24.   local image = takePicture()
  25.   sendImage(image)
  26.   sleep(1) -- Čekání jednu sekundu
  27. end
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement