196 posts
Location
Norway
Posted 17 May 2013 - 07:53 PM
If you ever wanted your turtle to see a bit. There is a method to make the turtle able to see whether a block is transparant or not, by using redstone logic
Turtle code:
rs.setOutput(side,true)
isSolid = rs.getInput(side)
if isSolid then
--Do stuff
end
1619 posts
Posted 17 May 2013 - 08:15 PM
Pretty neat little trick.
196 posts
Location
Norway
Posted 17 May 2013 - 08:38 PM
Thank you
570 posts
Location
Germany
Posted 18 May 2013 - 01:31 AM
Looks nice! But I would like it more as a function:
function isSolid()
rs.setOutput(side,true)
local issolid = rs.getInput(side)
rs.setOutput(side, false)
return issolid
end
if isSolid() then
--Do stuff
end
Note that I just coded that quickly in my browser and didn't tested it so I can't guarantee that it works
1054 posts
Posted 18 May 2013 - 11:46 AM
Looks nice! But I would like it more as a function:
function isSolid()
rs.setOutput(side,true)
local issolid = rs.getInput(side)
rs.setOutput(side, false)
return issolid
end
if isSolid() then
--Do stuff
end
Note that I just coded that quickly in my browser and didn't tested it so I can't guarantee that it works
If you put this in a function, you'd better pass the 'side' variable as argument:
function isSolid(side)
rs.setOutput(side,true)
local isSolid = rs.getInput(side)
rs.setOutput(side, false)
return isSolid
end
if isSolid('left') then
--Do stuff
end
But really, making a function for this nifty snippet is the obvious part.
1522 posts
Location
The Netherlands
Posted 18 May 2013 - 11:49 AM
I really like this! It can help in certain environments!
570 posts
Location
Germany
Posted 18 May 2013 - 11:56 AM
But it doesn't excactly tell if a block is solid: if you use redstone it says it is solid, but redstone isn't solid
620 posts
Location
Holland
Posted 18 May 2013 - 12:15 PM
I love this!
1054 posts
Posted 18 May 2013 - 12:15 PM
Redstone dust is obviously the only exception as it always conducts redstone power. But you rarely encounter redstone dust in the wild.
620 posts
Location
Holland
Posted 18 May 2013 - 12:43 PM
This doesn't work if the block is already powered by a different thing like a lever
1522 posts
Location
The Netherlands
Posted 18 May 2013 - 12:55 PM
This doesn't work if the block is already powered by a different thing like a lever
Of course not, because it can transmit redstone then! :D/>
So it is a solid block! :P/>
620 posts
Location
Holland
Posted 18 May 2013 - 01:22 PM
oh haha
620 posts
Location
Holland
Posted 18 May 2013 - 01:31 PM
Hmm glass and glowstone won't work either or do we count them as non-solid
1054 posts
Posted 18 May 2013 - 01:48 PM
Hmm glass and glowstone won't work either or do we count them as non-solid
Technically they are solid. I think this snippet actually returns true for non-transparent blocks.
196 posts
Location
Norway
Posted 18 May 2013 - 03:54 PM
Blocks like: glass, water, rails, half-slabs, leves. etc. Counts as transparent and will return false, other type of blocks will give true if anyone was a bit confuced :)/>
570 posts
Location
Germany
Posted 18 May 2013 - 03:59 PM
redstone isnt the only exception, redstone torches/levers and some other stuff can even give multiple results depending on the state of them
1054 posts
Posted 18 May 2013 - 04:11 PM
redstone isnt the only exception, redstone torches/levers and some other stuff can even give multiple results depending on the state of them
Tricks like this (and most others) are only useful in natural or controlled environments.
This reminds me of another trick I discovered once. It's a method to detect if a block in front of the turtle is water or not (without a bucket, but with a mining turtle):
function isWater()
return not turtle.detect() and turtle.dig()
end
This worked at least with CC 1.33. I haven't tested it since.
1522 posts
Location
The Netherlands
Posted 18 May 2013 - 04:26 PM
-snip-
The snipper works beautifully. I have just tested it :P/>
Thank you!