Jump to content




[SOLVED] is there a better way around this


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

#1 Cozzimoto

  • Members
  • 221 posts
  • LocationDallas, Tx

Posted 31 August 2012 - 05: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.


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


#2 Matrixmage

  • Members
  • 116 posts
  • LocationAt my Computer coding for the Computer in my Computer

Posted 31 August 2012 - 05:33 PM

Couldn't you just have it periodically ping the main console and when the console doesn't get a ping after a amount of time it will think that the turtle is out of range and print that on the console (if that's what you want)

About turning off rednet, you would probably still need the rednet on so that it can know when it's in range

#3 Cozzimoto

  • Members
  • 221 posts
  • LocationDallas, Tx

Posted 31 August 2012 - 05:43 PM

wow thats a simple way to do it. lol =)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users