Posted 02 June 2012 - 07:39 PM
In advance, sorry for the amateur level quality of the code. :)/>/>
To give an idea of the context for this code, what it does is sends pulses to a RedPower2 transposer which sends pork down a pipeline.
I'd just like to count the amount of pork flowing, though. I have the pork going through an "Item Detector" which sends out a pulse for each item that passes through it.
Only problem is, the counter program of mine doesn't iterate past 10! I'm racking my brain trying to figure it out!
Any help would be very much appreciated!
To give an idea of the context for this code, what it does is sends pulses to a RedPower2 transposer which sends pork down a pipeline.
I'd just like to count the amount of pork flowing, though. I have the pork going through an "Item Detector" which sends out a pulse for each item that passes through it.
Only problem is, the counter program of mine doesn't iterate past 10! I'm racking my brain trying to figure it out!
Any help would be very much appreciated!
term.clear()
term.setCursorPos(1, 1)
textutils.slowPrint("Welcome to PorkSend")
print("")
textutils.slowPrint(" Would you like to receive pork?")
write("Enter (yes/no): ")
input = read()
if input == "no" then
os.shutdown()
elseif input == "yes" then
print("")
textutils.slowPrint("How much pork?")
write("Enter: ")
input2 = read()
input2 = tonumber(input2)
textutils.slowPrint("Sending...")
i = 0
while i < input2 do
rs.setOutput("back",true)
sleep(0.3)
rs.setOutput("back", false)
sleep(0.3)
i = i+1
end
end
x = 0
while x < input2 do
event = os.pullEvent()
if event == "redstone" and rs.getInput("right") then
term.clear()
term.setCursorPos(1, 1)
x = x + 1
print("Count: " .. x)
end
if x == input2 then
textutils.slowPrint("Sending complete.")
break
end
end
sleep(3)
os.shutdown()