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

Concept: Line of Sight Addon (scanners) and also Dwarf Fortress

Started by funkey100, 24 January 2014 - 11:26 PM
funkey100 #1
Posted 25 January 2014 - 12:26 AM
I was wondering this. How can you make a line of sight script? It's less complex in Minecraft with blocks. Let's say, you (or a object) are (is) at x, y, z and you want to know the blocks you could see. You do this function and it returns a list of coordinates of all the blocks you can see. How? One method is multiplying the coords by 2. So instead of block a as 1, 1, 1 and block b as 2, 2, 2 you would have block a as 8 different blocks (one for each corner), since it would span from 1, 1, 1 to 2, 2, 2. Block b would span from 3, 3, 3 to 4, 4, 4. You now have block corners. You could draw lines from your coords to it's 4-5 outer corners (depending on it's orientation to you) and any blocks inside that area wouldn't be counted. But this is very, very complicated and where does it start? Any ideas? Thanks!

This is eventually going to lead to a scanner which gets the coords for every block in it's line of sight and gives you their coords (relative to you, you first tell the turtle it's position first and then it'll remember it's translations) and what they are. I then can make a turtle have this a link it with a computer where you can command it, see a digital map it's built (in Dwarf Fortress style) and maybe even designate areas for it to build/mine. Wait… This is pretty much Dwarf Fortress for Minecraft… I just had the best idea… Multiple turtles. Turtles=dwarfs. Command them. Mine, build and craft. Extremely awesome and hard.

Back to the scanner. You could upload this map on your portable computer and if you scanned the surface know where everything is in 3D. Is this the right place to post?
Edited on 24 January 2014 - 11:30 PM
CometWolf #2
Posted 25 January 2014 - 04:13 AM
Why would you need line of sight for this? Just make it a grid, and you'll know where the blocks are.
oeed #3
Posted 25 January 2014 - 04:19 AM
I don't really think line of sight is the best way of doing this. I've thought about 3D mapping with turtles before and I think the best way would be to basically collision test every surface within, say, 100 blocks.
funkey100 #4
Posted 25 January 2014 - 04:19 PM
That's not what I meant. I meant an addon or mod that adds a scanner for turtles which tells the turtle what each block it can see is. For that, I'll need a script that calculates which blocks it can see and returns them.Then, for example, you could work out the shape of a room and what's in it. So much faster and easier than going to each and every block and seeing what they are. CometWolf, the line of sight is for realism. Not just a command that gives you what every block is in a 100 block radius. And I'll put the LoS results into a grid. oeed, I'm not talking about a method but about a mod or addon.
CometWolf #5
Posted 25 January 2014 - 04:32 PM
Isn't there or atleast used to be a sensor that was just this, minus the line of sight in, openCCSensors?
funkey100 #6
Posted 25 January 2014 - 04:57 PM
Nope.
CometWolf #7
Posted 25 January 2014 - 05:14 PM
Yes there is.
Sonic sensor
http://www.computercraft.info/wiki/OpenCCSensors
oeed #8
Posted 25 January 2014 - 06:19 PM
I think you'd basically have to render the Minecraft world to do that. Not easy, but take a look at GopherAlt's 3D rendering engine.
funkey100 #9
Posted 25 January 2014 - 06:42 PM
CometWolf, that gets blocks in a radius, not LoS and sees if they're liquid or solid. It doesn't get the blocks in your LoS and tells you what they are.
oeed, thanks, I'll take a look at that.