mkmush

framemotor door

Jan 23rd, 2022 (edited)
851
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local stufe
  2. local inputSide = "top"
  3. local framemotor1 = "back"
  4. local framemotor2 = "bottom"
  5.  
  6. function bewegen(output)
  7.   stufe = 0
  8.   while (stufe < 4) do
  9.     rs.setOutput(output, true)
  10.     sleep(0.5)
  11.     rs.setOutput(output, false)
  12.     sleep(0.5)
  13.     stufe = stufe + 1
  14.   end
  15. end
  16.  
  17. function speichern(zustand)
  18.   local file = fs.open("speicher", "w")
  19.   file.write(zustand)
  20.   file.close()
  21. end
  22.  
  23. while true do
  24.   file = fs.open("speicher", "r")
  25.   inhalt = file.readLine()
  26.   file.close()
  27.  
  28.   if inhalt == "offen" and rs.getInput(inputSide) then
  29.       print("hoch gemacht")
  30.       bewegen(framemotor1)
  31.       speichern("geschlossen")
  32.  
  33.   elseif inhalt == "geschlossen" and rs.getInput(inputSide) then
  34.       print("runter gemacht")
  35.       bewegen(framemotor2)
  36.       speichern("offen")
  37.   end
  38.   sleep(0.5)
  39. end
  40.  
RAW Paste Data Copied