SHOW:
|
|
- or go back to the newest paste.
| 1 | print("Elven Gateway controler V1")
| |
| 2 | - | local right = "right" |
| 2 | + | print("En attente de signal")
|
| 3 | - | local left = "left" |
| 3 | + | |
| 4 | - | local top = "top" |
| 4 | + | local right = "right" -- Redstone Link (Create) |
| 5 | local left = "left" -- Sticky piston (Minecraft) | |
| 6 | local top = "top" -- item user (Cyclic) | |
| 7 | ||
| 8 | -- Configuration des messages à afficher | |
| 9 | local msg_received = "Signal reçu" | |
| 10 | local msg_stopped = "Signal stoppé" | |
| 11 | local msg_waiting = "En attente de signal" | |
| 12 | ||
| 13 | -- Initialisation | |
| 14 | local is_waiting = true | |
| 15 | rs.setOutput(left, true) | |
| 16 | ||
| 17 | -- Fonction pour envoyer une impulsion de redstone au top | |
| 18 | - | sleep(0.1) |
| 18 | + | |
| 19 | rs.setOutput(top, true) | |
| 20 | sleep(0.5) | |
| 21 | rs.setOutput(top, false) | |
| 22 | end | |
| 23 | ||
| 24 | -- Boucle principale | |
| 25 | while true do | |
| 26 | -- Attente d'un signal sur le côté droit | |
| 27 | while not rs.getInput(right) do | |
| 28 | if not is_waiting then | |
| 29 | print(msg_waiting) | |
| 30 | is_waiting = true | |
| 31 | end | |
| 32 | sleep(1) | |
| 33 | end | |
| 34 | ||
| 35 | -- Signal reçu, on active le côté gauche, envoie une impulsion au top, et arrête l'attente | |
| 36 | if is_waiting then | |
| 37 | print(msg_received) | |
| 38 | rs.setOutput(left, true) | |
| 39 | pulseTop() | |
| 40 | is_waiting = false | |
| 41 | end | |
| 42 | ||
| 43 | - | sleep(0.1) |
| 43 | + | |
| 44 | while rs.getInput(right) do | |
| 45 | sleep(0.5) | |
| 46 | end | |
| 47 | ||
| 48 | -- Signal stoppé, on désactive le côté gauche pendant 1 seconde | |
| 49 | print(msg_stopped) | |
| 50 | rs.setOutput(left, false) | |
| 51 | sleep(1) | |
| 52 | rs.setOutput(left, true) | |
| 53 | end | |
| 54 |