Pandafuchs

Weichenkontrolle

Sep 29th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.35 KB | None | 0 0
  1. function weichenkontrolle()
  2.     local counter = 0;
  3.     local changed = false
  4.     local gleis1 = colors.orange
  5.     local gleis2 = colors.yellow
  6.     local gleis3 = colors.green
  7.     local gleis4 = colors.gray
  8.     print("Weichenkontrolle wird gestartet....")
  9.     while true do
  10.         if colors.test(redstone.getBundledInput("left"), 2048) == true then
  11.             --print("zuuuug")
  12.             if counter == 0 and colors.test(redstone.getBundledInput("right"), colors.white) then
  13.                 redstone.setBundledOutput("left", colors.orange)
  14.                 --print(counter .. " is the counter and white is green so go there")
  15.             elseif counter == 1 and colors.test(redstone.getBundledInput("right"), colors.yellow) then
  16.                 redstone.setBundledOutput("left", colors.yellow)
  17.                 --print(counter .. " is the counter and yellow is green so go there")
  18.             elseif counter == 2 and colors.test(redstone.getBundledInput("right"), colors.lime) then
  19.                 redstone.setBundledOutput("left", colors.green)
  20.                 --print(counter .. " is the counter and lime is green so go there")
  21.             elseif counter == 3 and colors.test(redstone.getBundledInput("right"), colors.pink) then
  22.                 redstone.setBundledOutput("left", colors.gray)
  23.                 --print(counter .. " is the counter and pink is green so go there")
  24.             elseif colors.test(redstone.getBundledInput("right"), colors.cyan) then
  25.                 --print(counter .. " is the counter and cyan is green so go there")
  26.                 redstone.setBundledOutput("left", 0)
  27.             else
  28.                 if colors.test(redstone.getBundledInput("right"), colors.white) then
  29.                     --print("cwhite")
  30.                     redstone.setBundledOutput("left", colors.orange)
  31.                 elseif colors.test(redstone.getBundledInput("right"), colors.yellow) then
  32.                     --print("cyellow")
  33.                     redstone.setBundledOutput("left", colors.yellow)
  34.                 elseif colors.test(redstone.getBundledInput("right"), colors.lime) then
  35.                     --print("clime")
  36.                     redstone.setBundledOutput("left", colors.green)
  37.                 elseif colors.test(redstone.getBundledInput("right"), colors.pink) then
  38.                     --print("cpink")
  39.                     redstone.setBundledOutput("left", colors.gray)
  40.                 else
  41.                     --print("cyan")
  42.                     redstone.setBundledOutput("left", 0)
  43.                 end
  44.             end
  45.             changed = true
  46.  
  47.             counter = counter + 1
  48.             if counter > 4 then            
  49.                 counter = 0
  50.             end
  51.         end
  52.         --print("kein zuuuug " .. redstone.getBundledInput("left") )
  53.         if changed then
  54.             sleep(2)
  55.             changed = false
  56.         else
  57.             sleep(0.5)
  58.         end
  59.     end
  60. end
Advertisement
Add Comment
Please, Sign In to add comment