Posted 31 August 2012 - 06:07 PM
the turtle starts within range of the console of course but
i am trying to make a code for a turtle that if it goes out of range of the console it will report to the console saying it is out of range and turn off the rednet, and turn it back on when it is within range. i have a few vars here, the range var is the safe distance for the modem. since the modems range is a circle of 64 blocks out a maxium distance for a cube in a circle is 44. the next var is xCoord, zCoord, and yCoord which tracks the turtles coordinates. ServerX, ServerZ, ServerY keeps track of where the main console is at. if this is possible get back to me. if there is an easier way let me know. im having issues trying to figure out how to lay it all out.
i am trying to make a code for a turtle that if it goes out of range of the console it will report to the console saying it is out of range and turn off the rednet, and turn it back on when it is within range. i have a few vars here, the range var is the safe distance for the modem. since the modems range is a circle of 64 blocks out a maxium distance for a cube in a circle is 44. the next var is xCoord, zCoord, and yCoord which tracks the turtles coordinates. ServerX, ServerZ, ServerY keeps track of where the main console is at. if this is possible get back to me. if there is an easier way let me know. im having issues trying to figure out how to lay it all out.
range = 44
xCoord = 0
zCoord = 0
yCoord = 0
ServerX = 0
ServerZ = 0
ServerY = 0
if xCoord > (ServerX + range) or xCoord < (ServerX - range) then
rednet.send(id, "is now out of the servers Network range.")
rednet.close(side)
else
rednet.open(side)
rednet.announce()
end
if yCoord > (ServerY + range) or yCoord < (ServerY - range) then
rednet.send(id, "is now out of the servers network range.")
rednet.close(side)
else
rednet.open(side)
rednet.announce()
end
if zCoord > (ServerZ + range) or zCoord < (ServerZ - range) then
rednet.send(id, "is now out of the servers network range.")
rednet.close(side)
else
rednet.open(side)
rednet.announce()
end