DoddyLeSel

PortiqueBois

Feb 25th, 2025 (edited)
525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.59 KB | Gaming | 0 0
  1. rednet.open("right")
  2.  
  3. station = peripheral.wrap("left")
  4. relay = peripheral.wrap("redstone_relay_2")
  5.  
  6. local function gantry(gantry_bool)
  7.     relay.setOutput("back", gantry_bool)
  8. end
  9.  
  10. local function gearshift(gearshift_bool)
  11.     relay.setOutput("front", gearshift_bool)
  12. end
  13.  
  14. local function clutch(clutch_bool)
  15.     relay.setOutput("left", clutch_bool)
  16. end
  17.  
  18. local function sequenced_impulse()
  19.     relay.setOutput("right", true)
  20.     sleep(0.1)
  21.     relay.setOutput("right", false)
  22. end
  23.  
  24. local function grab()
  25.     --attrape le wagon et le remonte
  26.     clutch(true)
  27.     gantry(true)
  28.     gearshift(false)
  29.     clutch(false)
  30.     sleep(2)
  31.     gearshift(true)
  32.     sleep(2)
  33.     clutch(true)
  34. end
  35.  
  36. local function put()
  37.     --pose le wagon
  38.     clutch(true)
  39.     gantry(true)
  40.     gearshift(false)
  41.     clutch(false)
  42.     sleep(2)
  43.     rednet.send(rednet.lookup("Portique", "PortiquePulleyTurtle"), "dig", "Portique")
  44.     clutch(true)
  45. end
  46.  
  47. local function move(sens_bool)
  48.     --déplace la poulie
  49.     gantry(false)
  50.     gearshift(not sens_bool)
  51.     sequenced_impulse()
  52.     sleep(1)
  53. end
  54.  
  55. local function bois()
  56.     grab()
  57.     move(true)
  58.     move(true)
  59.     put()
  60.     move(false)
  61.     grab()
  62.     move(false)
  63.     put()
  64.     move(true)
  65.     move(true)
  66.     grab()
  67.     move(false)
  68.     put()
  69.     move(false)
  70. end
  71.    
  72. while true do  
  73.     if station.isTrainPresent() then
  74.         train_name = station.getTrainName()
  75.            
  76.         if train_name == "Bois" then
  77.             sleep(1)
  78.             station.disassemble()
  79.             bois()
  80.             station.assemble()
  81.         end
  82.     end
  83.     sleep(5)
  84. end
Advertisement
Add Comment
Please, Sign In to add comment