KaychenHH

StargateDialing

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