Advertisement
Guest User

reactor

a guest
Jun 25th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.18 KB | None | 0 0
  1. local tArgs = { ... }
  2. local function printUsage()
  3.     print ( "Usages:" )
  4.     print ( "reactor <inputSide> <outputSide> <onTime> <offTime>")
  5. end
  6. if #tArgs == 4 then
  7.     local sIn = tArgs[1]
  8.     local sOut = tArgs[2]
  9.     local nOnCycle = tonumber( tArgs[3] ) or 60
  10.     local nOffCycle = tonumber( tArgs[4] ) or 20
  11.     local bTick = true
  12.     while redstone.getInput( sIn ) do
  13.         if bTick then
  14.             io.write ( "\nOn Cycle Start\n" )
  15.    io.write ( nOnCycle )
  16.             redstone.setOutput( sOut, true )
  17.             for n = 0, nOnCycle , 1 do
  18.                 if n % 5 == 0 then
  19.                     io.write ( "\n" )
  20.                     io.write ( n )
  21.                     io.write ( "/" )
  22.                     io.write ( nOnCycle )
  23.                 end
  24.                 if redstone.getInput( sIn ) == false then break end
  25.                 sleep ( 1 )
  26.             end
  27.             bTick = false
  28.         else
  29.             io.write ( "\nOff Cycle Start" )
  30.             redstone.setOutput ( sOut, false )
  31.             for n = 0, nOffCycle, 1 do
  32.                 if n % 5 == 0 then
  33.                     io.write ( "\n" )
  34.                     io.write ( n )
  35.                     io.write ( "/" )
  36.                     io.write ( nOffCycle )
  37.                 end
  38.                 if redstone.getInput( sIn ) == false then break end
  39.                 sleep ( 1 )
  40.             end
  41.             bTick = true
  42.         end
  43.     end
  44.     io.write ( "\nNo redstone input from " )
  45.     io.write ( sIn )
  46.     io.write ( " side." )
  47. else
  48.     printUsage()
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement