DraRex368

Stargate Dialing CC:Tweaked 1.19.2

Sep 3rd, 2024 (edited)
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.36 KB | None | 0 0
  1. --This code should work with the currently most recent version as of writing this (v0.6.17)
  2. interface = peripheral.find("basic_interface")
  3. --This finds some interface connected to the
  4. --computer network, but since that one is the only
  5. --one connected, it will always be that one near the gate
  6.  
  7. function dial(address)
  8. --Milky Way Stargate is a special case when it comes
  9. --to dialing
  10.    
  11.     local addressLength = #address
  12.     --You don't really need to have this variable,
  13.     --I just like to use lots of variables with
  14.     --names to make everything immediately clear
  15.    
  16.     local start = interface.getChevronsEngaged() + 1
  17.     --This is a helpful variable we'll be using to
  18.     --make resuming dialing easier.
  19.     --Basically what this does is it makes the computer
  20.     --check how many chevrons are engaged and start from
  21.     --the next one (that's why there's a +1)
  22.    
  23.     for chevron = start,addressLength,1
  24.     do
  25.         --This is a loop that will go through all the
  26.         --symbols in an address
  27.        
  28.         local symbol = address[chevron]
  29.        
  30.         if chevron % 2 == 0 then
  31.             interface.rotateClockwise(symbol)
  32.         else
  33.             interface.rotateAntiClockwise(symbol)
  34.         end
  35.         --Here we're basically making sure the gate ring
  36.         --rotates clockwise when the number of chevrons
  37.         --engaged is even and counter-clockwise when odd
  38.        
  39.         while(not interface.isCurrentSymbol(symbol))
  40.         do
  41.             sleep(0)
  42.         end
  43.         --This effectively ensures the program doesn't
  44.         --do anything else and lets the dialing finish
  45.         --rotating to the correct symbol
  46.        
  47.         sleep(1)
  48.         --We want to wait 1 second before we
  49.         --engage the chevron
  50.         interface.openChevron() --This opens the chevron
  51.         sleep(1)
  52.         interface.closeChevron() -- and this closes it
  53.         sleep(1)
  54.        
  55.         --Note that from many of the functions here,
  56.         --you can get Stargate Feedback
  57.        
  58.         --For example, the raiseChevron() function will output
  59.         --a number corresponding to some feedback value which you'll
  60.         --be able to find in the video description
  61.        
  62.     end
  63. end
  64.  
  65. --Now that we've got a function, this is how we'll run it
  66.  
  67. --But first we want some addresses
  68.  
  69. abydosAddress = {26,6,14,31,11,29,0}
  70. --Do note that the Point of Origin (number 0)
  71. --is considered a part of the address
  72. --and if you forget it, the dialing sequence
  73. --will not finish
  74. chulakAddress = {8,1,22,14,36,19,0}
  75.  
  76. lanteaAddress = {18,20,1,15,14,7,19}
  77.  
  78. --Now let's write the actual part of the program
  79. --that will start the dialing
  80.  
  81. print("Avaiting input:")
  82.  
  83. print("1 = Abydos")
  84. print("2 = Chulak")
  85. print("3 = Lantea")
  86. --These only tell the computer to write these
  87. --strings of words when we run this program
  88.  
  89. input = tonumber(io.read())
  90. sleep(0)
  91. --Here we're basically getting the number written
  92. --by the player on the console
  93.  
  94. if input == 1 then
  95.     dial(abydosAddress) --We're using the function we wrote earlier
  96. elseif input == 2 then
  97.     dial(chulakAddress)
  98. elseif input == 3 then
  99.     dial(lanteaAddress)
  100. else
  101.     print("Invalid input")
  102. end
  103.  
  104. --If you want to add more addresses, just
  105. --add them to other addresses and extend this block
  106.  
  107. --You can do a bunch of other stuff with all this,
  108. --but let's test it out now
  109.  
Add Comment
Please, Sign In to add comment