Difference between revisions of "CcSensors"
From ComputerCraft Wiki
(Created page with " == Peripheral: ccSensors == ccSensors is an addon which adds sensors to ComputerCraft. it provides readings from the MC surrounding to lua programs. a reading can be a va...") |
|||
| (19 intermediate revisions by 14 users not shown) | |||
| Line 1: | Line 1: | ||
| + | {{Outdated|reason='''This mod is 1.2.5 ONLY! It is very out-of-date!''' Documentation is ripped from source code. Information is provided "as-is" with no guarantee of accuracy.}} | ||
| + | {{DISPLAYTITLE:ccSensors}} | ||
| + | '''ccSensors''' is a user created peripheral by Yoskaz01, which adds sensors to ComputerCraft. It provides readings from the Minecraft surroundings to lua programs. | ||
| + | A reading can be a value a simple as Light level, a isRaining, isDay or as complex as the content of a chest or the temperature of IC2 reactor. | ||
| − | == | + | ==Getting Started== |
| + | # place a Sensor Controller next to a computer | ||
| + | # open the sensor Controller GUI and hit the "New" button to register a new freq | ||
| + | # place blank transmitter card in the slot and click "Encode Transmitter" to get an encoded transmitter to be used with the remote sensor. | ||
| + | # Place a Remote Sensor (can be placed anywhere) and put the transmitter card in the bottom slot. (you can rename the Remote Sensor from the default name "Sensor") | ||
| + | # Place a SensorModule card into the top slot. | ||
| + | # open the computer terminal and run: /ccSensors/console to run the sample console program. That's it - you now have a working sensor connected to a computer :) | ||
| − | + | ==API: sensors== | |
| + | Note: Documentation is ripped from source code. Information is provided "as-is" with no guarantee of accuracy. | ||
| + | <!-- ################################################################# | ||
| − | + | TO MOD AUTHOR: | |
| − | + | If you fix up the docs, please remove the above sentence. | |
| + | Thank you. | ||
| + | ~~~~ | ||
| + | ############################################################## --> | ||
| + | {| class="sortable" border="1" cellpadding="2" cellspacing="0" | ||
| + | !style="background:#EEE" width="200px"|Method name | ||
| + | !style="background:#EEE" width="*"|Description | ||
| + | |- | ||
| + | |getVersion() | ||
| + | |sensorAPI version | ||
| + | |- | ||
| + | |getPeripherals() | ||
| + | |returns a dict of attached peripherals : SensorController,monitor,modem | ||
| + | |- | ||
| + | |getController() | ||
| + | |return the side the first controller is attached at | ||
| + | |- | ||
| + | |rIterator( table ) | ||
| + | |Intended for internal use only. | ||
| + | |- | ||
| + | |tabtodict( table ) | ||
| + | |Intended for internal use only. | ||
| + | |- | ||
| + | |getReadingAsTable( side, sensor, ... ) | ||
| + | |return sensor reading as a table instead of a dict | ||
| + | |- | ||
| + | |setTarget( side, sensor, target ) | ||
| + | |set the active target for a given sensor | ||
| + | |- | ||
| + | |setSensorRange( side, sensor, range ) | ||
| + | |set the sensor range (as long is <= max_sensor_range) | ||
| + | |- | ||
| + | |getAvailableReadings( side, sensor ) | ||
| + | |returns names of all readings available for a given sensor | ||
| + | |- | ||
| + | |setActiveReading( side, sensor, reading ) | ||
| + | |set the active reading to be used when getReading is called | ||
| + | |- | ||
| + | |getAvailableTargets( side, sensor ) | ||
| + | |returns the available targets for a given sensor | ||
| + | |- | ||
| + | |getAvailableTargetsforProbe( side, sensor, probe ) | ||
| + | |UNDOCUMENTED | ||
| + | |- | ||
| + | |getAvailableTargetsforProbe2( side, sensor, probe ) | ||
| + | |UNDOCUMENTED | ||
| + | |- | ||
| + | |getProbe( side, sensor ) | ||
| + | |returns a table of the available probes (eg: TargetInfo, LivingEntities, Players) | ||
| + | |- | ||
| + | |getSensorInfo( side, sensor, ... ) | ||
| + | |returns the following information for a given sensor: | ||
| + | cardType, ActiveReadingID, Distance, Name, ActiveReading, ShortName, SensorRange, yCoord, zCoord, xCoord | ||
| + | <!-- | ||
| + | old values from someone else | ||
| + | cardType,name,activereading,activereadingid,distance,location,methods,SensorRange | ||
| + | --> | ||
| + | |- | ||
| + | |getSensorInfoAsTable( side, sensor, ... ) | ||
| + | |same as getSensorInfo, except as a table | ||
| + | |- | ||
| + | |getReading( side, sensor, ... ) | ||
| + | |returns sensor reading in a dict of reading,value pairs | ||
| + | |- | ||
| + | |getReading2( side, sensor, probe, target, ... ) | ||
| + | |returns sensor reading in a dict of reading,value pairs | ||
| + | |- | ||
| + | |getSensors( side ) | ||
| + | |returns the names of all connected sensors | ||
| + | |- | ||
| + | |getSensorReadingAsDict(side,sensor,target,probe,...) | ||
| + | |get a reading while setting the target and reading type for a given sensor. returns a dictionary [working] | ||
| + | |- | ||
| + | |getSensorReadingAsDict2(side, sensor, probe, target, ...) | ||
| + | |Alias for getReading2 | ||
| + | |- | ||
| + | |getSensorReadingAsTable( side, sensor, target, reading, ...) | ||
| + | |get a reading while setting the target and reading type for a given sensor | ||
| + | |- | ||
| + | |getItemInfo(name,content) | ||
| + | |return item info from an inventory dictionary | ||
| + | |- | ||
| + | |getItemsInfo(names,content) | ||
| + | |returns a dict for each item in the given names table with .dmg and .qty | ||
| + | |} | ||
| − | + | == External links== | |
| − | - | + | *[http://www.computercraft.info/forums2/index.php?/topic/126-mc-125-cc-133-ccsensors-smpssp/ ccSensors]—ComputerCraft Forum Thread |
| − | - | + | |
| − | + | [[Category:User Created Peripherals]] | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
Latest revision as of 06:15, 9 December 2012
ccSensors is a user created peripheral by Yoskaz01, which adds sensors to ComputerCraft. It provides readings from the Minecraft surroundings to lua programs.
A reading can be a value a simple as Light level, a isRaining, isDay or as complex as the content of a chest or the temperature of IC2 reactor.
Getting Started
- place a Sensor Controller next to a computer
- open the sensor Controller GUI and hit the "New" button to register a new freq
- place blank transmitter card in the slot and click "Encode Transmitter" to get an encoded transmitter to be used with the remote sensor.
- Place a Remote Sensor (can be placed anywhere) and put the transmitter card in the bottom slot. (you can rename the Remote Sensor from the default name "Sensor")
- Place a SensorModule card into the top slot.
- open the computer terminal and run: /ccSensors/console to run the sample console program. That's it - you now have a working sensor connected to a computer :)
API: sensors
Note: Documentation is ripped from source code. Information is provided "as-is" with no guarantee of accuracy.
| Method name | Description |
|---|---|
| getVersion() | sensorAPI version |
| getPeripherals() | returns a dict of attached peripherals : SensorController,monitor,modem |
| getController() | return the side the first controller is attached at |
| rIterator( table ) | Intended for internal use only. |
| tabtodict( table ) | Intended for internal use only. |
| getReadingAsTable( side, sensor, ... ) | return sensor reading as a table instead of a dict |
| setTarget( side, sensor, target ) | set the active target for a given sensor |
| setSensorRange( side, sensor, range ) | set the sensor range (as long is <= max_sensor_range) |
| getAvailableReadings( side, sensor ) | returns names of all readings available for a given sensor |
| setActiveReading( side, sensor, reading ) | set the active reading to be used when getReading is called |
| getAvailableTargets( side, sensor ) | returns the available targets for a given sensor |
| getAvailableTargetsforProbe( side, sensor, probe ) | UNDOCUMENTED |
| getAvailableTargetsforProbe2( side, sensor, probe ) | UNDOCUMENTED |
| getProbe( side, sensor ) | returns a table of the available probes (eg: TargetInfo, LivingEntities, Players) |
| getSensorInfo( side, sensor, ... ) | returns the following information for a given sensor:
cardType, ActiveReadingID, Distance, Name, ActiveReading, ShortName, SensorRange, yCoord, zCoord, xCoord |
| getSensorInfoAsTable( side, sensor, ... ) | same as getSensorInfo, except as a table |
| getReading( side, sensor, ... ) | returns sensor reading in a dict of reading,value pairs |
| getReading2( side, sensor, probe, target, ... ) | returns sensor reading in a dict of reading,value pairs |
| getSensors( side ) | returns the names of all connected sensors |
| getSensorReadingAsDict(side,sensor,target,probe,...) | get a reading while setting the target and reading type for a given sensor. returns a dictionary [working] |
| getSensorReadingAsDict2(side, sensor, probe, target, ...) | Alias for getReading2 |
| getSensorReadingAsTable( side, sensor, target, reading, ...) | get a reading while setting the target and reading type for a given sensor |
| getItemInfo(name,content) | return item info from an inventory dictionary |
| getItemsInfo(names,content) | returns a dict for each item in the given names table with .dmg and .qty |
External links
- ccSensors—ComputerCraft Forum Thread