enderpro100

sgCraft dhd program

Apr 23rd, 2021 (edited)
504
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- Program : Connect a sgcraft gate to another
  2. --- Author : LightKnight51
  3. --- Last modification : 23/04/2021
  4.  
  5.  
  6. --- Functions
  7.  
  8. local arg = { ... }
  9.  
  10. function askConnectionType()
  11.     connectionType = ""
  12.     if arg[1] ~= nil then
  13.         connectionType = arg[1]
  14.         print("Type de connexion : " .. connectionType)
  15.     else
  16.         connectionType = read()
  17.     end
  18.     return connectionType
  19. end
  20.  
  21. function askAddress()
  22.     address = ""
  23.     if arg[2] ~= nil then
  24.         address = arg[2]
  25.         print("Adresse en paramètre : " .. address)
  26.     else
  27.         address = read()
  28.     end
  29.     return address
  30. end
  31.  
  32. function mainProgram()
  33.     connectionType = askConnectionType()
  34.     sg = peripheral.find("stargate")
  35.     if connectionType == "connect" or connectionType == "con" then
  36.         address = askAddress()
  37.         sg.dial(address)
  38.     elseif connectionType == "disconnect" or connectionType == "dis" then
  39.         sg.disconnect()
  40.     end
  41. end
  42.  
  43. mainProgram()
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×