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

neeed help on this code

Started by jdanner95, 20 October 2016 - 12:54 PM
jdanner95 #1
Posted 20 October 2016 - 02:54 PM
Hi I don't post in forms, but I need some help on this code that I was doing because it gives me a error when I try to run this code I don't know what I am doing wrong I am sure I am missing something here, or did it not use this type of stuff
here is the link on pastebin for the code
http://pastebin.com/P9A0TGMT
the error when I try to run it on the turtle is bios;14; [string "dark"];6; ')' expected
if you know what it could be plz let me know I am learning and I would like to know what happened thanks
jdanner95
just letting you all know it is fixed and I really thank you for all the help have a great night/day :)/>
Edited on 21 October 2016 - 03:30 PM
Bomb Bloke #2
Posted 20 October 2016 - 02:57 PM
The error is telling you that you've put something into line 6 that shouldn't go there, but where a ")" could go.

                               v
orientations = ("north", "east". "south", "west")
                               ^
jdanner95 #3
Posted 20 October 2016 - 03:07 PM
The error is telling you that you've put something into line 6 that shouldn't go there, but where a ")" could go.

							   v
orientations = ("north", "east". "south", "west")
							   ^
ah ok I really thank you for your help

so I fixed and if I am getting you right it would go like this

orientations = ("north","east","south","west")

right cause its what I did and it still giving me that same error
or is it like this

Spoiler
orientations = ("north","east")"south","west")

xCoord = 551
zCoord = 414
yCoord = 83

orientation = 4
orientations = ("north","east","south","west")

zDiff = (-1, 0, 1, 0)
xDiff = (0, 1, 0, -1)

function left()
  orientation = orientation - 1
  orientation = (orientation + 1) % 4
  orientation = orientation + 1

  turtle.turnLeft()
end

function right()
  orientation = orientation - 1
  orientation = (orientation - 1) % 4
  orientation = orienation  + 1

  turtle.turnRight() 
end

function moveForward()
  xCoord = xCoord + xDiff[orientation]
  zCoord = zCoord + zDiff[orientation]

  turtle.forward()
end

for i = 1,3 do
  moveForward()
  print("X;"..xCoord.." Z;"..zCoord)
end

this is the total code and I did fix what you told me to fix I hoped it would work but it still gave me the same error as last time
here is the pastebin link too
http://pastebin.com/hqV91aQ3
Edited on 22 October 2016 - 10:42 PM
hbomb79 #4
Posted 21 October 2016 - 11:46 AM
From what I can gather orientations should be a table, and as such defined using curly braces - not parentheses:

orientations = {"north","east","south","west"}
jdanner95 #5
Posted 21 October 2016 - 02:23 PM
From what I can gather orientations should be a table, and as such defined using curly braces - not parentheses:

orientations = {"north","east","south","west"}
oh ok thank you AI have been trying to figure them out alot and its like finding everything Ihave done so far was like not working
jdanner95 #6
Posted 21 October 2016 - 02:48 PM
From what I can gather orientations should be a table, and as such defined using curly braces - not parentheses:

orientations = {"north","east","south","west"}

Spoiler
xCoord = 466
zCoord = 714
yCoord = 70
orientation = 4
orientations = {"north","east","south","west"}
zDiff = (-1, 0, 1, 0)
xDiff = (0, 1, 0, -1)

function left()
	orientation = orientation - 1
	orientation = (orientation + 1) % 4
	orientation = orientation + 1
	turtle.turnLeft()
end

function right()
	orientation = orientation - 1
	orientation = (orientation - 1) % 4
	orientation = orienation + 1
	turtle.turnRight()
end

function moveForward()
	xCoord = xCoord + xDiff[orientation]
	zCoord = zCoord + zDiff[orientation]
	turtle.forward()
end

for i = 1,3 do
	moveForward()
	print("X;"..xCoord.." Z;"..zCoord)
end

I don't know if I am doing it right or not cause i put the brackets instead of the other ones and I still giving that error bios;14: [string "Quarry"]:8: ')'
Edited on 22 October 2016 - 10:44 PM
jdanner95 #7
Posted 21 October 2016 - 05:29 PM
i have fixed my problem but thank you for all your help guys :)/> much respect :)/> and thank you very much
Hbomb_79

for getting it right, it worked :)/>
jdanner95 #8
Posted 22 October 2016 - 08:06 PM
ok I have a question I have finshed my code and my turtle won't move when the manger computer gave it a job and when it does get to the loaction it just spins and not do anything
i was wanting to know if you guys can tell me why here is my manger code for the computer controlling the turtle

Spoiler
 print(os.computerID())

jobAvailable = true

xStart = 486
zStart = 749

xEnd = 441
zEnd = 221

qDist = 11

xNextJob = xStart
zNextJob = zStart
yNextJob = 71

rednet.close("right")
rednet.open("right")

function setNextJob()

  zNextJob = zNextJob - qDist
  if zNextJob < zEnd then
	zNextJob = zStart
	xNextJob = xNextJob -qDist
	 if xNextJob < xEnd then
	   jobAvailable = false
	 end
   end
end
while jobAvailable do

  print("Waiting for quarry turtle")

  id, message, dis = rednet.receive()

  print("Turtle"..id.." needs a job")


  if message == "getJob" then
	print("Job available at "..xNextJob.." "..zNextJob)
	rednet.send(id, "yes")
	print("trace")
	rednet.send(id, tostring(xNextJob))
	rednet.send(id, tostring(zNextJob))
	rednet.send(id, tostring(yNextJob))

	setNextJob()
  end
print("No more jobs")
while true do
  id, message, dis = rednet.receive()

  if message == "getJob" then
	rednet.send(id, "no")
	end
  end
end

here is the turtle code

Spoiler
xCoord = 404
zCoord = 748
yCoord = 64

xQuarry = 999
zQuarry = 999
yQuarry = 150

xProgress = 999
zProgress = 999
yProgress = 150
oProgress = 1

xHome = xCoord
zHome = zCoord
yHome = yCoord

yTravel = 79

orientation = 4
orientations = {"north","east","south","west"}

zDiff = {-1, 0, 1, 0}
xDiff = {0, 1, 0, -1}

lineLength = 2
lines = 3
yMin = 999

jobAvailable = true
manager = 36

function inventoryFull()
  turtle.select(16)
  full = turtle.getItemCount(16) > 0
  turtle.select(1)
  return full
end

function left()
  orientation = orientation - 1
  orientation = (orientation -1) % 4
  orientation = orientation + 1

  turtle.turnLeft()
end


function right()
  orientation = orientation - 1
  orientation = (orientation + 1) % 4
  orientation = orientation + 1

  turtle.turnRight()
end

function moveForward()
  xCoord = xCoord + xDiff[orientation]
  zCoord = zCoord + zDiff[orientation]

   turtle.dig()
   moved = false
   while not(moved) do
	 moved = turtle.forward()
	end
  end

function moveUP()
  yCoord = yCoord + 1

  turtle.digUp()

  moved = false
  while not(moved) do
	moved = turtle.up()
	end
end

function moveDown()
  yCoord = yCoord - 1

  turtle.digDown()

  moved = false
  while not(moved) do
	moved = turtle.digDown()
  end


	if yMin > yCoord then
	  yMin = yCoord
	end
  end

function look(direction)
  while direction ~= orientations[orientation] do
	right()
  end  
end

function goto(xTarget, zTarget, yTarget)
   while yTarget < yCoord do
	  moveDown()
	end
   while yTarget > yCoord do
	 moveUP()
   end

  if xTarget < xCoord then
	look("west")
	while xTarget < xCoord do
	  moveForward()
	end
  end
  if xTarget > xCoord then
	look("east")
	while xTarget > xCoord do
	  moveForward()
	end
  end
  if zTarget < zCoord then
	look("north")
	while zTarget < zCoord do
	  moveForward()
	end
  end
  if zTarget > zCoord then
	look("south")
	while zTarget > zCoord do
	  moveForward()
	end
  end
end

function returnItems()
  xProgress = xCoord
  zProgress = zCoord
  yProgress = yCoord
  oProgress = orientation

  goto(xHome, zHome, yTravel)
  goto(xHome, zHome, yHome)
  look("west")

  for i = 1,16 do
	turtle.select(i)
	turtle.drop()
	end
	turtle.select(1)

	goto(xProgress, zProgress, yTravel)
	goto(xProgress, zProgress, yProgress)
	look(orientations[oProgress])
  end

function digLine()
  for i = 1,lineLength do
	if inventoryFull() then
	 returnItems()  
   end
	moveForward()
  end
end

function digLayer()
  for i = 1,lines do
	digLine()
	if i%2 == 1 and i < lines then
	  left()
	  moveForward()
	  left()
	 elseif i < lines then
	   right()
	   moveForward()
	   right()
	 end
   end
   goto(xQuarry, zQuarry, yCoord)
   look("north")
   moveDown()
end

function digQuarry(xTarget, zTarget, yTarget)
  xQuarry = xTarget
  zQuarry = zTarget
  yQuarry = yTarget

  goto(xQuarry, zQuarry, yTravel)
  goto(xQuarry, zQuarry, yQuarry)
  while yMin > 7 do
	 digLayer()
   end
  goto(xQuarry, zQuarry, yQuarry)
  goto(xHome, zHome, yTravel)
  goto(xHome, zHome, yHome)
  yMin = 999
end

function getjob()
  while jobAvailable do
	print("Requesting Job")
	rednet.send(manager, "getJob")
	id, message, dis = rednet.receive()

	if message == "yes" then
	  id, xRec, dis = rednet.receive()
	  id, zRec, dis = rednet.receive()
	  id, yRec, dis = rednet.receive()

	  xQuarry = tonumber(xRec)
	  zQuarry = tonumber(zRec)
	  yQuarry = tonumber(yRec)
	  print("Job at"..xQuarry.." "..zQuarry)
	  digQuarry(xQuarry, zQuarry, yQuarry)
	  print("Finshed Job")
	elseif message == "no" then
	  print("No more Jobs")
	  jobAvailable = false
	end
  end
end

rednet.close("right")
rednet.open("right")

getjob()

if you all can tell me that would help out alot if you cant its ok I just thought I would ask cause I have been trying for days to figure it out
thanks
jdanner95
Edited on 22 October 2016 - 10:46 PM
KingofGamesYami #9
Posted 22 October 2016 - 08:14 PM
Does the turtle have fuel?
jdanner95 #10
Posted 22 October 2016 - 08:52 PM
I have to check that if it does but it just don't make since on why it would spin once it reaches the area
jdanner95 #11
Posted 22 October 2016 - 09:33 PM
ya the fuel was why the trutle would not move, but Idk what I am doing wrong, but once the turtle reaches the area to dig the turtle just hover above it and don't even start to quarry like he should but if the slots are fulled the turtle does got back, but don't go down once there and don't even drop the items to return to the job I am thinking of just giving up on it, but I jaut wanted to update you all and let you all know
Larry84 #12
Posted 23 October 2016 - 04:12 PM
It seems that the problem is into "moveDown" function, at line 86. Should that be turtle.down() instead of turtle.digDown() ?
Also, on function inventoryFull, lines 34 and 36 aren't needed - turtle.getItemCount() already select the slot you passed as a parameter.
Edited on 23 October 2016 - 02:27 PM
jdanner95 #13
Posted 23 October 2016 - 09:41 PM
ok ty I am going to test that I hope that it will work and dig a quarry and bring it back once done :)/> cause that would be so nice if does I have been so down cause I could never figure it out I was worried I did something esle to the goto comand never thought about the go down one
jdanner95 #14
Posted 23 October 2016 - 10:19 PM
I have fixed the lines that you have told me about, but now my rednet code is not working here is the paste bin line to the code
http://pastebin.com/mqCrFxYN
and if I take out the end on line 221 it tells me end of line on line 77 which makes no sense to me since there is more code to go on with so I did what it said for line 221 and now it won't use rednet and talk to the other computer and it did work the first time, but once it got to the ara it was ment to mine it gave a error for line 80 so I didn't know
Bomb Bloke #15
Posted 24 October 2016 - 03:03 AM
You don't have an end on line 221…

I guess this bit near the bottom is your problem:

function digQuarry(xTarget, zTarget, yTarget)
  xQuarry = xTarget
  zQuarry = zTarget
  yQuarry = yTarget

  goto(xQuarry, zQuarry, yTravel)
  goto(xQuarry, zQuarry, yQuarry)
  while yMin > 7 do
     digLayer()
   end
  goto(xQuarry, zQuarry, yQuarry)
  goto(xHome, zHome, yTravel)
  goto(xHome, zHome, yHome)
  yMin = 999 
-- ????

function getjob()
  ...
jdanner95 #16
Posted 24 October 2016 - 04:29 AM
What would be the problem cause I am confused on why that fuction would cause a problem but idk it could be
Bomb Bloke #17
Posted 24 October 2016 - 07:01 AM
Because there is no "end" statement between lines 180 and lines 195, getjob() is defined within digQuarry(). The "end" statement on line 222 is currently closing your digQuarry() definition.
jdanner95 #18
Posted 24 October 2016 - 11:52 AM
So if I take out getjob then it should be be fine is what you are telling me

I am sorry for all the questions I am learning is all but I understand it I just new with it
jdanner95 #19
Posted 24 October 2016 - 12:26 PM
will I delated it and I am still having the problem but it could be the whole code is screwed up i just would hate to rewrite it again if that is the cause cause it took me for ever to write it
thank you for your help thought
jdanner95
Bomb Bloke #20
Posted 24 October 2016 - 02:41 PM
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.
jdanner95 #21
Posted 24 October 2016 - 04:29 PM
oh ok
jdanner95 #22
Posted 24 October 2016 - 04:42 PM
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
jdanner95 #23
Posted 24 October 2016 - 04: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
Larry84 #24
Posted 24 October 2016 - 08: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 on 24 October 2016 - 06:49 PM
jdanner95 #25
Posted 24 October 2016 - 08: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
jdanner95 #26
Posted 24 October 2016 - 09: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 on 24 October 2016 - 07:20 PM
Larry84 #27
Posted 24 October 2016 - 10:20 PM
In fact, on line 79, it should be turtle.digDown()
jdanner95 #28
Posted 24 October 2016 - 11:32 PM
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 :)/>
jdanner95 #29
Posted 25 October 2016 - 01: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 :)/>
Lupus590 #30
Posted 25 October 2016 - 03:20 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 :)/>

can we have a screenshot of the tree in question?
jdanner95 #31
Posted 25 October 2016 - 04:59 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 :)/>

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 on 25 October 2016 - 03:04 PM
Lupus590 #32
Posted 25 October 2016 - 05:26 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 :)/>

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:



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 on 25 October 2016 - 03:27 PM
Larry84 #33
Posted 25 October 2016 - 05:32 PM
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()
jdanner95 #34
Posted 25 October 2016 - 05:48 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 :)/>

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:



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

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
Larry84 #35
Posted 25 October 2016 - 05:59 PM
-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.computercraft.info/wiki/Gps_(API)
[/hint]
jdanner95 #36
Posted 25 October 2016 - 06:26 PM
-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
Larry84 #37
Posted 25 October 2016 - 07: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 on 25 October 2016 - 05:59 PM
jdanner95 #38
Posted 25 October 2016 - 08:33 PM
would tthat be the same with the manger code too or just the turtle
Larry84 #39
Posted 25 October 2016 - 08:52 PM
Just the turtle, the manager should be exactly the same.
jdanner95 #40
Posted 25 October 2016 - 09:24 PM
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 on 25 October 2016 - 07:25 PM
Larry84 #41
Posted 25 October 2016 - 09:35 PM
Well, the manager is set up so that it will say to just one turtle to go to quarry

Wait, is the manager not sending any turtle at all?
jdanner95 #42
Posted 25 October 2016 - 09:46 PM
No its not here is the pastebin link to it http://pastebin.com/TGsEffzC
Also it does send the turtle out on the job but I was asking if I have code where it gets gps and sends the turtle a area to mine and so forth
Larry84 #43
Posted 25 October 2016 - 09:52 PM
No, the gps is just for the turtle, you don't have to modify the manager.
Though, in the manager code you may want to redefine xStart, zStart, xEnd and zEnd according to your wishes, but these are values that you want to give - they are the coordinates the turtle will quarry.
For example, if you want it to quarry from x:476 z:329 to x:490 z:350 in the manager you have to change


xStart = 476
zStart = 329

xEnd = 490
zEnd = 350

Just as an example, of course
Edited on 25 October 2016 - 07:55 PM
jdanner95 #44
Posted 25 October 2016 - 10:07 PM
Ah so I still will have too enter the area in the manger still then
Larry84 #45
Posted 25 October 2016 - 10:24 PM
Yeah, simply because it's an area that you define.

You can set a large area and the manager will quarry it all for you if you want it to.
jdanner95 #46
Posted 25 October 2016 - 11:09 PM
thats what I was wanting to do with it also I am still trying to figure out a other code but I get it later or talk more about later
jdanner95 #47
Posted 26 October 2016 - 07:07 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 :)/>

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:



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.
so when you said to do a column you mean do {code} turtle.turnLeft {code} right if I anot mistaking and make a fuction to make it remember the base of the tree right? and I alreday have the grounds of a code for it I think but here it is just in case
http://pastebin.com/ZyfaKHYj
LumberJack v1.0
Edited on 26 October 2016 - 05:42 PM
Lupus590 #48
Posted 29 October 2016 - 11:50 PM
You should be able to map out points as you dig the tree, I've made a start on this but needed to go to bed before I could finish.

Here's what I managed to get so far though: http://pastebin.com/LBdkTyZj
jdanner95 #49
Posted 30 October 2016 - 01:56 AM
You should be able to map out points as you dig the tree, I've made a start on this but needed to go to bed before I could finish.

Here's what I managed to get so far though: http://pastebin.com/LBdkTyZj
ok I can finsh it later thank you very much for what you did I add to as I go along
also love the name you put for it lol
jdanner95 #50
Posted 12 November 2016 - 06:20 PM
I have a question I have updated the code to use gps and the gps is right for the x y and z when I do gps locate but when the turtle gets the job from the manger it digs down instead of traveling to the location of the area where it is ment to dig here is the paste bin link for the Quarry
http://pastebin.com/WhRtMccD
and I don't why it would be diging down instead of going the loaction
jdanner95 #51
Posted 19 November 2016 - 10:06 PM
my mining turtle is going diging down instead of going to the job site from the manger I have updated the code to use the gps api but it is diging down instead of going to the the area from the manger
here is the code for the quarry in pastebin link
http://pastebin.com/4k6nv6cu

and the manger paste bin link is

http://pastebin.com/MwzsDV3m

and the turtle is not giveing any errors so I don't what is going with it
thanks
jdanner95
Dog #52
Posted 19 November 2016 - 10:46 PM
In your quarry code, I notice that in several places you are sending the turtle to yTravel instead of yTarget, yQuarry, or yProgress - not sure if that's the issue, but are you sure that's what you intended? I'm seeing this at lines 140, 150, 187, and 193.
Edited on 19 November 2016 - 09:47 PM
jdanner95 #53
Posted 19 November 2016 - 11:44 PM
I am new with the code but its not giving a error and I would like to fix it see I had a first not even put the gps code in to the quarry code but once I did that it now digs down instead of going to the loaction so if you know how to fix it I would be glad to change it I am just learning and new with the computer craft code
Bomb Bloke #54
Posted 20 November 2016 - 03:00 AM
Threads merged - please stick to the one for the one project.
Dog #55
Posted 20 November 2016 - 03:04 AM
I'm terrible with navigation so I won't be able to help you much there…but, as a first step, you might want to try the changes I suggested and see if that fixes your problem.
jdanner95 #56
Posted 20 November 2016 - 03:31 AM
I'm terrible with navigation so I won't be able to help you much there…but, as a first step, you might want to try the changes I suggested and see if that fixes your problem.
what changes did ya mean cause I saw what ya wrote first but I am not sure with what lines you mean to change in those lines

Threads merged - please stick to the one for the one project.
ok ty and sorry for that
Dog #57
Posted 20 November 2016 - 03:38 AM
I have to admit, that on second blush, the changes I recommend aren't needed. Is yTravel your up/down coordinate or is yTravel a forward/back/left/right coordinate?
jdanner95 #58
Posted 20 November 2016 - 12:22 PM
I have to admit, that on second blush, the changes I recommend aren't needed. Is yTravel your up/down coordinate or is yTravel a forward/back/left/right coordinate?
yTravel is so the truttle don't hit anything and its so it don't dig through the bass until it gets to its area to dig then it moves down
Dog #59
Posted 20 November 2016 - 03:20 PM
What is your ground level? Is it higher or lower than 79?
jdanner95 #60
Posted 20 November 2016 - 05:08 PM
What is your ground level? Is it higher or lower than 79?
is lower 79 is when its in the air flying to the area and it its sosped to go down once it reaches the area to qurry but it just stays in the starting point and digs down and don't go the loaction so I am guesing it could be causeing my problem if I am not misting?
Dog #61
Posted 20 November 2016 - 06:22 PM
Unless I'm missing something obvious, I don't see any reason your code would behave that way. If your ground level is below 79 then check the next two things:

1. Is your GPS returning correct coordinates?

2. Are you providing the coordinates in the correct order? (I ask this because I am rubbish with navigation and MC coordinates)
jdanner95 #62
Posted 20 November 2016 - 08:55 PM
Unless I'm missing something obvious, I don't see any reason your code would behave that way. If your ground level is below 79 then check the next two things:

1. Is your GPS returning correct coordinates?

2. Are you providing the coordinates in the correct order? (I ask this because I am rubbish with navigation and MC coordinates)
see I am bad with gps too and it saids its got the right one cordinates but I don't know because I never used the gps api so i don't know if its runing them right ether
jdanner95 #63
Posted 20 November 2016 - 09:09 PM
Unless I'm missing something obvious, I don't see any reason your code would behave that way. If your ground level is below 79 then check the next two things:

1. Is your GPS returning correct coordinates?

2. Are you providing the coordinates in the correct order? (I ask this because I am rubbish with navigation and MC coordinates)
see I am bad with gps too and it saids its got the right one cordinates but I don't know because I never used the gps api so i don't know if its runing them right ether
I just checked the gps I think it is off but I am not sure on how to make it work with the code cause it should go to the area and quarry the point for the gps was so I didn't have to hard code where the turtle's home is and so it can get back to the house and drop off its things and go back again
Lupus590 #64
Posted 20 November 2016 - 09:19 PM
Have you looked at the wiki page for the GPS API? http://www.computerc...o/wiki/Gps_(API)
Edited on 20 November 2016 - 08:20 PM
jdanner95 #65
Posted 20 November 2016 - 09:36 PM
Have you looked at the wiki page for the GPS API? http://www.computerc...o/wiki/Gps_(API)
ya I don't understand how to set it up like do i use the x as 0 for south and north or do I put the x in the and do I use the exect x for it of where the comptur is setting, I don't think its the problem cause when I use the gps loacte in the turtle it is right where it should be on the its home so there working I just don't know why when I tell it to qurry at that area from home it won't go so there is some wrong there because the first time I used the code I ddin't have the gps api in it I had to hard code its home where it is at so its why I was useing the api because some told me how on this form all of it s right here in the all the pages
Bomb Bloke #66
Posted 20 November 2016 - 11:16 PM
Use x/y/z for whichever axes you like, so long as you're consistent - all systems must use them the same way. Minecraft itself uses x for west-to-east, y for down-to-up, and z for north-to-south, so you're generally best off following that standard.

Each GPS server should be coded with the exact co-ords of the computer running the GPS script.
jdanner95 #67
Posted 21 November 2016 - 12:38 AM
Use x/y/z for whichever axes you like, so long as you're consistent - all systems must use them the same way. Minecraft itself uses x for west-to-east, y for down-to-up, and z for north-to-south, so you're generally best off following that standard.

Each GPS server should be coded with the exact co-ords of the computer running the GPS script.
I only have one gps tower
here is the code to the gps tower its simler as in with the shell.run comand
http://pastebin.com/TYq0jhs8


F3 screen cordantes where I am standing on the computer






GPS tower


GPS

Edited on 20 November 2016 - 11:43 PM
Bomb Bloke #68
Posted 21 November 2016 - 12:48 AM
I see four computers in your image. So long as each has its precise co-ords programmed into it (which going by your screenshots, they don't), and is turned on and running (the screenshots suggest at least some are turned off), that setup should be fine.

Remember that if you're directly standing on top of a computer, then it should share your x/z co-ords, but its y co-ord should be whatever the debug screen shows you minus one.
jdanner95 #69
Posted 21 November 2016 - 01:08 AM
So you are saying do to -202,253,-251 if I am understanding what you mean and on the just do 251 right also is that why the mining trutle stay at home and not go to the ming area to quarry is cause the GPS is messed? Right or no?
Edited on 21 November 2016 - 12:49 AM
Dog #70
Posted 21 November 2016 - 02:12 AM
Most likely the mining turtles aren't working right because the GPS is messed up.

Based on your screenshot, you'd enter -202 for x (the actual X value), 252 for y (one less than your feet position), and 253 for z (the actual Z value).
jdanner95 #71
Posted 21 November 2016 - 03:18 AM
Most likely the mining turtles aren't working right because the GPS is messed up.
Based on your screenshot, you'd enter -202 for x (the actual X value), 252 for y (one less than your feet position), and 253 for z (the actual Z value).
so it should go like this -202,253,252 right?
Dog #72
Posted 21 November 2016 - 03:22 AM
Not for the GPS host program. For that you'd enter them as -202, 252, 253 I believe.
jdanner95 #73
Posted 21 November 2016 - 04:17 AM
Not for the GPS host program. For that you'd enter them as -202, 252, 253 I believe.
I don't know but I check and if there's anyone that knows it I be glad to have more advice but I think it might be also but I am not sure which why I asked so I can fix it so I can quarry with the turtle
Dog #74
Posted 21 November 2016 - 04:25 AM
Have you tried it either way? If necessary, try it both ways and see if it works.
Bomb Bloke #75
Posted 21 November 2016 - 05:15 AM
Oh, another point - you need to round down. Remember that -0.1, for eg, rounds down to -1 (as opposed to 0).

For example, let's say you're standing directly on top of a computer, and debug shows you:

x: -202.84640
y: 253.000 (feet)
z: 253.57304

Round the values down to the nearest integers, and subtract a further one from y:

x: -203
y: 252
z: 253

Then simply plug them into the computer's startup script:

shell.run("gps","host",-203,252,253)

Repeat the process for each computer in the GPS cluster.
jdanner95 #76
Posted 21 November 2016 - 02:30 PM
Oh, another point - you need to round down. Remember that -0.1, for eg, rounds down to -1 (as opposed to 0).

For example, let's say you're standing directly on top of a computer, and debug shows you:

x: -202.84640
y: 253.000 (feet)
z: 253.57304

Round the values down to the nearest integers, and subtract a further one from y:

x: -203
y: 252
z: 253

Then simply plug them into the computer's startup script:

shell.run("gps","host",-203,252,253)

Repeat the process for each computer in the GPS cluster.
ok will it went to the area return its things and then it stoped in the air do I have to move the gps code down to the end of the program or there something else causing the problem cause it should have went back where it last stop diging
here is the code as it stands
http://pastebin.com/mb7haYiR
for the quarry
Edited on 21 November 2016 - 01:38 PM
jdanner95 #77
Posted 21 November 2016 - 02:41 PM
I just did a gps loacte to the turtle to see where he is at and ether I am looking at this wrong or somehow I am doing the gps cluster wrong

Dog #78
Posted 21 November 2016 - 04:25 PM
If your turtle's actual position is not the same as the GPS coordinates returned, then yes, your GPS cluster isn't setup correctly. Before making changes to your code, make sure your GPS cluster is working properly, then we can worry about the code.
jdanner95 #79
Posted 21 November 2016 - 06:30 PM
If your turtle's actual position is not the same as the GPS coordinates returned, then yes, your GPS cluster isn't setup correctly. Before making changes to your code, make sure your GPS cluster is working properly, then we can worry about the code.
ya true I just not good with math so its hard to understand if the gps cluster is set up right but what I saw in the f3 to turtle it don't seem to add up or seem right but I don't know
Dog #80
Posted 21 November 2016 - 06:55 PM
FWIW, you don't need to be good at math to copy the numbers from F3 to the turtle. What does your GPS cluster look like? Is it staggered like the wiki recommends (2 high, 2 low) or are they all on the same level?

If you continue to have problems with your GPS cluster, then I'd recommend you disassemble it and rebuild it using this script.
Edited on 21 November 2016 - 06:01 PM
jdanner95 #81
Posted 21 November 2016 - 07:15 PM
it looks like this
Dog #82
Posted 21 November 2016 - 07:31 PM
It looks OK. Like I said, if you can't get the GPS cluster working right, try using the script I included in my last post. I recommend using a mining turtle so you only need one disk drive. The advantage to that script is that it will setup your cluster automatically - all you have to do is provide correct starting coordinates and it handles the rest.

Having said that, it shouldn't be too hard to stand on each computer, use F3 (subtracting one for the Y value), and get them all running right.
jdanner95 #83
Posted 21 November 2016 - 07:31 PM
FWIW, you don't need to be good at math to copy the numbers from F3 to the turtle. What does your GPS cluster look like? Is it staggered like the wiki recommends (2 high, 2 low) or are they all on the same level?

If you continue to have problems with your GPS cluster, then I'd recommend you disassemble it and rebuild it using this script.
I am going to give the script a try and I am going to see if that works
jdanner95 #84
Posted 21 November 2016 - 08:37 PM
it looks like its getting the gps cluster right





here it is with the f3 screen while I am on the turtle after I have loacted it

Bomb Bloke #85
Posted 22 November 2016 - 12:48 AM
it looks like its getting the gps cluster right

That's still wrong. You got y as 68, when 67 was expected.

If you continue to have problems with your GPS cluster, then I'd recommend you disassemble it and rebuild it using this script.

That still requires jdanner95 to supply the turtle's initial position… and apparently he can't interpret the co-ords on the debug screen in order to do that. :/

Again, jdanner95, stand directly on top of the turtle, you round all the values down (remembering that negative numbers round further away from 0), and that's it.

If you're reading the debug co-ords to locate a computer, you cannot stand inside the same block as you can with a turtle (computers are a perfect block shape, turtles are slightly shorter) - meaning you need to subtract a further 1 from the y co-ord the debug screen shows you, as you're standing in the block above. With a turtle you just round the y co-ord down, same as all the other values.

For example, in your last screenshot, the debug screen shows that the turtle is located at -200, 67, 256.
jdanner95 #86
Posted 22 November 2016 - 03:12 AM
it looks like its getting the gps cluster right
That's still wrong. You got y as 68, when 67 was expected.
If you continue to have problems with your GPS cluster, then I'd recommend you disassemble it and rebuild it using this script.
That still requires jdanner95 to supply the turtle's initial position… and apparently he can't interpret the co-ords on the debug screen in order to do that. :/
Again, jdanner95, stand directly on top of the turtle, you round all the values down (remembering that negative numbers round further away from 0), and that's it.
If you're reading the debug co-ords to locate a computer, you cannot stand inside the same block as you can with a turtle (computers are a perfect block shape, turtles are slightly shorter) - meaning you need to subtract a further 1 from the y co-ord the debug screen shows you, as you're standing in the block above. With a turtle you just round the y co-ord down, same as all the other values.
For example, in your last screenshot, the debug screen shows that the turtle is located at -200, 67, 256.
so you are saying instead of standing on the computers just stay in front of them right and do the debug screen like if one computer is -200 and the y is 253 it would be 252 meaning like this -200,252,253
Dog #87
Posted 22 November 2016 - 03:15 AM
No, stand on top of the computer and subtract one from the y value. If you were at -200, 253, 253, then you'd input -200, 252, 253.
jdanner95 #88
Posted 22 November 2016 - 04:21 AM
No, stand on top of the computer and subtract one from the y value. If you were at -200, 253, 253, then you'd input -200, 252, 253.
ok will I just said -200 252 253 but I work more on it tomorrow thank you
jdanner95 #89
Posted 22 November 2016 - 03:29 PM
I think I have gotten it now




Dog #90
Posted 22 November 2016 - 03:42 PM
You're close, but you didn't round down on x (which should be 199, not 200) - that's my fault, I gave you the wrong numbers in my last post - apologies. Remember, you have to round down all values, not round up.
Bomb Bloke #91
Posted 22 November 2016 - 03:46 PM
Actually all the numbers are correct this time around; -199.72769 indeed floors to -200.
Edited on 22 November 2016 - 02:47 PM
jdanner95 #92
Posted 22 November 2016 - 04:23 PM
Actually all the numbers are correct this time around; -199.72769 indeed floors to -200.
ya finely lol now I need to get the turtle to mine in the area that I want it to go to but that is still a problem because I can send it to the area but it wont go back after it gets to the to home and unload its stuff it don't go back to the area to quarry again from where it started do I need to move the gps code down to the end of the code or do I need to do something else to the code?
here is the code just in case you need to see it again
http://pastebin.com/4z3qZKb0
and yes it uses the manger to tell it where it should quarry here is the that code too
http://pastebin.com/TGsEffzC
Edited on 22 November 2016 - 03:24 PM
Dog #93
Posted 22 November 2016 - 04:32 PM
I can't see any reason in your code why your turtle is not properly returning to it's last position after dumping it's inventory. As far as can tell, moving the code around won't fix the problem. I'll spend some time today reviewing the code again and try to figure out why it's behaving the way you describe. Maybe Bomb Bloke or somebody will see something I'm missing in the mean time.
jdanner95 #94
Posted 22 November 2016 - 04:57 PM
I can't see any reason in your code why your turtle is not properly returning to it's last position after dumping it's inventory. As far as can tell, moving the code around won't fix the problem. I'll spend some time today reviewing the code again and try to figure out why it's behaving the way you describe. Maybe Bomb Bloke or somebody will see something I'm missing in the mean time.
ok thanks I mean it could be that the manger code is wrong but I might have to do more testing with that cause I am not sure ether for that cause the manger is the one that tells the turtle where to go quarry and it it ment to tell 10 turtles to mine in a big area with out hiting each other, but see It seems to not be working but I am not sure on that until I test it or just it could be my f3 debug is wrong with the area too
Edited on 22 November 2016 - 04:11 PM
jdanner95 #95
Posted 22 November 2016 - 07:47 PM
it got the area and started minning like it should :)/>

now to see if it will return here after unloading its things
jdanner95 #96
Posted 22 November 2016 - 07:53 PM
it works now thank you all who have helped me now I just to figure out a way to get it to move the next job once its done with that area and go on to a new area with the manger to mange more turtlles other then that it works its not perfect tut I am happy it works :)/> thanks again all
one thing I want to know is how can I program to where the trutle can refuel and go on quarrying instead of canceling the program and having to redo his job again
Edited on 22 November 2016 - 07:49 PM
Lupus590 #97
Posted 22 November 2016 - 09:34 PM
one thing I want to know is how can I program to where the trutle can refuel and go on quarrying instead of canceling the program and having to redo his job again

Make a function which checks the turtle fuel level, if it's low then search the inventory for a fuel item and consume it. I would call this function before every time I move.
jdanner95 #98
Posted 23 November 2016 - 01:20 PM
one thing I want to know is how can I program to where the trutle can refuel and go on quarrying instead of canceling the program and having to redo his job again

Make a function which checks the turtle fuel level, if it's low then search the inventory for a fuel item and consume it. I would call this function before every time I move.
ok cool I should do that and I should note my goal is to get it to where the manger and the turtle will pick the areas and quarry out without me inputing them in to the manger and the other goal is to get a other turtle quarry in a other area but I don't know if there is a way to make the manger do that. For now at least it works
thanks to all ya
jdanner95