Jump to content




Please delete


  • You cannot reply to this topic
21 replies to this topic

#1 xxx

  • New Members
  • 28 posts

Posted 17 August 2012 - 06:02 PM

Please delete

Edited by Peter110, 27 December 2013 - 04:44 PM.


#2 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 17 August 2012 - 06: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


#3 Grim Reaper

  • Members
  • 503 posts
  • LocationSeattle, WA

Posted 17 August 2012 - 06: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! :(/>

#4 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 17 August 2012 - 06: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

#5 xxx

  • New Members
  • 28 posts

Posted 17 August 2012 - 07:40 PM

Please delete

Edited by Peter110, 27 December 2013 - 04:44 PM.


#6 Pharap

  • Members
  • 816 posts
  • LocationEngland

Posted 17 August 2012 - 09: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.

#7 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 17 August 2012 - 09:08 PM

oh so you are using it for a unloader... interesting, why not just toss all items onto the transposer for instant offload?

#8 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 17 August 2012 - 09:14 PM

View PostKaoS, on 17 August 2012 - 09:08 PM, said:

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.

#9 Pharap

  • Members
  • 816 posts
  • LocationEngland

Posted 17 August 2012 - 09:53 PM

View Postcraniumkid22, on 17 August 2012 - 09:14 PM, said:

View PostKaoS, on 17 August 2012 - 09:08 PM, said:

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 :(/>

#10 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 17 August 2012 - 10:01 PM

View PostPharap, on 17 August 2012 - 09:53 PM, said:

I hope there is a code ninja status :(/>
No, but enough posts, and you get to choose your own, I think...

#11 Pharap

  • Members
  • 816 posts
  • LocationEngland

Posted 17 August 2012 - 10:08 PM

View Postcraniumkid22, on 17 August 2012 - 10:01 PM, said:

View PostPharap, on 17 August 2012 - 09:53 PM, said:

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.

#12 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 17 August 2012 - 10:11 PM

Code Monkey?

#13 Pharap

  • Members
  • 816 posts
  • LocationEngland

Posted 17 August 2012 - 10:25 PM

View Postcraniumkid22, on 17 August 2012 - 10:11 PM, said:

Code Monkey?
Tempting. Very tempting.

#14 xxx

  • New Members
  • 28 posts

Posted 18 August 2012 - 09:25 AM

Please delete

Edited by Peter110, 27 December 2013 - 04:44 PM.


#15 Pharap

  • Members
  • 816 posts
  • LocationEngland

Posted 18 August 2012 - 10:52 AM

Quote

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>


#16 xxx

  • New Members
  • 28 posts

Posted 18 August 2012 - 02:13 PM

Please delete

Edited by Peter110, 27 December 2013 - 04:45 PM.


#17 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 18 August 2012 - 02: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.

#18 xxx

  • New Members
  • 28 posts

Posted 18 August 2012 - 02:46 PM

Please delete

Edited by Peter110, 27 December 2013 - 04:45 PM.


#19 Pharap

  • Members
  • 816 posts
  • LocationEngland

Posted 18 August 2012 - 03:45 PM

View Postcraniumkid22, on 18 August 2012 - 02:31 PM, said:

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.

#20 xxx

  • New Members
  • 28 posts

Posted 18 August 2012 - 04:19 PM

Please delete

Edited by Peter110, 27 December 2013 - 04:45 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users