This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Please delete
Started by xxx, 17 August 2012 - 05:02 PMPosted 17 August 2012 - 07:02 PM
Please delete
Edited on 27 December 2013 - 03:44 PM
Posted 17 August 2012 - 07:08 PM
while true do
if turtle.getItemCount(1)~=1 then
rs.setOutput("bottom",true)
else
rs.setOutput("bottom",false)
end
sleep(0.25)
end
Posted 17 August 2012 - 07:13 PM
If you look around the wiki you should be able to put the code together on your own, but here is mine:
If you have any questions, feel free to PM me.
Hope I helped! :(/>/>
if turtle.getItemCount( 1 ) > 1 then -- If the item count in slot 1 is > 1.
repeat
rs.setOutput( "bottom", true ); -- Set a redstone signal.
sleep( 0.1 ); -- Keep the loop from running to fast.
until turtle.getItemCount( 1 ) <= 1 -- Loop until the count is <= 1;
else
rs.setOutput( "bottom", false );
end
If you have any questions, feel free to PM me.
Hope I helped! :(/>/>
Posted 17 August 2012 - 07:20 PM
after setting the output to true once that code would stop looping, not sure if that's what OP is looking for
EDIT: sorry only after one full cycle (being one and then changing) would it stop
EDIT: sorry only after one full cycle (being one and then changing) would it stop
Posted 17 August 2012 - 08:40 PM
Please delete
Edited on 27 December 2013 - 03:44 PM
Posted 17 August 2012 - 10:05 PM
No, I know why it's not working. Transposers need an alternating flow of redstone current, a full time current won't work.
Try this:
Bear in mind this will only work for slot 1 and to terminate it you must hold Ctrl+T.
Try this:
while true do
if turtle.getItemCount(1) > 1 then -- if the item count for slot 1 is more than 1
rs.setOutput("down", true) -- send current
sleep(0.5) -- pause
rs.setOutput("down", false) -- stop current
end -- end condition
sleep(0.5) -- pause that occurs unconditionally to avoid an error
end
Bear in mind this will only work for slot 1 and to terminate it you must hold Ctrl+T.
Posted 17 August 2012 - 10:08 PM
oh so you are using it for a unloader… interesting, why not just toss all items onto the transposer for instant offload?
Posted 17 August 2012 - 10:14 PM
He wants all items except one to be unloaded. You should be able to use his code with a slight modification. Just add a sleep(.2), then a rs.setOutput("bottom",false).oh so you are using it for a unloader… interesting, why not just toss all items onto the transposer for instant offload?
EDIT: Ha, Pharap Ninja'd me, and I didn't see his code. His should work.
Posted 17 August 2012 - 10:53 PM
He wants all items except one to be unloaded. You should be able to use his code with a slight modification. Just add a sleep(.2), then a rs.setOutput("bottom",false).oh so you are using it for a unloader… interesting, why not just toss all items onto the transposer for instant offload?
EDIT: Ha, Pharap Ninja'd me, and I didn't see his code. His should work.
I hope there is a code ninja status :(/>/>
Posted 17 August 2012 - 11:01 PM
No, but enough posts, and you get to choose your own, I think…I hope there is a code ninja status :(/>/>
Posted 17 August 2012 - 11:08 PM
No, but enough posts, and you get to choose your own, I think…I hope there is a code ninja status :(/>/>
I wouldn't know what to choose.
Posted 17 August 2012 - 11:11 PM
Code Monkey?
Posted 17 August 2012 - 11:25 PM
Tempting. Very tempting.Code Monkey?
Posted 18 August 2012 - 10:25 AM
Please delete
Edited on 27 December 2013 - 03:44 PM
Posted 18 August 2012 - 11:52 AM
Sooooooo…
Which one does send out a rs signal until the count in slot 1 is 1 and then stops the loop?
You never mentioned stopping the loop before.
The edited version:
while true do
if turtle.getItemCount(1) &amp;gt; 1 then -- if the item count for slot 1 is more than 1
rs.setOutput(&amp;quot;down&amp;quot;, true) -- send current
sleep(0.5) -- pause
rs.setOutput(&amp;quot;down&amp;quot;, false) -- stop current
else
break -- exit loop
end -- end condition
sleep(0.5) -- pause that occurs unconditionally to avoid an error
end<br>
Posted 18 August 2012 - 03:13 PM
Please delete
Edited on 27 December 2013 - 03:45 PM
Posted 18 August 2012 - 03:31 PM
Looks like the forum derped a little. The fixed fixed code:
while true do
if turtle.getItemCount(1) == 1 then -- if the item count for slot 1 is more than 1
rs.setOutput("bottom", true) -- send current
sleep(0.5) -- pause
rs.setOutput("bottom", false) -- stop current
else
break -- exit loop
end -- end condition
sleep(0.5) -- pause that occurs unconditionally to avoid an error
end
That should look right.Posted 18 August 2012 - 03:46 PM
Please delete
Edited on 27 December 2013 - 03:45 PM
Posted 18 August 2012 - 04:45 PM
Looks like the forum derped a little. The fixed fixed code:That should look right.while true do if turtle.getItemCount(1) == 1 then -- if the item count for slot 1 is more than 1 rs.setOutput("bottom", true) -- send current sleep(0.5) -- pause rs.setOutput("bottom", false) -- stop current else break -- exit loop end -- end condition sleep(0.5) -- pause that occurs unconditionally to avoid an error end
I thought I'd fixed it all.
Don't know why but for some reason the forums seem to be having an issue with relapsing into bb-code/html.
I've seen it happen to someone else before me, so I'm not sure why it's happening.
Posted 18 August 2012 - 05:19 PM
Please delete
Edited on 27 December 2013 - 03:45 PM
Posted 18 August 2012 - 06:27 PM
if turtle.getItemCount(1) ~= 1 then -- if the item count for slot 1 is more than 1
That will check if the item time count is more than oneREplace line 2 with what i wrote.
Posted 18 August 2012 - 07:15 PM
Thank you all! It finally works!