Jump to content




Need Help Coding


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

#1 John Smith

  • Members
  • 11 posts

Posted 04 May 2014 - 02:44 PM

Hello I have just started using ComputerCaft and I was trying to make a coding so that my turtle can shear a sheep go to the right 2 times and when the shears break it can grab a new one however I cant seem to get it to work and I have looked at many others so I really need help. Basically here is what I need.



A coding to..

Shear a sheep and move on the the next two.

Grab a new set of shears when the old ones break.

repeat in a loop.



I hope its not to much to ask for!


Edited by John Smith, 04 May 2014 - 05:59 PM.


#2 jewelshisen

  • Members
  • 164 posts

Posted 04 May 2014 - 04:40 PM

This place is for you to get help with code you have made, not to get people to make the code for you

#3 John Smith

  • Members
  • 11 posts

Posted 04 May 2014 - 04:49 PM

I wonder why the mod accepted my thread im new and it says I need a mods approval and it seems to be approved so clearly its both I guess
and btw if you dont want to help please just dont comment.

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 04 May 2014 - 05:25 PM

A topic getting approved usually just means it isn't a spam topic. He was giving you a friendly notice that we generally don't create programs on request here. Play nice, please.

#5 John Smith

  • Members
  • 11 posts

Posted 04 May 2014 - 05:27 PM

So I'm coding a turtle for shearing a sheep and I want it to move it to move but it wont. I also want it to shear yet also it wont do that to, here is my code. Please I need help I'm a beginner and I don't entirety understand this.



while true do --never ending loop
turtle.place()
turtle.select(2)
turtle.Down()
turtle. turnRight()
turte.forward()
turtle.Down()
turtle.select(1)
turtle.suckUp()
while turtle.getItemCount(1) == 0 do - repearts this until there's an item in slot 1
turtle.select(1)
turtle.suckUp()
end
end

I have no idea what I did wrong and I have no idea what to do! Help maybe?



#6 awsmazinggenius

  • Members
  • 930 posts
  • LocationCanada

Posted 04 May 2014 - 05:29 PM

You say that you have tried; can you show that code?

Also, can you put up a screenshot/something that shows us where to get the new shears from? Also, what about dropping off the wool when the turtle gets full?

#7 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 04 May 2014 - 05:33 PM

Threads merged. Please stick to one topic for all questions about a given piece of code.

#8 John Smith

  • Members
  • 11 posts

Posted 04 May 2014 - 05:37 PM

Okay sorry

Posted Image

Posted Image

there you go images

#9 blipman17

  • Members
  • 92 posts

Posted 04 May 2014 - 06:31 PM

For what do you need help? Please use proper grammar, else it is hard for us to read. I understand if you are not English, but please try a little harder.

#10 John Smith

  • Members
  • 11 posts

Posted 04 May 2014 - 06:54 PM

I want to find out whats wrong with my code I want it to
shear the sheep and move on to the other sheeps
but it wont do any of that

#11 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 04 May 2014 - 11:15 PM

The turtle won't move without fuel.

Shearing requires the target to be sheared to be directly next to the turtle. Given that your sheep are underneath it, you probably want to be using turtle.placeDown().

To determine whether the turtle still has a pair of shears in its first slot, you could hold a wool block in eg the last (sixteenth) inventory slot, then do a check like this:

turtle.select(1)
if turtle.getItemCount(1) == 0 or turtle.compareTo(16) then
  -- Shears slot is either empty or has been filled with wool, shears are therefore broken, go get another pair.
end

Your script is still missing code to drop the wool and to move the turtle back after getting new shears, but once you've got it moving and can experiment properly you'll hopefully be ok from there. Be sure to read up on the rest of the turtle API if you haven't already.

#12 John Smith

  • Members
  • 11 posts

Posted 05 May 2014 - 03:35 AM

View PostBomb Bloke, on 04 May 2014 - 11:15 PM, said:

The turtle won't move without fuel.

Shearing requires the target to be sheared to be directly next to the turtle. Given that your sheep are underneath it, you probably want to be using turtle.placeDown().

To determine whether the turtle still has a pair of shears in its first slot, you could hold a wool block in eg the last (sixteenth) inventory slot, then do a check like this:

turtle.select(1)
if turtle.getItemCount(1) == 0 or turtle.compareTo(16) then
  -- Shears slot is either empty or has been filled with wool, shears are therefore broken, go get another pair.
end

Your script is still missing code to drop the wool and to move the turtle back after getting new shears, but once you've got it moving and can experiment properly you'll hopefully be ok from there. Be sure to read up on the rest of the turtle API if you haven't already.

I've been trying all day do you have some kind of code that might show me how I can fix mine?

#13 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 05 May 2014 - 03:50 AM

Explain how what it IS doing, and I'll see what I can do.

#14 awsmazinggenius

  • Members
  • 930 posts
  • LocationCanada

Posted 05 May 2014 - 04:30 AM

Depending on what other mods you play with and if you have power setup and of you have MFR, you may be interested in the MFR Rancher (http://ftbwiki.org/Rancher). It will do pretty much exactly what you want to do (shear sheep), among other things. Since Turtles do require fuel to function anyways, this might be a simpler option, depending on if you have power set up.

#15 blipman17

  • Members
  • 92 posts

Posted 05 May 2014 - 08:14 AM

Why are you letting your turtle go so much down? I mean, you want him to go to the left wnd right, right?

#16 John Smith

  • Members
  • 11 posts

Posted 05 May 2014 - 02:38 PM

View PostBomb Bloke, on 05 May 2014 - 03:50 AM, said:

Explain how what it IS doing, and I'll see what I can do.

its ignoring the stuff i just put in ill retry when I get back from school maybe I have a typo

#17 blipman17

  • Members
  • 92 posts

Posted 05 May 2014 - 05:34 PM

does it give an error?
if yes, then what error?
if no, what exact actions don't work?
until when does your code still work as intended?

we don't know exactly what you want, even if it seems so simple to you.

#18 Lignum

  • Members
  • 558 posts

Posted 05 May 2014 - 06:44 PM

View PostJohn Smith, on 05 May 2014 - 02:38 PM, said:

its ignoring the stuff i just put in ill retry when I get back from school maybe I have a typo
Do you mean that things like turtle.forward() don't do anything at all?
If that's the case, make sure the turtle has enough fuel (1 coal per block) or turn off fuel entirely in the config file.

Edited by Lignum, 05 May 2014 - 06:44 PM.


#19 John Smith

  • Members
  • 11 posts

Posted 06 May 2014 - 01:16 AM

things like turtle.forward

I want the following things to work as of my turtle.

-To Shear Sheep
-To Get New Shears When Old Ones Broken
-To Move On To The Next Sheep

That's all I am asking for...

#20 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 06 May 2014 - 06:29 AM

Okay, so break it down. What steps does the turtle need to take for each of those actions? You've got a good start on planning your program, but you need to invest the work in actually putting it together. We're not here to do it for you, just help you get there yourself.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users