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

[1.31] Turtle.detect gives id

Started by maarten1012, 10 March 2012 - 03:15 PM
maarten1012 #1
Posted 10 March 2012 - 04:15 PM
The function: turtle.detect() returns true or false, but wouldn't it be great so that it returns a block id for axample: turtle.return() returns the block id.

sry for bad english:)
Chlorek #2
Posted 11 March 2012 - 09:23 AM
There is now need to add next function like turtle.return(). Just turtle.detect() should return block ID, and if someone need to know is there anything or not, it's possible by:

local exist = turtle.detect()
if exist == 0 then
-- if there is air do something
else
-- there is any block and do sth
end
Sebra #3
Posted 11 March 2012 - 02:32 PM
It can be like that:
 -- use it as now:
if turtle.detect() then   --some block ahead
else --way clear
end
-- some new info:
detected, name, id, meta = turtle.detect()
if detected then -- other vars filled
  rednet.send(0,name.." ahead")
else -- other vars are nil
  result = turtle.forward() -- try to go
end
Pascal #4
Posted 12 March 2012 - 03:03 PM
when i use:


-- use it as now:
if turtle.detect() then   --some block ahead
else --way clear
end
-- some new info:
detected, name, id, meta = turtle.detect()
if detected then -- other vars filled
  print(name.." ahead") --error line
else -- other vars are nil
  result = turtle.forward() -- try to go
end


it's give a error: attempt to concatenate nil and string

please help…
Liraal #5
Posted 12 March 2012 - 03:09 PM
It is a suggestion how it should work, not how it actually works. turtle.detect() returns a boolean (true/false) value.
Mendax #6
Posted 15 March 2012 - 09:11 AM
Use the new turtle.compare() command.
Holofire #7
Posted 15 March 2012 - 07:13 PM
Turtle compare is good, but limited to the maximum of 9 to compare against (turtle inventory) Would be good a turtle.detect() is practicly useless.
passinglurker #8
Posted 15 March 2012 - 08:16 PM
block id's can be different for every installation it will be very unstable don't ask for block id's ask for more inventory space. also seeing the block ID is magic this is a tech mod.
Holofire #9
Posted 15 March 2012 - 08:22 PM
Well, the block id's wouldn't be hard coded necessarily, but maybe retrieved from the mods config file. Oh, and move invent space would be nice :D/>/>
passinglurker #10
Posted 16 March 2012 - 12:11 AM
its been shot down by dan or one of the forum staff since the introduction of turtles. compare is what you get be happy or code your own peripheral.
Advert #11
Posted 01 April 2012 - 01:16 AM
This won't happen, fortunately.