Guest User

finddev

a guest
Sep 12th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.86 KB | None | 0 0
  1. -- Inventory and Peripheral Program
  2. -- For use with computercraft and OpenPeripherals, to display Inventory information on both items and
  3. -- fluids.
  4. -- Programmed By Linrox
  5. -- Requirements: 1x Advanced Computer (GOLD) and 40x Advanced Monitors (5 heigh x 8 wide)
  6.  
  7.  
  8. -- SETUP VARIABLES
  9. local w, s, tp, ID, txt, timeout,modSd,monSd,bc
  10. local MyID, MyName, wm, hm, DevName
  11. monFound=False
  12. -- Table Variables
  13. term.clear()
  14. term.setCursorPos(1,1)
  15.  
  16. --TABLES
  17. local DeviceNames={}
  18.  
  19.  
  20.  
  21. function ComputerInfo()
  22. MyID= (os.getComputerID())
  23. MyName=(os.getComputerLabel())
  24. end
  25.  
  26. ComputerInfo()
  27.  
  28. function MonitorInfo()
  29. if monFound==false then print("Monitor not found")
  30. DevAsk()
  31. else wm, hm = monitor.getSize()
  32. end
  33. end
  34.  
  35.  
  36. function checkExtra(DevName,currD)
  37. UDevType=peripheral.getType(DevName)
  38. if UDevType=="monitor" then
  39. mon=peripheral.wrap(DevName)
  40. if peripheral.isPresent(DevName) then
  41. print("Remote "..DevName.." Found ",currD)
  42. print("Give a user friendly name to use for "..DevName)
  43. newDevName=io.read()
  44. DeviceNames[tonumber(currD)]=tostring(newDevName)
  45. for k,v in pairs(DeviceNames) do
  46. if tostring(v)==newDevName then
  47. print(tostring(v).." has been added, using key "..k)
  48. end
  49. end
  50. mfsu=peripheral.wrap(DevName)
  51. print(newDevName.." Assigned")
  52. end
  53. end
  54. if UDevType=="mfsu" then
  55. if peripheral.isPresent(DevName) then
  56. print("Remote "..DevName.." Found")
  57. print("Give a user friendly name to use for "..DevName)
  58. newDevName=io.read()
  59. DeviceNames[tonumber(currD)]=tostring(newDevName)
  60. for k,v in pairs(DeviceNames) do
  61. if tostring(v)==newDevName then
  62. print(tostring(v).." has been added, using key "..k)
  63. end
  64. end
  65. print(newDevName,DevName)
  66. newDevName=peripheral.wrap(DevName)
  67. print(newDevName.." Assigned")
  68. end
  69. end
  70. if UDevType=="net_minecraft_src_buildcraft_factory_tiletank_0" then
  71. if peripheral.isPresent(DevName) then
  72. bctank=peripheral.wrap(DevName)
  73. print("Remote "..DevName.." Found")
  74. print("Give a user friendly name to use for "..DevName)
  75. newDevName=io.read()
  76. DeviceNames[tonumber(currD)]=tostring(newDevName)
  77. for k,v in pairs(DeviceNames) do
  78. if tostring(v)==newDevName then
  79. print(tostring(v).." has been added, using key "..k)
  80. end
  81. end
  82. newDevName=peripheral.wrap(DevName)
  83. print(newDevName.." Assigned")
  84. end
  85. end
  86. if UDevType=="rcirontankvalvetile" then
  87. if peripheral.isPresent(DevName) then
  88. irontank=peripheral.wrap(DevName)
  89. print("Remote "..DevName.." Found")
  90. print("Give a user friendly name to use for "..DevName)
  91. newDevName=io.read()
  92. DeviceNames[tonumber(currD)]=tostring(newDevName)
  93. for k,v in pairs(DeviceNames) do
  94. if tostring(v)==newDevName then
  95. print(tostring(v).." has been added, using key "..k)
  96. end
  97. end
  98. mfsu=peripheral.wrap(DevName)
  99. print(newDevName.." Assigned")
  100. end
  101. end
  102. if UDevType=="cofh_thermalexpansion_energycell" then
  103. if peripheral.isPresent(DevName) then
  104. cell=peripheral.wrap(DevName)
  105. print("Remote "..DevName.." Found")
  106. print("Give a user friendly name to use for "..DevName)
  107. newDevName=io.read()
  108. DeviceNames[tonumber(currD)]=tostring(newDevName)
  109. for k,v in pairs(DeviceNames) do
  110. if tostring(v)==newDevName then
  111. print(tostring(v).." has been added, using key "..k)
  112. end
  113. end
  114. mfsu=peripheral.wrap(DevName)
  115. print(newDevName.." Assigned")
  116. end
  117. end
  118. if UDevType=="appeng_me_tileterminal" then
  119. if peripheral.isPresent(DevName) then
  120. meterminal=peripheral.wrap(DevName)
  121. print("Remote "..DevName.." Found")
  122. print("Give a user friendly name to use for "..DevName)
  123. newDevName=io.read()
  124. DeviceNames[tonumber(currD)]=tostring(newDevName)
  125. for k,v in pairs(DeviceNames) do
  126. if tostring(v)==newDevName then
  127. print(tostring(v).." has been added, using key "..k)
  128. end
  129. end
  130. newDevName=peripheral.wrap(DevName)
  131. print(newDevName.." Assigned")
  132. end
  133. end
  134. end
  135.  
  136. function getDevName()
  137. print("How many devices?")
  138. local Devs=io.read()
  139. for currD=1,Devs do
  140. print("What is the Name of the device?")
  141. DevName=io.read()
  142. checkExtra(DevName,currD)
  143. end
  144. end
  145.  
  146. function DevAsk()
  147. print("Is there another device? Y/N")
  148. Answer=io.read()
  149. if Answer=="Y" or Answer=="y" then getDevName()
  150. else print("ok")
  151. end
  152. end
  153.  
  154. function findDev()
  155. print("ID: "..MyID.." Name: "..MyName)
  156. print("____________________________")
  157. for w = 1 , 5, 1 do --CHANGE THE 4 BACK TO 5
  158. if (w==1) then s="left" end
  159. if (w==2) then s="right" end
  160. if (w==3) then s="top" end
  161. if (w==4) then s="back" end
  162. if (w==5) then s="bottom" end
  163. ps=peripheral.isPresent(s)
  164. if (ps== true) then
  165. tp=peripheral.getType(s)
  166. --print("True found - w: ",w," s: ",s," tp: ",tp )
  167. if (tp=="modem") then
  168. Comms= peripheral.wrap(s)
  169. --[[for i,v in ipairs(peripheral.getMethods(s)) do
  170. print(i..". "..v) ]]--
  171. if Comms.isWireless() == true then
  172. print("Wireless Modem Found - Side: ",s)
  173. Wireless=peripheral.wrap(s)
  174. modSd=s
  175. else
  176. print("Modem Found - Side: ",s)
  177. Wired=peripheral.wrap(s)
  178. modSd=s
  179. end
  180. --end
  181. -- print("Device: "..tp)
  182. -- for i,v in ipairs(peripheral.getMethods(modSd)) do
  183. -- print(i..". "..v)
  184. -- end
  185. end
  186. if (tp=="monitor") then
  187. if monFound==false then print("Monitor not found")
  188. DevAsk()
  189. --[[for i,v in ipairs(peripheral.getMethods(s)) do
  190. --print(i..". "..v)]]--
  191. monitor= peripheral.wrap(s)
  192. print("Monitor Found - Side: ",s )
  193. local monSd=s
  194. monFound=True
  195. --MonitorInfo()
  196. print("Monitor Height:"..hm.." Width:"..wm)
  197. end
  198. end
  199. --if w=="4" then
  200. --local BackProxy=tp
  201. --bproxy=peripheral.wrap(modSd)
  202. -- if BackProxy=="container_chest" then
  203. -- for i,v in ipairs(bproxy) do
  204. -- print(i..". "..v)
  205. --end
  206. --print(tp.." is Found on the "..s)
  207.  
  208. --end
  209.  
  210. end
  211. end
  212. end
  213.  
  214. findDev()
  215. DevAsk()
Advertisement
Add Comment
Please, Sign In to add comment