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

Advanced Pulser?

Started by PatrikF1, 12 March 2016 - 09:54 AM
PatrikF1 #1
Posted 12 March 2016 - 10:54 AM
Is there a way to make a program that pulses a redstone signal but asks how many times it should pulse before and then pulses the amount of times. Im planning to use this with redpower transposers so i can specify the amount i want of a certain item.
Bomb Bloke #2
Posted 12 March 2016 - 12:57 PM
Yes.

http://www.computercraft.info/wiki/Read
http://www.computercraft.info/wiki/Redstone.setOutput
http://www.computercraft.info/wiki/Os.sleep
PatrikF1 #3
Posted 12 March 2016 - 01:58 PM

I have this already

print("How many:")

redstone.setBundledOutput("back", colors.blue)
sleep(1)
redstone.setBundledOutput("back", colors.blue)
os.reboot()

Its how i should repeat the pulse and i used bundled cable instead of redstone just so i could have different items on the same computer.
I have renamed multible programs to a ingot name and changed the bundled cable output color on the programs so its semi working
Edited on 12 March 2016 - 01:07 PM
Creator #4
Posted 12 March 2016 - 03:46 PM
If you want it to pulse a specific amount of times, better use a for loop:


for i=1, times do
  --pulse code
end

If you want it to run for infinity, use a while true do loop:


while true do
  -- pulse code
end
PatrikF1 #5
Posted 12 March 2016 - 03:59 PM
If you want it to pulse a specific amount of times, better use a for loop:


for i=1, times do
  --pulse code
end

If you want it to run for infinity, use a while true do loop:


while true do
  -- pulse code
end

I did this

print("How many:")
for i=read(), times do
redstone.setBundledOutput("back", colors.red)
sleep(1)
redstone.setBundledOutput("back", colors.red)
end
os.reboot()

but get this error
Creator #6
Posted 12 March 2016 - 04:14 PM
You change the times variable:


print("Times: ")
for i=1, tonumber(read()) do -- both i and times have to be numbers.
end