Advertisement
VaMinion

mekanism_dialler

Aug 28th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. mekModem = peripheral.wrap("bottom")
  2. teleName = "null"
  3. gateDuration = 5
  4.  
  5. function setAddress(teleValue)
  6.  teleValue = string.lower(teleValue)
  7.  if teleValue == "haxley" then setTele(1, 0, 0, 0)
  8.  elseif teleValue == "shantara" then setTele(1, 0, 0, 1)
  9.  elseif teleValue == "barge" then setTele(1, 0, 0, 2)
  10.  end
  11. end
  12.  
  13. function gateFinder()
  14.  t = mekModem.getNamesRemote()
  15.  for i=1, #t do
  16.   if string.find(t[i], "Teleporter") then teleName = t[i] end
  17.  end
  18. end
  19.  
  20. function setTele(num0, num1, num2, num3)
  21.  mekModem.callRemote(teleName, "set", 0, num0)
  22.  mekModem.callRemote(teleName, "set", 1, num1)
  23.  mekModem.callRemote(teleName, "set", 2, num2)
  24.  mekModem.callRemote(teleName, "set", 3, num3)
  25. end
  26.  
  27. function main()
  28.  gateFinder()
  29.  shell.run("clear")
  30.  print("Welcome to Dormagic Dialling! Please choose:")
  31.  print("Barge Haxley Shantara")
  32.  print("\nEnter Destination (Q to quit):")
  33.  
  34.  -- Get the choice from the user.
  35.  local userDest = io.read()
  36.  
  37.  -- Set the teleporter value for going out.
  38.  shell.run("clear")
  39.  print("Connecting to ", userDest, "! Portal will remain for 60 seconds!")
  40.  setAddress(userDest)
  41.  -- Timer that displays how long the gate will remain open.
  42.  for i=0,gateDuration do
  43.   shell.run("clear")
  44.   print("Gate to ", userDest, " closes in ", gateDuration-i, " seconds.")
  45.   os.sleep(1)
  46.  end
  47.  print("Resetting to default value")
  48.  setAddress(os.getComputerLabel())
  49.  os.sleep(2)
  50.  shell.run("clear")
  51. end
  52.  
  53. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement