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

Please delete

Started by xxx, 17 August 2012 - 05:02 PM
xxx #1
Posted 17 August 2012 - 07:02 PM
Please delete
Edited on 27 December 2013 - 03:44 PM
KaoS #2
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
Grim Reaper #3
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 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! :(/>/>
KaoS #4
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
xxx #5
Posted 17 August 2012 - 08:40 PM
Please delete
Edited on 27 December 2013 - 03:44 PM
Pharap #6
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:

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.
KaoS #7
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?
Cranium #8
Posted 17 August 2012 - 10:14 PM
oh so you are using it for a unloader… interesting, why not just toss all items onto the transposer for instant offload?
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).

EDIT: Ha, Pharap Ninja'd me, and I didn't see his code. His should work.
Pharap #9
Posted 17 August 2012 - 10:53 PM
oh so you are using it for a unloader… interesting, why not just toss all items onto the transposer for instant offload?
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).

EDIT: Ha, Pharap Ninja'd me, and I didn't see his code. His should work.

I hope there is a code ninja status :(/>/>
Cranium #10
Posted 17 August 2012 - 11:01 PM
I hope there is a code ninja status :(/>/>
No, but enough posts, and you get to choose your own, I think…
Pharap #11
Posted 17 August 2012 - 11:08 PM
I hope there is a code ninja status :(/>/>
No, but enough posts, and you get to choose your own, I think…

I wouldn't know what to choose.
Cranium #12
Posted 17 August 2012 - 11:11 PM
Code Monkey?
Pharap #13
Posted 17 August 2012 - 11:25 PM
Code Monkey?
Tempting. Very tempting.
xxx #14
Posted 18 August 2012 - 10:25 AM
Please delete
Edited on 27 December 2013 - 03:44 PM
Pharap #15
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;amp;gt; 1 then -- if the item count for slot 1 is more than 1
rs.setOutput(&amp;amp;quot;down&amp;amp;quot;, true)  -- send current
sleep(0.5)  -- pause
rs.setOutput(&amp;amp;quot;down&amp;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>
xxx #16
Posted 18 August 2012 - 03:13 PM
Please delete
Edited on 27 December 2013 - 03:45 PM
Cranium #17
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.
xxx #18
Posted 18 August 2012 - 03:46 PM
Please delete
Edited on 27 December 2013 - 03:45 PM
Pharap #19
Posted 18 August 2012 - 04:45 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.

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.
xxx #20
Posted 18 August 2012 - 05:19 PM
Please delete
Edited on 27 December 2013 - 03:45 PM
sjele #21
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 one
REplace line 2 with what i wrote.
xxx #22
Posted 18 August 2012 - 07:15 PM
Thank you all! It finally works!