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

Proximity Sensor Basics

Started by gustavowizard, 30 June 2014 - 01:55 PM
gustavowizard #1
Posted 30 June 2014 - 03:55 PM
hey man, im trying to set a basic program to use with the Proximity Sensor of the openCCsensors mod, the code is so small i will just type it below:



os.loadAPI("ocs/apis/sensor")
m = peripheral.wrap("right")
prox = sensor.wrap("top")


while true do
moreDetails = prox.getTargetDetails( here i use put the coords of my targets but i dont know what to put here, since its a radius detection type)
m.setCursorPos(1,1)
m.write(moreDetails.Armour.Name) here i just want to show the name of the entity that i will summon on a close area, in front of the sensor (about 4 blocks)
end


so for example i want the sensor detecting the entities on the tank in front, i want its Name on the monitor, its simple, all i need to know is how to got the target here (would be a 3x3x3 area for example)

can you give me a hand?

thank you
Lyqyd #2
Posted 30 June 2014 - 06:33 PM
The proximity sensor's getTargetDetails doesn't use coordinates as its parameter. Like the other sensors, you use the key from the getTargets table of the thing you are interested in. Players use the player name and entities use the entity name concatenated with their entity ID. These are the IDs you can see on the left pane of sensorview when you are looking at the proximity sensor (run ocs/programs/sensorview if you haven't already).
gustavowizard #3
Posted 01 July 2014 - 04:45 AM
so i just use

moreDetails = prox.getTargetDetails(Entity)

?

i did not understand well what you mean by 'concatenated' lol my english is not 100% :D/>

btw im using your sensors massivelly on a huge typhoon soviet submarine that shoots real ICBMs im building, your sensors control the double-nuclear reactor, the missile inventory on the SLBM silos, the biology marine laboratory is what im trying to set now; would be a tank that when a squid or shark comes in, the monitor will diplay; creature on tank: squid hehe - im running out of ideas in how to fill the submarine, its really huge, it was made using the hull of this guy:

https://www.youtube.com/watch?v=LUoHLr4dAjg

i made all the interiors, programs and stuffs and im also using the direwolf20 button API - works nice with your sensors btw, i will give full credit to you guys when this project is done, im putting a lot of job on it i bet people will like it :D/>

almost forgot Lyqyd, could you take a look on my space station when u have some time? i would apreciate a lot your comments and sugestions :)/>

https://www.youtube.com/watch?v=kcziH5h-HYM&feature=youtu.be

it uses your sensors interacting with the galacticraft oxygen detectors, its working very nice now after i fix my rednet problems

thank you again
Lyqyd #4
Posted 01 July 2014 - 03:56 PM
Again, use the sensorview program to see what I mean. The names on the left are what you need to use as the argument to getTargetDetails.
gustavowizard #5
Posted 02 July 2014 - 07:43 PM
oh now i understand what u mean, but in this way the sensor will only recognise 1 species, like if i use shark, it wont detect a dolphin, so i must make 1 entrance for each entity specie i want the sensor to detect?

thanks

os.loadAPI("ocs/apis/sensor")
m = peripheral.wrap("right")
prox = sensor.wrap("top")


while true do
moreDetails = prox.getTargetDetails(Shark38739)
m.setCursorPos(1,1)
m.write(moreDetails.Armour.Name)
end

its giving me error on the Armour line for some reason
Lyqyd #6
Posted 02 July 2014 - 07:51 PM
You aren't going to be able to hard code the IDs like that, since they will change at least every chunk reload. You will need to use a getTargets call and then iterate the table, using the keys with a getTargetDetails call to figure out which one you care about based on its position, then look at the armor on the ones you care about.
gustavowizard #7
Posted 03 July 2014 - 11:52 PM
cool thanks bro