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

Botania/ComputerCraft Automation

Started by MihaMi, 04 April 2015 - 07:33 PM
MihaMi #1
Posted 04 April 2015 - 09:33 PM
I want to get the code for automating this. I have a Item Dropper which has 1 of Mana Pearl, Mana Diamond and Manasteel Ingot, which makes Terrasteel. I have set up a system and I want code like this: When i receive a redstone with high signal from behind, Emit 3 quick pulses for each of items.

I would appreciate some help. :D/>

So, I know the most basic stuff from CC, but I am not the best coder in the world.
Lyqyd #2
Posted 04 April 2015 - 09:45 PM
Please post the code you have written so far and explain what you're having issues with.
MihaMi #3
Posted 05 April 2015 - 12:39 PM
I haven't got the code yet, I was asking for someone to explain how to make a pulser, when redstone signal of 15 comes to the computer. I know, this might be simple but i spent all night to figure out how to do it, still no progress.
agowa338 #4
Posted 07 April 2015 - 12:37 AM
Look here Redstone API.
You can use "redstone.getAnalogInput(15)" for looking at the input and probably "redstone.setOutput(string side, boolean value)" for setting your output.
But I have to admit, that I don't really understand what you exactly mean by "make a pulser".
KingofGamesYami #5
Posted 07 April 2015 - 02:08 AM
He wants something that'll 'pulse' redstone, similar to a redstone clock.

That's pretty simple, do something like this:


for i = 1, 3 do --#pulse 3 times
  rs.setOutput( "left", true ) --#turn on redstone to the left
  sleep( 0.05 ) --#wait 1 block update
  rs.setOutput( "left", false ) --#turn off redstone to the left
end

Also, redstone.getAnalogInput( 15 ) would not work, it requires a side, not a strength


if rs.getAnalogInput( "right" ) == 15 then --#if the input on the right is level 15
  --#do something
end
Edited on 07 April 2015 - 11:16 PM
MihaMi #6
Posted 07 April 2015 - 01:29 PM
@KingOfGamesYami That will do, but does that pulse out 3 times, when it receives redstone signal?
@agowa338 When does the computer receive a redstone signal, he pulses 3 times, basically.
agowa338 #7
Posted 08 April 2015 - 12:50 AM
I'll give you a short summary, what you could do to accomplish your goal.

1. Create an endless loop

while true do

  sleep(1)
end

2. Check if the computer receives a redstone signal of strength 15 on the right side

if rs.getAnalogInput( "right" ) == 15 then

end

Now when the computer receives the signal it jumps into this if block, so you have to put that what should happen in here
3. Set redstone output to true and after one block update to false for one pulse

rs.setOutput( "left", true )
sleep( 0.05 )
rs.setOutput( "left", false )

4. And because you want 3 pulses you have to put a count-controlled loop around it (that counts from 1 to 3)

for i = 1, 3 do


end
MihaMi #8
Posted 13 April 2015 - 03:01 PM
Okay, wrote it, tested and it has one problem, it doesn't pulse out.
Here is the code: http://pastebin.com/hGbcQS9S
Don't know what is the problem.
Previously, I had a problem "too long without yielding".
Edited on 13 April 2015 - 01:49 PM
Cing #9
Posted 13 April 2015 - 06:18 PM
I don't get why it say "too long without yielding" because you have a 'sleep in your program.
But the pulser probably doesn't work because the redstone signal is to low try to put it on 14 not 15.

EDIT: I have tested it and what i said above isn't correct
but "rs.getAnalogInput("left")" means that the computer checks your left when you'r facing the computer not the left of the computer it self.
Edited on 13 April 2015 - 04:36 PM
KingofGamesYami #10
Posted 13 April 2015 - 06:25 PM
Did you give it a redstone current of the power 15 to the left side for at least 1 second? Because that sleep(1) might be active when you applied the current.