You'll probably want to use os.pullEvent()
It stops your program until something happens:
-Redstone update
-User input (like pressing a key or clicking the mouse)
These are the only ones that happen by default, but there are more when a peripheral is connected (like a monitor or modem)
So, the program
local mcPasses = 0 --#stores the number of passes
local redstoneSide = "right" --#Which side the detector rail/redstone is
while true do --#runs forever
os.pullEvent("redstone") --#calls os.pullEvent, waiting for only the 'redstone' event
if rs.getInput(redstoneSide) then --#Only increments when the signal turns on (Event also fires when it turns off)
mcPasses = mcPasses+1
end
end
That will do it. Of course, nothing will happen on screen, since the program never updates anything.
If you want, you can add a 'print(mcPasses)' after it increments, to display the number
NOTE: Usually, os.pullEvent() returns several things, but for the 'redstone' event, nothing important is returned.
NOTE 2: You did ask for a tutorial, not the program, but since it was so short, I just wrote it.
Edited by HPWebcamAble, 28 February 2015 - 05:49 PM.