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

OpenCCSensors programming help

Started by 1337patchy, 08 March 2013 - 11:28 AM
1337patchy #1
Posted 08 March 2013 - 12:28 PM
Title: OpenCCSensors programming help

Hello everyone.
Unfortunately I cannot find documentation about this.
I would like to have a code which would retrieve info from the world sensor, such as the weather and the time of the day. Also light level if possible.
But I just can not find documents which tell us how to code in order to operate the sensors, I have no idea how to start, or what to write in the code.
A little help or a heads up please, thank you in advance! ;)/>
OmegaVest #2
Posted 09 March 2013 - 04:45 AM
Well, if you look through the thread for OpenCCSensors, there is sporadically documentation.

Otherwise, build one, hook it up to a computer, then wrap it (worldSen = peripheral.wrap(side)) Then do this to find out its functions:


for k, v in pairs(worldSen) do
   print(k)
end


That should be a good place to start. I don't know enough about it to tell you what those functions might be. But, if all else fails, just plomp a function into the lua prompt and see what it does!
Lyqyd #3
Posted 09 March 2013 - 05:27 AM
There is a whole swath of documentation in the first post of the topic. On your computer with the sensor attached, run `ocs/programs/sensorview` and take a look at the detailed info for your sensor. That information represents the content of a table returned by one of the sensor's functions. For instance, you might look for the `Raining` field. You'd then need to retrieve that table and look up the value of `Raining` in your code:


os.loadAPI("ocs/apis/sensor")
local worldSensor = sensor.wrap("left")
local details = worldSensor.getTargetDetails("CURRENT")
print(details.Raining)
1337patchy #4
Posted 10 March 2013 - 11:34 AM
Thanks all, I am no Pro at this. Will take a look at it now, Appreciate everyone's help, will report soon.