Jump to content




neeed help on this code

turtle computer command

97 replies to this topic

#21 jdanner95

  • Members
  • 57 posts
  • LocationUS

Posted 24 October 2016 - 03:29 PM

oh ok

#22 jdanner95

  • Members
  • 57 posts
  • LocationUS

Posted 24 October 2016 - 03:42 PM

View PostBomb Bloke, on 24 October 2016 - 01:41 PM, said:

View Postjdanner95, on 24 October 2016 - 10:52 AM, said:

So if I take out getjob then it should be be fine is what you are telling me

No, just move the "end" you had on line 222 up to line 194.
I did fix that part of the code, but once it gets to the job it won't go down and start the quarry part

#23 jdanner95

  • Members
  • 57 posts
  • LocationUS

Posted 24 October 2016 - 03:49 PM

here is the updated pastebin code to what you told me and I have done that but I do have the trouble once it reaches the job as stated in last post of this that it won't start quarring
http://pastebin.com/iYqpNa1a

#24 Larry84

  • Members
  • 51 posts
  • LocationItaly

Posted 24 October 2016 - 07:05 PM

Again, the problem is in the moveDown function, on line 84 it should be turtle.down() instead of turtle.Down(). Lua is case sensitive. Remember that every function starts with a a lowercase letter, and there are upperacse ones just as a convention, to distinguish words.
Also, with my previous post, I meant only the second turtle.digDown(), the first had to be right there for what you intended (diggging a block and then moving, am I right?).
It should become something like this:
function moveDown()
  yCoord = yCoord - 1
 
  turtle.digDown()
 
  moved = false
  while not(moved) do
    moved = turtle.down()
  end
	 
  if yMin > yCoord then
    yMin = yCoord
  end
end

In inventoryFull function you've messed it up a little :P it now doesn't work as you should expect. You aren't needed to re-set the turtle selected slot to 1 (unless you want it to be done, of course), because turtle.getItemCount() doesn't move the selected slot. Also, it will now return what turtle.select() returns (because it's the last line of your function and you've not used any return). Use return, or simply do not set a variable to turtle.getItemCount(16)>0 and use it as the last (and only, in my advice) line of inventoryFull.
(I suggest you to modify it like this:)
function inventoryFull()
  return turtle.getItemCount(16) > 0
end

Edited by Larry84, 24 October 2016 - 07:49 PM.


#25 jdanner95

  • Members
  • 57 posts
  • LocationUS

Posted 24 October 2016 - 07:48 PM

Ya I wanted to dig once it got to its target area to quarry to bedrock then get a new job from the manger and quarry to the next area the computer sends it too

#26 jdanner95

  • Members
  • 57 posts
  • LocationUS

Posted 24 October 2016 - 08:19 PM

here is the updated version of the code, but now it is saying there is a error on line 79 in the code and he gets on the ground but wont dig now
http://pastebin.com/d1RQYGK1

Edited by jdanner95, 24 October 2016 - 08:20 PM.


#27 Larry84

  • Members
  • 51 posts
  • LocationItaly

Posted 24 October 2016 - 09:20 PM

In fact, on line 79, it should be turtle.digDown()

#28 jdanner95

  • Members
  • 57 posts
  • LocationUS

Posted 24 October 2016 - 10:32 PM

View PostLarry84, on 24 October 2016 - 09:20 PM, said:

In fact, on line 79, it should be turtle.digDown()
thank you so much it has fixed all my problems and it works now just one thing I need to do now it progam so he can get fuel so I don't have too can I put that anywhere in the code or should be at the top or bottom cause I am not sure but it does work thank very much :)

#29 jdanner95

  • Members
  • 57 posts
  • LocationUS

Posted 25 October 2016 - 12:45 PM

I have a question to ask I have made this logging code to make the logging turtle to chop tress I was just wantting to know if there is a way to make it chop red forest trees because I have those in the mode pack I am useing and I am also trying to figure out if there is a way to get it to auto detect and after its done to smelt its own fuel and plant and put the wood back into the chest as it is right now it plants and it chops and it refuels it just don't do the other things
http://pastebin.com/LGnMfbdc
thanks for everything :)

#30 Lupus590

  • Members
  • 2,029 posts
  • LocationUK

Posted 25 October 2016 - 02:20 PM

View Postjdanner95, on 25 October 2016 - 12:45 PM, said:

I have a question to ask I have made this logging code to make the logging turtle to chop tress I was just wantting to know if there is a way to make it chop red forest trees because I have those in the mode pack I am useing and I am also trying to figure out if there is a way to get it to auto detect and after its done to smelt its own fuel and plant and put the wood back into the chest as it is right now it plants and it chops and it refuels it just don't do the other things
http://pastebin.com/LGnMfbdc
thanks for everything :)

can we have a screenshot of the tree in question?

#31 jdanner95

  • Members
  • 57 posts
  • LocationUS

Posted 25 October 2016 - 03:59 PM

View PostLupus590, on 25 October 2016 - 02:20 PM, said:

View Postjdanner95, on 25 October 2016 - 12:45 PM, said:

I have a question to ask I have made this logging code to make the logging turtle to chop tress I was just wantting to know if there is a way to make it chop red forest trees because I have those in the mode pack I am useing and I am also trying to figure out if there is a way to get it to auto detect and after its done to smelt its own fuel and plant and put the wood back into the chest as it is right now it plants and it chops and it refuels it just don't do the other things
http://pastebin.com/LGnMfbdc
thanks for everything :)

can we have a screenshot of the tree in question?
I am not sure how to paste it into here but it is the redwood tree from the mod natura plus I was just wourding cause it can cut it down cause i have tested it but it only does one row in tunk of the tree and I also have it to were it would plant the sapling if I have it in its slot 2 I just was asking on how to get it to chop all the tree and replant and also put the wood in a chest and also make its own fuel and sit until a tree grows again even some times the oak trees grow weird also so its why I was asking about because somtimes I grow oak or big tress I just wanted to code a all round lumber jack which I did its just not cutting it once it grows or even making its own fuel and put the logs in the chest cause I was not sure on how I would go about doing that cause it needed the log to cut the tree of that type, so its why I asked.
cause I have tried to google search on that and I really did not get very well good things for that

Edited by jdanner95, 25 October 2016 - 04:04 PM.


#32 Lupus590

  • Members
  • 2,029 posts
  • LocationUK

Posted 25 October 2016 - 04:26 PM

View Postjdanner95, on 25 October 2016 - 03:59 PM, said:

View PostLupus590, on 25 October 2016 - 02:20 PM, said:

View Postjdanner95, on 25 October 2016 - 12:45 PM, said:

I have a question to ask I have made this logging code to make the logging turtle to chop tress I was just wantting to know if there is a way to make it chop red forest trees because I have those in the mode pack I am useing and I am also trying to figure out if there is a way to get it to auto detect and after its done to smelt its own fuel and plant and put the wood back into the chest as it is right now it plants and it chops and it refuels it just don't do the other things
http://pastebin.com/LGnMfbdc
thanks for everything :)

can we have a screenshot of the tree in question?
I am not sure how to paste it into here but it is the redwood tree from the mod natura

upload image to a hosting service, copy a direct link. In post editor, click on image icon (under the smily face) and paste link:

Posted Image

as for a soloution to the problem.... err... you had to pick the ridiculously big one!

get the turtle to map out the base of the tree, then do each column in turn. This will get the truck and some of the leaves but not all of the branches or the roots, but it's a starting point.

Edited by Lupus590, 25 October 2016 - 04:27 PM.


#33 Larry84

  • Members
  • 51 posts
  • LocationItaly

Posted 25 October 2016 - 04:32 PM

View Postjdanner95, on 24 October 2016 - 10:32 PM, said:

View PostLarry84, on 24 October 2016 - 09:20 PM, said:

In fact, on line 79, it should be turtle.digDown()
thank you so much it has fixed all my problems and it works now just one thing I need to do now it progam so he can get fuel so I don't have too can I put that anywhere in the code or should be at the top or bottom cause I am not sure but it does work thank very much :)/>

You can make a function wich controls fuel and then call it together with inventoryFull()

#34 jdanner95

  • Members
  • 57 posts
  • LocationUS

Posted 25 October 2016 - 04:48 PM

View PostLupus590, on 25 October 2016 - 04:26 PM, said:

View Postjdanner95, on 25 October 2016 - 03:59 PM, said:

View PostLupus590, on 25 October 2016 - 02:20 PM, said:

View Postjdanner95, on 25 October 2016 - 12:45 PM, said:

I have a question to ask I have made this logging code to make the logging turtle to chop tress I was just wantting to know if there is a way to make it chop red forest trees because I have those in the mode pack I am useing and I am also trying to figure out if there is a way to get it to auto detect and after its done to smelt its own fuel and plant and put the wood back into the chest as it is right now it plants and it chops and it refuels it just don't do the other things
http://pastebin.com/LGnMfbdc
thanks for everything :)

can we have a screenshot of the tree in question?
I am not sure how to paste it into here but it is the redwood tree from the mod natura

upload image to a hosting service, copy a direct link. In post editor, click on image icon (under the smily face) and paste link:

Posted Image

as for a soloution to the problem.... err... you had to pick the ridiculously big one!

get the turtle to map out the base of the tree, then do each column in turn. This will get the truck and some of the leaves but not all of the branches or the roots, but it's a starting point.
I was just asking cause I was cures on that, but its not the tree I am doing right now as stated in my post I just was asking, but as far as it goes for the oak trees I can do the same thing I am guessing do I have to use a lumberJack turtle that is a crafty turtle to the making of its fuel and auto detect the tree is grown if I am right

View PostLarry84, on 25 October 2016 - 04:32 PM, said:

View Postjdanner95, on 24 October 2016 - 10:32 PM, said:

View PostLarry84, on 24 October 2016 - 09:20 PM, said:

In fact, on line 79, it should be turtle.digDown()
thank you so much it has fixed all my problems and it works now just one thing I need to do now it progam so he can get fuel so I don't have too can I put that anywhere in the code or should be at the top or bottom cause I am not sure but it does work thank very much :)/>

You can make a function wich controls fuel and then call it together with inventoryFull()
ok I have to check that out and update it I am just glad it is working nicely one thing I do have a question do I use gps towers to let the turtle know what the next job would be and where from the manger right or no cause as it is right now the area is hard coded into the manger code and the starting point is in the turtle that why I was asking

#35 Larry84

  • Members
  • 51 posts
  • LocationItaly

Posted 25 October 2016 - 04:59 PM

View Postjdanner95, on 25 October 2016 - 04:48 PM, said:

-hard snip-

ok I have to check that out and update it I am just glad it is working nicely one thing I do have a question do I use gps towers to let the turtle know what the next job would be and where from the manger right or no cause as it is right now the area is hard coded into the manger code and the starting point is in the turtle that why I was asking

I'm so glad you've said this. Really.

That's not a really hard thing, you just have to add at the top of the script a gps function which sets the actual (at startup) coordinates of the turtle. You also need to setup gps towers, as you said.
[hint]
http://www.computerc...o/wiki/Gps_(API)
[/hint]

#36 jdanner95

  • Members
  • 57 posts
  • LocationUS

Posted 25 October 2016 - 05:26 PM

View PostLarry84, on 25 October 2016 - 04:59 PM, said:

View Postjdanner95, on 25 October 2016 - 04:48 PM, said:

-hard snip-

ok I have to check that out and update it I am just glad it is working nicely one thing I do have a question do I use gps towers to let the turtle know what the next job would be and where from the manger right or no cause as it is right now the area is hard coded into the manger code and the starting point is in the turtle that why I was asking

I'm so glad you've said this. Really.

That's not a really hard thing, you just have to add at the top of the script a gps function which sets the actual (at startup) coordinates of the turtle. You also need to setup gps towers, as you said.
[hint]
http://www.computerc...o/wiki/Gps_(API)
[/hint]
ok so instead of using the x and y and z coords that in the top of the code I just put in a goto fuction of a gps in the code
causer here is the paste bin to the turtle
http://pastebin.com/4RkbSvXv
and here is the manger code
http://pastebin.com/TGsEffzC
btw I am learning and its just easier to write it all out but I have spent a week trying to get the qurry code to run now I am just need to get to where I do not have to hard code the stuff of y x and z into the code for both and let the manger do all the telling for the turtle so I can make more turtles and let them quarry

#37 Larry84

  • Members
  • 51 posts
  • LocationItaly

Posted 25 October 2016 - 06:42 PM

Exactly. I suggest you to put some code at the top of the program, so that the turtle is aware of where it starts, and then your coordinate management will work for you, it's already capable of doing this.
Just remove the first three lines of the code (where you define your xCoord, yCoord, and zCoord varibles) and put in this:

rednet.open("right")

xCoord, yCoord, zCoord = gps.locate()
if not xCoord then
  error("Cannot find coordinates")
end

It opens up your modem, then locates the turtle based on the gps tower signals and, if it isn't able to find any coordinate, you will get an error saying "Cannot find coordinates".

Edited by Larry84, 25 October 2016 - 06:59 PM.


#38 jdanner95

  • Members
  • 57 posts
  • LocationUS

Posted 25 October 2016 - 07:33 PM

would tthat be the same with the manger code too or just the turtle

#39 Larry84

  • Members
  • 51 posts
  • LocationItaly

Posted 25 October 2016 - 07:52 PM

Just the turtle, the manager should be exactly the same.

#40 jdanner95

  • Members
  • 57 posts
  • LocationUS

Posted 25 October 2016 - 08:24 PM

View PostLarry84, on 25 October 2016 - 07:52 PM, said:

Just the turtle, the manager should be exactly the same.
ok here is the turtle code from paste bin
http://pastebin.com/4RkbSvXv
I should say the turltle did what it was ment to do, but I think the manger code needs to be changed to get the gps cause it didn't send the turtle to a new job I did it in a single player world and it did not tell the turtle to go to a area to mine

Edited by jdanner95, 25 October 2016 - 08:25 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users