Advertisement
sneakybeakylike

Untitled

May 18th, 2024
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.90 KB | None | 0 0
  1. --program for host to receive graph and turtle position
  2. --generates graph_image.nft file and displays it on connected monitor
  3.  
  4. function draw_image(image)
  5.     monitor = peripheral.find("monitor")
  6.     if not monitor then
  7.         print("Unable to find monitor")
  8.         return false
  9.     end
  10.     term.redirect(monitor)
  11. end
  12. --look for monitor peripheral.
  13.  
  14.  
  15. --open rednet
  16. peripheral.find("modem", rednet.open)
  17. --host on protocol "MINER_GRAPH" as hostname "monitor"
  18. rednet.host("MINER_GRAPH", "monitor")
  19. while true do
  20.     local id, message, protocol = rednet.receive("MINER_GRAPH", 1)
  21.     if id then
  22.         local graph = message.graph
  23.         local x = message.x
  24.         local y = message.y
  25.         local z = message.z
  26.         local image = generate_graph_image(graph, y)
  27.     end
  28. end
  29.  
  30. --unhost on protocol "MINER_GRAPH"
  31. rednet.unhost("MINER_GRAPH")
  32. --close rednet
  33. peripheral.find("modem", rednet.close)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement