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

GPS API Question

Started by Whispering, 23 June 2013 - 11:17 PM
Whispering #1
Posted 24 June 2013 - 01:17 AM
I want to know if i'm able to tell a turtle where is its max y, like, "you can't go higher then y 64", please help me
Lyqyd #2
Posted 24 June 2013 - 01:10 PM
Split into new topic.

Yes, it is possible to do that.
Bomb Bloke #3
Posted 24 June 2013 - 07:07 PM
local x,y,z

local function up()
  if y<65 then
    while not turtle.up() do end
    y = y + 1
  else
    print ("Can't go any higher!")
  end
end

-- Get GPS position here, store it in x/y/z.

-- From here on, use "up()" instead of "turtle.up()".

You would need a somewhat similar function for downward movement, to 1) ensure each movement is successful and 2) update the value of "y".
Zudo #4
Posted 25 June 2013 - 03:32 AM
The gps api is really underused, I bet dan would remove it soon.
apemanzilla #5
Posted 25 June 2013 - 07:06 AM
The gps api is really underused, I bet dan would remove it soon.
It's not that it's underused, it's that it's less well known. And why would Dan remove it? It's not causing any problems… That's like removing the colors API because you can use numbers instead.
theoriginalbit #6
Posted 25 June 2013 - 12:26 PM
The gps api is really underused, I bet dan would remove it soon.
Definitely not! If he removed it, it would require people to be able to write an algorithm to calculate their own trilateration, something that people would not be able to do easily… it won't be removed!
Saying it will be removed is akin to saying that he will remove the vector API because not many people used it… the aim of the CC developers is to KEEP support in, not remove it, that is why we have this awesome function in the latest versions of CC


local bRunning = false
function run()
  if bRunning then
	error( "rednet is already running" )
  end
  bRunning = true
  while bRunning do
	local sEvent, sSide, sChannel, sReplyChannel, sMessage, nDistance = os.pullEventRaw( "modem_message" )
	if sEvent == "modem_message" and isOpen( sSide ) and (sChannel == os.getComputerID() or sChannel == CHANNEL_BROADCAST) then
	  os.queueEvent( "rednet_message", sReplyChannel, sMessage, nDistance )
	end
  end
end