Advertisement
Manifusion

MoseOS

Mar 1st, 2013
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.94 KB | None | 0 0
  1. -- Call Functions
  2. function Init_Addons()
  3. -- Global Variables
  4. hasMODEM = false
  5. hasMONITOR = false
  6. hasPRINTER = false
  7.  
  8. -- Checkside: Variables
  9. local addonTOP = peripheral.getType("top")
  10. local addonBOTTOM = peripheral.getType("bottom")
  11. local addonLEFT = peripheral.getType("left")
  12. local addonRIGHT = peripheral.getType("right")
  13. local addonFRONT = peripheral.getType("front")
  14. local addonBACK = peripheral.getType("back")
  15.  
  16. -- Peripheral Initializers
  17. local peripheralMODEM = nil
  18. local peripheralMONITOR = nil
  19. local peripheralPRINTER = nil
  20. -- Other Types of Peripherals:
  21. -- computer
  22. -- turtle
  23. -- drive
  24.  
  25. -- if "Top" Slot is Occupied
  26.     if peripheral.isPresent("top") then
  27.         -- Check Top for Modem
  28.         if addonTOP == "modem" then
  29.             peripheralMODEM = "top"
  30.             hasMODEM = true
  31.             print("Modem detected on Node: " ..peripheralMODEM)
  32.         end
  33.  
  34.         -- Check Top for Monitor
  35.         if addonTOP == "monitor" then
  36.             peripheralMONITOR = "top"
  37.             hasMONITOR = true
  38.             print("Monitor detected on Node: " ..peripheralMONITOR)
  39.         end
  40.        
  41.         -- Check Top for Printer
  42.         if addonTOP == "printer" then
  43.             peripheralPRINTER = "top"
  44.             hasPRINTER = true
  45.             print("Printer detected on Node: " ..peripheralPRINTER)
  46.         end
  47.     end
  48.  
  49.     -- if "Bottom" Slot is Occupied
  50.     if peripheral.isPresent("bottom") then
  51.         -- Check Bottom for Modem
  52.         if addonBOTTOM == "modem" then
  53.             peripheralMODEM = "bottom"
  54.             hasMODEM = true
  55.             print("Modem detected on Node: " ..peripheralMODEM)
  56.         end
  57.  
  58.         -- Check Bottom for Monitor
  59.         if addonBOTTOM == "monitor" then
  60.             peripheralMONITOR = "bottom"
  61.             hasMONITOR = true
  62.             print("Monitor detected on Node: " ..peripheralMONITOR)
  63.         end
  64.        
  65.         -- Check Bottom for Printer
  66.         if addonBOTTOM == "printer" then
  67.             peripheralPRINTER = "bottom"
  68.             hasPRINTER = true
  69.             print("Printer detected on Node: " ..peripheralPRINTER)
  70.         end
  71.     end
  72.    
  73.     -- if "Left" Slot is Occupied
  74.     if peripheral.isPresent("left") then
  75.         -- Check Left for Modem
  76.         if addonLEFT == "modem" then
  77.             peripheralMODEM = "left"
  78.             hasMODEM = true
  79.             print("Modem detected on Node: " ..peripheralMODEM)
  80.         end
  81.  
  82.         -- Check Left for Monitor
  83.         if addonLEFT == "monitor" then
  84.             peripheralMONITOR = "left"
  85.             hasMONITOR = true
  86.             print("Monitor detected on Node: " ..peripheralMONITOR)
  87.         end
  88.        
  89.         -- Check Left for Printer
  90.         if addonLEFT == "printer" then
  91.             peripheralPRINTER = "left"
  92.             hasPRINTER = true
  93.             print("Printer detected on Node: " ..peripheralPRINTER)
  94.         end
  95.     end
  96.  
  97.     -- if "Right" Slot is Occupied
  98.     if peripheral.isPresent("right") then
  99.         -- Check Right for Modem
  100.         if addonRIGHT == "modem" then
  101.             peripheralMODEM = "right"
  102.             hasMODEM = true
  103.             print("Modem detected on Node: " ..peripheralMODEM)
  104.         end
  105.  
  106.         -- Check Right for Monitor
  107.         if addonRIGHT == "monitor" then
  108.             peripheralMONITOR = "right"
  109.             hasMONITOR = true
  110.             print("Monitor detected on Node: " ..peripheralMONITOR)
  111.         end
  112.        
  113.         -- Check Right for Printer
  114.         if addonRIGHT == "printer" then
  115.             peripheralPRINTER = "right"
  116.             hasPRINTER = true
  117.             print("Printer detected on Node: " ..peripheralPRINTER)
  118.         end
  119.     end
  120.    
  121.     -- if "Front" Slot is Occupied
  122.     if peripheral.isPresent("front") then
  123.         -- Check Front for Modem
  124.         if addonFRONT == "modem" then
  125.             peripheralMODEM = "front"
  126.             hasMODEM = true
  127.             print("Modem detected on Node: " ..peripheralMODEM)
  128.         end
  129.  
  130.         -- Check Front for Monitor
  131.         if addonFRONT == "monitor" then
  132.             peripheralMONITOR = "front"
  133.             hasMONITOR = true
  134.             print("Monitor detected on Node: " ..peripheralMONITOR)
  135.         end
  136.        
  137.         -- Check Front for Printer
  138.         if addonFRONT == "printer" then
  139.             peripheralPRINTER = "front"
  140.             hasPRINTER = true
  141.             print("Printer detected on Node: " ..peripheralPRINTER)
  142.         end
  143.     end
  144.    
  145.     -- if "Back" Slot is Occupied
  146.     if peripheral.isPresent("back") then
  147.         -- Check Back for Modem
  148.         if addonBACK == "modem" then
  149.             peripheralMODEM = "back"
  150.             hasMODEM = true
  151.             print("Modem detected on Node: " ..peripheralMODEM)
  152.         end
  153.  
  154.         -- Check Back for Monitor
  155.         if addonBACK == "monitor" then
  156.             peripheralMONITOR = "back"
  157.             hasMONITOR = true
  158.             print("Monitor detected on Node: " ..peripheralMONITOR)
  159.         end
  160.        
  161.         -- Check Back for Printer
  162.         if addonBACK == "printer" then
  163.             peripheralPRINTER = "back"
  164.             hasPRINTER = true
  165.             print("Printer detected on Node: " ..peripheralPRINTER)
  166.         end
  167.     end
  168.    
  169.     -- Initialize Hardware
  170.     if hasMODEM then
  171.         rednet.close(peripheralMODEM)
  172.         rednet.open(peripheralMODEM)
  173.     end
  174.    
  175.     if hasMONITOR then
  176.         Monitor = peripheral.wrap(peripheralMONITOR)
  177.         Monitor.clear()
  178.         Monitor.setCursorPos(1,1)
  179.         Monitor.write("MoseOS is Online.")
  180.     end
  181.    
  182.         if hasPRINTER then
  183.         Printer = peripheral.wrap(peripheralPrinter)
  184.     end
  185. -- End of Function
  186. end
  187.  
  188. function Init_Wireless_Machines()
  189.     rednet.broadcast("Initialize")
  190.     print("Connecting to Rednet.")
  191.     if hasMONITOR then
  192.         Monitor.setCursorPos(1,2)
  193.         Monitor.write("Connecting to Rednet.") 
  194.     end
  195. end
  196.  
  197. -- Runtime
  198. Init_Addons()
  199. if hasMODEM then
  200.     Init_Wireless_Machines()
  201. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement