Posted 15 November 2012 - 12:17 PM

OpenCCSensors

Further information

A wiki page with full details, example code and recipes can be found here: http://www.computerc...e=OpenCCSensors

Changelog

Example code

-- load the API os.loadAPI("ocs/apis/sensor") -- wrap the sensor prox = sensor.wrap("left") -- get the targets local targets = prox.getTargets() -- loop through them for name, basicDetails in pairs(targets) do -- print their name print("Found entity: "..name) -- get more details about them local moreDetails = prox.getTargetDetails(name) -- print their health print("Health: "..moreDetails.Health) print("------") end

Media

Authors

Spoiler

Left/right arrow: select sensor side

Up/down arrow: select sensor target

Page up/down: scroll detailed view (if these do not work and you have NEI installed, make sure to close the NEI interface and try again)

S: save current detailed information

Q: quit

G: toggle graphing (requires monitor; advanced monitor suggested)

N: graph next numeric value (from detailed view list)

P: graph previous numeric value



Spoiler

The graph API exposes one method:



graph.new(target, updateFunction, valueText, gradientTable, min, max, sharedBounds) --target: a redirect table to output to, e.g. peripheral.wrap("top") for output to a monitor on top of the computer --updateFunction: a function that fetches new values. e.g. function update() local tab = sensor.call("right", "getTargetDetails", "-2,0,-1") return tab.Stored end --valueText: a string to display as the label for the value. --gradientTable: a table of colors to be used as the gradient, from lowest to highest, e.g. {colors.red, colors.orange, colors.yellow, colors.lime, colors.green} (default) --min: the minimum value of the graph (defaults to 0) --max: the maximum value of the graph (defaults to 1) --sharedBounds: used with multi-trace graphs. If true, all traces share the same bounds (defaults to false)

To use the multi-trace feature of the graphing API, provide an integer-indexed table of update functions and value texts as the input parameters rather than a single function and string, respectively. You can also provide a table of gradient tables, a table of minimums, and a table of maximums. Each trace will use its own update function, value text, and gradient table. If sharedBounds is passed as true, they will each use their own minimum and maximum as well.



Putting it all together:

--our output target mon = peripheral.wrap("top") --our update function function update() local tab = sensor.call("right", "getTargetDetails", "-2,0,-1") return tab.Stored end --our graph declaration. We use nil as the gradientTable parameter, so it will use the default red-green gradient. graphInstance = graph.new(mon, update, "EU Storage", nil, 0, 600000) while true do --update the graph graphInstance:draw() sleep(0.5) end The graph API exposes one method:To use the multi-trace feature of the graphing API, provide an integer-indexed table of update functions and value texts as the input parameters rather than a single function and string, respectively. You can also provide a table of gradient tables, a table of minimums, and a table of maximums. Each trace will use its own update function, value text, and gradient table. If sharedBounds is passed as true, they will each use their own minimum and maximum as well.Putting it all together:

Regarding mod packs: Please don't bother asking me/Cloudy/anyone for permission!. It's MIT. If you're using it for a mod pack, I'd love to know about it, but only purely out of personal interest. You're in no way required to tell us!Here are links to select older versions: 1.6.4.5 OpenCCSensors is an open source add-on mod for ComputerCraft which gives your computers the ability to retrieve information about the area around them.Some of you may remember CCSensors, which unfortunately didn't work well for multiplayer. We've taken that concept, simplified and rewritten it from the ground up for Minecraft 1.4.6 / 1.4.7 / 1.5.1.: Released 1.7.3, forgot to update changelog previously. Many bug fixes, update to MC 1.7.10/CC 1.65.: Released 1.6.4.0, fixed dropped item sensor.: Released 1.5.1.0, fixed sign sensor, increased support for CC 1.53: Released 0.1.5i, changed the behaviour of the sonic sensor: Released 0.1.5h, fixed a compatibility issue with ars magica: Released 0.1.5g, slight bug fix to sonic sensor: Added Crop Sensor Card, added proximity sensor block, random bug fixes: Released 0.1.5e. IC2 fixes, other random fixes.: Removed the mod-specific sensor cards. The functionality of these will be merged into other cards.Applied energistics is supported by the inventory sensorIndustrialcraft 2 is supported by the power and machine sensorUniversal Electricity is supported by the power sensor cardTooltips have been added into the inventory sensor cardBuildcraft not currently supported, Thaumcraft not currently supported.: Released 0.1.4c. Fixed an issue with console output. Added moon phase/angle info to the world sensor card (apparently helpful for bees): Released 0.1.4b. Applied Energistics sensor added, renderID removed from the config, added "IsChild" to the proximity sensor, fixed issues with the Sonic Sensor.: Released 0.1.4. Sonic sensor added, Inventory sensor can now read bee information, Issues related to Gauge lag improved, improved the information coming from buildcraft sensor. Factorisation barrel support.: Released 0.1.3. Support for Iron Tanks, Fixed issues related to buildcraft, Minecraft sensor improved, Proximity sensor now has pitch/yaw. Improved stability.The best way to show off what can be done using this mod is with videos:Cloudhunter, Mikeemoo, Orwell1984, Lyqyd, Nietsnie and others who've commited along the way (and if you're a modder, please get involved!)IRC: irc.esper.net #OpenCCSensorsControls for sensorview program:Graph API documentation: