This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
thomsen's profile picture

Item Detecor Input To Computer

Started by thomsen, 06 October 2012 - 05:32 PM
thomsen #1
Posted 06 October 2012 - 07:32 PM
First hello everyone :D/>/> , I'm new to the forum and newbie in programming, so I need your help.
Recently I use a lot of features in computercraft and I need a program, but unfortunately I do not know how to compose it by myself.
Just as the subject it relates to item detector.
Here is my code, but it is only about to receive the input signal from detector

if os.pullEvent () == "redstone" then
redstone.testBundledInput if ("bottom", colors.black) == true then
print ("")

This program satisfy me, but I need two things:

1.Sometimes happens that there is no signal input, cause no items going through detector and the program is waiting, so I need function:
"If the signal will not be for ex. 30 sec then …."

2.It will be good if the computer gets the information about amount items go through the detector, how many signals inputed during ex. 30 sec.

Is it possible?
jag #2
Posted 06 October 2012 - 08:03 PM
Can't you do it with a while loop?
while true do
  if rs.testBundledInput("bottom", colors.black) then
    print("Black is powered!")
    -- Other code you want to execute
  else
    print("Black is NOT powered!")
    -- Other code you want to execute
  end
  sleep(.2)
end

And + I don't really understand what you mean with your description, could you define your question better?
thomsen #3
Posted 06 October 2012 - 08:30 PM
Items from chest with transpose goes to item detector and informations from detector go to computer. I need two functions:
First to get reply from item detector when items go through it or not.
And second how many items was passed.
jag #4
Posted 06 October 2012 - 08:42 PM
What is the time difference between each item? Or do you just want to store the total amount of items passed?
thomsen #5
Posted 06 October 2012 - 08:46 PM
30 seconds, yes
jag #6
Posted 06 October 2012 - 09:07 PM
Well here's a quick code I just wrote that will do as you wish.
It will even remember the current count when shut down (like when the server reboots).
Bundled cable version: GrY0MYBP
Regular redstone version: L4VuvWCr