Vodka51200

list Peripheral connected

Apr 14th, 2021 (edited)
817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.58 KB | None | 0 0
  1. local mon = peripheral.find("monitor")
  2. local mod = peripheral.find("modem")
  3.  
  4. --term.blit("Hello, world!","01234456789ab","0000000000000")
  5.  
  6. term.redirect(mon)
  7. --mon.setTextColor(colors.white)
  8. mod.open(0)
  9. mon.setTextColor(colors.black)
  10. mon.setBackgroundColor( colors.black )
  11. mon.clear()
  12. mon.setCursorPos(1,24)
  13. mon.setTextScale(0.5)
  14. mon.setBackgroundColor( colors.cyan )
  15. mon.clearLine()
  16.  
  17. local function centerTextX(text)
  18.     local w,h = term.getSize()
  19.     term.setCursorPos(math.floor(w/2-text:len()/2+.5), 24)
  20.     io.write(text)
  21. end
  22.  
  23. local function centerTextBy(text)
  24.     local w,h = term.getSize()
  25.     term.setCursorPos(math.floor(w/2-text:len()/2+.5), h)
  26.     io.write(text)
  27. end
  28.  
  29. centerTextX("computer ID: "..os.getComputerID().."\n")
  30.  
  31. --print(modem.isOpen(0))
  32.  
  33. -- for k,v in pairs(modem) do
  34.     -- monitor.setTextColor(colors.yellow)
  35.     -- print(k,v)
  36. -- end
  37.  
  38. -- for k,v in pairs(r) do
  39.     -- print(k,v)
  40. -- end
  41. --for k,v in pairs(r.tags) do
  42. --    print(k,v)
  43. --end
  44. --for k,v in pairs(r.state) do
  45. --    print(k,v)
  46. --end
  47.  
  48. local w,h = term.getSize()
  49. mon.setTextColor(colors.gray)
  50. write ("\ntaille du monitor: ")
  51. mon.setTextColor(colors.yellow)
  52. print ("L x".. w .." : H x".. h)
  53. mon.setTextColor(colors.orange)
  54. print("modem ouvert")
  55. local blocks = {
  56.   ["minecraft:ancient_debris"] = { colour = colours.brown, name = "ancien debris" },
  57.   ["allthemodium:vibranium_ore"] = { colour = colors.green, name = "vibranium" },
  58.   ["tconstruct:cobalt_ore"] = { colour = colors.blue, name = "cobalt" },
  59.   ["allthemodium:allthemodium_ore"] = { colour = colors.orange, name = "allthemodium" },
  60.   ["allthemodium:unobtainium_ore"] = { colour = colors.purple, name = "unobtainium" },
  61. }
  62.  
  63. local function inspect()
  64.   local _,r = turtle.inspect()
  65.   mon.setTextColor(colors.white)
  66.   print("j'inspect le block")
  67.   sleep(2)
  68.   if r and blocks[r.name] then
  69.     mon.setTextColour(blocks[r.name].colour)
  70.     print("> " .. blocks[r.name].name)
  71.   else
  72.     mon.setTextColor(colors.red)
  73.     print("pas de block")
  74.   end
  75. end
  76. -- function inspect()
  77.     -- local _,r = turtle.inspect()
  78.     -- print("j'inspect le block")
  79.     -- sleep(2)
  80.     -- if r.name == "minecraft:ancient_debris" then
  81.         -- mon.setTextColor(colors.brown)
  82.         -- print("> ".. "ancien debris")
  83.     -- elseif r.name == "allthemodium:vibranium_ore" then
  84.         -- mon.setTextColor(colors.green)
  85.         -- print("> ".. "vibranium")
  86.     -- elseif r.name == "tconstruct:cobalt_ore" then
  87.         -- mon.setTextColor(colors.blue)
  88.         -- print("> ".. "cobalt")
  89.     -- elseif r.name == "allthemodium:allthemodium_ore" then
  90.         -- mon.setTextColor(colors.orange)
  91.         -- print("> ".. "allthemodium")
  92.     -- elseif r.name == "allthemodium:unobtainium_ore" then
  93.         -- mon.setTextColor(colors.purple)
  94.         -- print("> ".. "unobtainium")
  95.     -- else
  96.         -- mon.setTextColor(colors.red)
  97.         -- print("pas de block")
  98.     -- end
  99.     -- mon.setTextColor(colors.white)
  100. -- end
  101.  
  102. local premierSlot = 1
  103. local dernierSlot = 16
  104.  
  105. function scan()
  106. local items ={}
  107.     for i = premierSlot,dernierSlot do
  108. local data = turtle.getItemDetail(i)
  109.         if data then
  110.             items[i]={name=data.name,count=data.count}
  111.             --print(data.name .. " x" .. data.count) -- pour verifier les noms
  112.             if data.name == "allthemodium:allthemodium_ore" then
  113.             name1 = "allthemodium x" .. data.count
  114.             elseif data.name == "allthemodium:vibranium_ore" then
  115.             name2 = "vibranium x" .. data.count
  116.             elseif data.name == "allthemodium:unobtainium_ore" then
  117.             name3 = "unobtainium x" .. data.count
  118.             elseif data.name == "minecraft:ancient_debris" then
  119.             name4 = "ancient debris x" .. data.count
  120.             elseif data.name == "tconstruct:cobalt_ore" then
  121.             name5 = "cobalt x" .. data.count
  122.             end
  123.         end
  124.     end
  125. end
  126.  
  127. mon.setCursorPos(1,24)
  128. mon.setBackgroundColor( colors.black )
  129. mon.setTextColor(colors.yellow)
  130. mon.clearLine()
  131. print("--------------------")
  132. for i = 1, 4 do
  133. inspect()
  134. turtle.turnRight()
  135. end
  136. sleep(1)
  137. mon.setTextColor(colors.yellow)
  138. mon.setBackgroundColor( colors.gray )
  139. mon.clearLine()
  140. print("--------------------")
  141. mon.setTextColor(colors.lime)
  142. --print("")
  143. print("Dans mon inventaire j'ai :")
  144. mon.setTextColor(colors.white)
  145. -- mon.setBackgroundColor( colors.gray )
  146. -- mon.clearLine()
  147. scan()
  148. print(name1)
  149. print(name2)
  150. print(name3)
  151. print(name4)
  152. print(name5)
  153. mon.setTextColor(colors.yellow)
  154. -- mon.setBackgroundColor( colors.black )
  155. -- mon.clearLine()
  156. --print("")
  157. print("--------------------")
  158. mon.setBackgroundColor( colors.cyan )
  159. mon.clearLine()
  160. mod.close(0)
  161. mon.setTextColor(colors.orange)
  162. print("modem fermer")
  163. --mon.setTextColor(colors.white)
  164. ---print(modem.isOpen(0))
  165. print("")
  166. mon.setTextColor(colors.black)
  167. centerTextBy("By Vodka")
Add Comment
Please, Sign In to add comment