Hi im trying to make a smart turtle killing program. I need to get the sensors to report the players co-ords and i want the computer to print it too.
Thanks in advance
0
Help with OpenCCSensors
Started by dexter9, Apr 20 2013 05:55 AM
10 replies to this topic
#1
Posted 20 April 2013 - 05:55 AM
#2
Posted 20 April 2013 - 07:39 AM
Try using sensorview to examine the detailed output for the player target. This will tell you which table(s) you need to index. Then simply iterate through the targets returned by getTargets, determine which are players and which are not, and use getTargetDetails on the appropriate targets to fetch their details table (which you then index to get the position values).
#3
Posted 20 April 2013 - 07:41 AM
sorry how would that be as lua code? or how would i type it in. sorry im new to openccsensors..
#4
Posted 20 April 2013 - 07:52 AM
I don't exactly remember where in the tables all of this info actually is, so this code almost certainly won't work out of the box, but it should get you pointed in the right direction:
I don't know what the rest of your code looks like, so that's about all I have for you at this point. The rest should be fairly simple.
os.loadAPI("ocs/apis/sensor") local proxSense = sensor.wrap("left") for target in pairs(proxSense.getTargets()) do local detailedInfo = proxSense.getTargetDetails(target) if detailedInfo.whateverTellsUsItIsAPlayer == "player" then --you will need to look around and find whatever distinguishes players and non-players in the output. rednet.broadcast("Player! "..detailedInfo.name.." @ "..detailedInfo.Position.X..", "..detailedInfo.Position.Y..", "..detailedInfo.Position.Z) end end
I don't know what the rest of your code looks like, so that's about all I have for you at this point. The rest should be fairly simple.
#5
Posted 20 April 2013 - 08:03 AM
omg! That is actually a lot easier than i expected. thank you thank you thank you. Its going to be like a turtle infected type thing with the objective of blowing up the turtle factory inside a castle. Hope it turns out fun!
Thanks a lot!!!
Thanks a lot!!!
#6
Posted 20 April 2013 - 10:57 AM
Hi, sorry how would i receive it as in rednet.receive()?
#7
Posted 24 April 2013 - 08:55 AM
dexter9, on 20 April 2013 - 10:57 AM, said:
Hi, sorry how would i receive it as in rednet.receive()?
to send tables over rednet you have to use the textutils API and the function serialize() to convert them into a string. you recieve that string and unserialize() it on the other side where the msg has been recieved.. ie
events = os.pullEvent("modem") -- capture a modem event. tableOfOursWeWant = textutils.unserialize(events[4])e[4] should be the message in string form. i think that will depend upon your version of cc though because the functions for rednet functioning has been updated somewhat recently.
#8
Posted 07 June 2013 - 10:32 AM
Hello.
I want to write my own program to activate redstone signal during night and turn it off during day with help of "World" Open sensor, but the only documentation i could find is about proximity sensor
Can anyone point me in the right direction where to look for the rest of api commands to other sensors?
Any help would be much appreciated
I want to write my own program to activate redstone signal during night and turn it off during day with help of "World" Open sensor, but the only documentation i could find is about proximity sensor
Can anyone point me in the right direction where to look for the rest of api commands to other sensors?
Any help would be much appreciated
#9
Posted 07 June 2013 - 10:48 AM
azumi, on 07 June 2013 - 10:32 AM, said:
I want to write my own program to activate redstone signal during night and turn it off during day with help of "World" Open sensor, but the only documentation i could find is about proximity sensor
#10
Posted 07 June 2013 - 02:06 PM
oh, thanks i will use it.
But for future reference if i would like to use any OCS data from any sensor other than proximity how to do it?
But for future reference if i would like to use any OCS data from any sensor other than proximity how to do it?
#11
Posted 07 June 2013 - 02:18 PM
azumi, on 07 June 2013 - 02:06 PM, said:
But for future reference if i would like to use any OCS data from any sensor other than proximity how to do it?
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users