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

How To Use ccSensors

Started by theoriginalbit, 20 January 2013 - 03:29 AM
theoriginalbit #1
Posted 20 January 2013 - 04:29 AM
How to Use ccSensors ( Not to be confused with openCCSensors )
— By TheOriginalBIT and remiX

Over the past few weeks there has been a large increase in the amount of people wanting to use ccSensors in Tekkit to do something. There is however no one that has a fantastic idea of how to fully use the peripheral due to a lack of documentation. So here is a compilation of everything we (TheOriginalBIT and remiX) have found out through our own experiments and helping people on “Ask a Pro”.

What is required:
  • A ComputerCraft computer
  • A Sensor Controller
  • A Sensor
  • A Sensor Card ( World, Inventory, BuildCraft, IndustrialCraft, Forestry, RedPower2, Equivalent Exchange, Advanced Power Systems, Thaumcraft2, Proximity )
  • Transmitter card
Setup:

Firstly, make sure you have what is needed in the above ‘What is required’. When you do, place the computer down anywhere with a Sensor Controller attached to it - like this. The Sensor Controller can be attached at any side to the computer.

Then place a sensor near what you want to be reading that is also within a reasonable distance to the SensorController you want it to be used with.
Once that is done, insert a Blank Transmitter Card into the SensorController at the bottom right and click ‘Encode’ and remove the Transmitter Card from the SensorController. You will notice the Transmitter Card will change colours, which is meant to happen.

Now open up the Sensor and place the Transmitter Card which you encoded from the SensorController into the bottom most left slot of the Sensor. You will notice there is another open spot next to the Transmitter Card slot - this slot is for the Module. There is also a spot where you can name the sensor to make it easier to identify in your code and/or on a UI.

In order for this all to work how you want it to, you will need the correct SensorModule. Search ‘Sensor’ and find the correct one, and place it into the slot next to the Transmitter Card in the Sensor. You should notice information come up on the sensor according to which SensorModule you placed inside the Sensor.
An example setup can be found here.

Do notice the colours of the SensorController and the Sensor are the same? That means they are connected.

Coding For The Sensors:

There is a very limited amount of documentation for ccSensors that can be found here.

Finding the Sensor Controller

The first piece of code that we can use is to find out the side of the computer that the sensor controller is on. There are two methods of doing this; Using the peripherals API or using a function that ccSensors gives us to use. The ccSensors way is much easier, but both are detailed below:

ccSensors method:
local controllerSide = sensors.getController()


peripheral API method:

local function findSensorController()
for _,side in pairs( rs.getSides() ) do
   if peripheral.getType( side ) == “SensorController” then
	 return side
   end
end
end

local controllerSide = findSensorController()


Using either of these methods to find the sensor controller is acceptable and comes down to personal choice ( although I don’t know why you wouldn’t use the one line, ccSensors, method over the longer, peripherals API method ).

Getting the Controller’s Sensors

Next we must find all the sensors that the Sensor Controller is able to access and use. To do this we use the following function.
local sensorsList = sensors.getSensors( controllerSide )

If you wish to see all the sensors that the controller can access you can use the following code.

for _, v in pairs( sensors.getSensors( controllerSide ) do
print( v )
end


When we use the getSensors function it will return us a table containing all the names of the sensors that the controller can access ( NOTE: It has been discovered that in some SMP worlds that the names do not work and all sensors will have the name “Sensor”)

Getting the Sensor’s Probes

We now have a list of the sensors, now we need to get the probes for the sensors. There are various different probes for each sensor.

sensors.getProbes( controllerSide, sensorName )

To see a list of all the probes available to the sensors you can use the following code

for _, sensor in pairs( sensors.getSensors( controllerSide ) ) do
print( “Probes for the sensor: “..sensor )
for _, probes in pairs( sensors.getProbes( controllerSide, sensor ) ) do
   print( probes )
end
end


If there is a sensor in particular that you can extract it directly from the return of the getProbes function like so

local probes = sensors.getProbes( controllerSide, sensor )[3]


Getting the Probe’s Targets

Once we have the probe or probes we are after we must then get the targets for the sensor. These targets are the actual items or blocks ( or any data ) that is in the game that we are trying to display or gather information for. This information varies for each Sensor type. The data that you have access from the target can be found out by the following code

sensors.getSensorReadingAsDict( controllerSide, sensor, target, probe )


Getting Information About the Target

To get the information or data about a target we use the following code

sensors.getSensorReadingAsDict( controllerSide, sensor, target, probe )


This will return us a table containing all the data about a given target. We can then access this data and use it in the functioning of our program. An example to display the amount of energy, as power level and percentage, inside of an IC2 Power Storage device is as follows:

print( “Power level: “..data.energy..”/”..data.maxStorage )
print( “Percentage: “..( data.energy / data.maxStorage * 100 )..”%” )


As there are so many sensor types there is no way we are going to list all the data for each target. So that being said the following example will print out all the data available for all the available targets, in all the available sensors ( this is recommended for use when your trying to find that one particular piece of data )

for _,sensor in pairs( sensors.getSensors( controllerSide ) ) do
for _,probe in pairs( sensors.getProbes( controllerSide, sensor ) ) do
   for _, target in pairs( sensors.getAvailableTargetsforProbe( controllerSide, sensor, probe ) ) do
	 for k, data in pairs( sensors.getSensorReadingAsDict( controllerSide, sensor, target, probe ) ) do
	   print( k.." : "..tostring( data ) )
	 end
   end
end
end


Summary

Using the steps shown above a great deal can be learnt about ccSensors and in fact it is how I ( TheOriginalBIT ) actually first figured out how to use ccSensors and still use when helping people in “Ask a Pro” with their ccSensors issues. Actually this method is quite a good method to use to figure out how to use ANY peripheral, just go through step-by-step until you get to where you need

Making it Easier

If all of this so far still isn’t making much sense, or you’re just not sure what sensor to use, remiX has made a small script to make sensor selection MUCH easier, this can be found here, an image of it running here.

Further Examples:

IC2 Power Storage Levels — By TheOriginalBIT: http://pastebin.com/asSLPyqZ
IC2 Power Levels — By remiX: http://pastebin.com/1UqupYub
Proximity — By remiX: http://pastebin.com/jzwn2xPQ
Inventory Module — By remiX: http://pastebin.com/8QZzwre9
Player Detector — By TheOriginalBIT: http://pastebin.com/F9DwAFcn

Still Don’t Get It?

Feel free to leave a comment below asking us a question and we will try to answer it as best as we can :)/>
Edited on 30 April 2013 - 07:35 PM
Dlcruz129 #2
Posted 20 January 2013 - 06:43 AM
+1. Good job.
remiX #3
Posted 20 January 2013 - 11:53 AM
I hope people with problems with ccSensors come here first now :P/>
theoriginalbit #4
Posted 20 January 2013 - 11:55 AM
I hope people with problems with ccSensors come here first now :P/>
Hope so… If not at least we can just post this link to them :P/>
NLBlackEagle #5
Posted 20 January 2013 - 12:10 PM
Nice tutorial guys :)/> But I'm still sadly still not getting it, managed it this far:
Spoiler

With this code:
Spoilermon = peripheral.wrap("back")
while true do
mon.clear()
mon.setCursorPos(0,0)
shell.run("monitor","back","/ccSensors/dash_reactor","Sensor","Reactor")
sleep(1)
end

But yet, I cant get any code to work as it should work, So my question remains and I'm not asking to explain the whole thing bit by bit, I assume a tip wil be enough :)/>

[Question]
SpoilerIs there a possibility to get readings from a sensor and use this reading for a purpose.
Example:
if ccSensors/getReading/world/playercount:1 == true then
rs.setBundledOutput("back", 1)
sleep(1)
rs.setBundledOutput("back", 0)
end


And, here what i've tried (apologies for the messy code, assume I just dont get it)

local controllerSide = Sensors.getController()
sensors.getSensorReadingAsDict("left","Sensor","World,-1123,30,2134","WorldProbe")

Also tried: ("left",/Sensor/World,-1123,30,2134/WorldProbe) And many other combinations
And, ofcourse tried it using shell.run("/ccSensors/console/ And didnt came much furder then that
And yes, even more ways but it just does not seems to work somehow and I dont want to copy codes (which will probaly work) because I want to learn it for myself.

Thanks in advance :)/>


Hope so… If not at least we can just post this link to them :P/>


And, here is the result :)/>
theoriginalbit #6
Posted 20 January 2013 - 12:19 PM
Hope so… If not at least we can just post this link to them :P/>
And, here is the result :)/>
Its ok… It means we can improve the post a little to help people more… plus we do say this

Still Don’t Get It?
Feel free to leave a comment below asking us a question and we will try to answer it as best as we can :)/>

It does make it very hard when ccSensors developer left little to no documentation…


Also very good job with what you have done… seems like you have a problem with the reactor components showing nan ( not a number ) though…

Ok so now to the problem… It seems to me that your trying to use the World sensors to detect players… This is actually done using the proximity sensor… unfortunately I am not aware of any module that can tell you how many people are connected to the world… only how many are within the range of the sensor… ( can you confirm remiX? )
Using the proximity sensor you could get the targets for Players and then just use #tableTargetsStoredIn to get the count of the players… and of course you can then use this in any way you wish for example

if #targets > 5 then
  print( "There are heaps of people in range!" )
else
  print( "There are "..#targets.." in range." )
end
NLBlackEagle #7
Posted 20 January 2013 - 12:50 PM
@TheOriginalBIT

No problems with the reactor, wait Ill show you :)/>
Spoiler

I'm having trouble not explaining about all the functions this beast has, lets keep it short "this reactor is not nearly matched by any other found on youtube" Thats why I had to post that picture in the spoiler haha (Ill probaly make a tutorial/guide on this reactor, and I might appear in creative now but this was all survival made (took about a year to collect all the knowlegde and add it to the reactor) [Edit] tried something new, which caused my HV 4x ins cable vaporising, 2070eu/t how awesome is that XD

And, yes the problem.

Well, Its not needed to see all the players in the world I even dont want that to, only within the range of the sensor so some a warning sign will apear (for example a lamp with a sign above of the sensors location) This is so I know if anyone has been near my base.

So, for example: I have set up a circle of sensors around my base (far enough so noone in the base will trigger it) When a player comes along in his boat the sensor will notice this resulting in: PlayerCount:1
What i basicly want is a program which is connected to this sensor and emit a redstone current when he recieves "playercount:1"

A logical code would be: If shell.run("/ccSensors/console/ ???? /playercount:1") == true then
rs.setBundledOutput("bottom", 1)

Wich activates a lamp wich will stay on (using redpower) so when i come online I see a lamp and know someone has been within the radius of the sensor triggering the lamp


[Edit]

But yes, indeed "if #targets = > 1 then" is the correct example but I dont get the code which gets me to this point i can type the example :P/>
theoriginalbit #8
Posted 20 January 2013 - 01:03 PM
No problems with the reactor, wait Ill show you :)/>
I was just noticing that on the initial image that the % for coolant cells and such show "nan%"

Well, Its not needed to see all the players in the world I even dont want that to, only within the range of the sensor so some a warning sign will apear (for example a lamp with a sign above of the sensors location) This is so I know if anyone has been near my base.
Ok I was just clarifying to make sure that its defs not what you wanted to do…

But yes, indeed "if #targets = > 1 then" is the correct example but I dont get the code which gets me to this point i can type the example :P/>
Yes this is an example… give me a minute to throw something together as a better example…
theoriginalbit #9
Posted 20 January 2013 - 01:27 PM
Ok so using the program that remiX made under the "Making It Easier" heading I was able to determine that there is a bug with the proximity sensor… but we can work around that… :)/>

First you need to place down the sensors and computers with the proximity sensor module in the sensors.

Next using the code outlined in the OP you need to do the following
  1. Get the sensor
  2. Get the "Players" probe from the sensor ( note this will return ALL living entities :@ damn developers and their bugs )
  3. Get the targets that have the name "vq" so that we ONLY get the players ( this is the players class, I think its a bug in the ccSensors code where it doesn't say what the entity type is)
Thats it… if we find targets with the name "vq" then it means that we have found a player within the range of the sensors… all you do then is increment some variable to say that a player was detected… then have the computer turn on the redstone to turn on the light when that variable is not 0…

make sense?
NLBlackEagle #10
Posted 20 January 2013 - 01:40 PM
Ok so using the program that remiX made under the "Making It Easier" heading I was able to determine that there is a bug with the proximity sensor… but we can work around that… :)/>

First you need to place down the sensors and computers with the proximity sensor module in the sensors.

Next using the code outlined in the OP you need to do the following
  1. Get the sensor
  2. Get the "Players" probe from the sensor ( note this will return ALL living entities :@ damn developers and their bugs )
  3. Get the targets that have the name "vq" so that we ONLY get the players ( this is the players class, I think its a bug in the ccSensors code where it doesn't say what the entity type is)
Thats it… if we find targets with the name "vq" then it means that we have found a player within the range of the sensors… all you do then is increment some variable to say that a player was detected… then have the computer turn on the redstone to turn on the light when that variable is not 0…

make sense?


I will do some testing using shell.run("ccSensors/
Anyway, ima going to make a program now and come back with a complete code I assume there will be some errors in there and If not ill give some feedback because others might want to do this too, thanks for the help so far! (I will post another reply in about 10-15 minutes as I guess :)/> )

So, to answer your questions, yes it does make sense :)/>
NLBlackEagle #11
Posted 20 January 2013 - 02:42 PM
Ok, I have the feeling im on the good course heading for the solution :)/>
This is the code I've writed and instead of blank fields after reboot i actualy get a error now.

Well, here the code:

local controllerSide = sensors.getController
print("2")
local sensorName = "A1"
local WorldProbe = sensors.getProbes ("controllerSide",sensorName")
print("1")
local targets = sensors.getAvailableTargetsforProbe("controllerSide","sensorName","WorldProbe")


Error:

CraftOS 1.3
2
sensors:141: Invalid Side.
>_

So, something is wrong with ""local controllerSide = sensors.getController"" But what?

theoriginalbit #12
Posted 20 January 2013 - 03:12 PM
ok so a few issues here outlined below:

Firstly for the controllerSide variable you want to do this

local controllerSide = sensors.getController()
note the ( ) at the end… this is because sensors.getController is a function and we must call it… by not using the ( ) at the end you are in fact telling Lua that the controllerSide is a pointer to the sensors.getController in memory…

Second issue, when passing values to a function you do it like this, the first is a variable, the second is a string, 3rd is a number and 4th is a function pointer…

someFunction( someVariable, "some string", 3, someFunction )
Now in your case you are trying to pass variables, but you have surrounded them with " making them strings… remove the " from around the variables in the getProbes and getAvailableTargetsforProbe and it should be good :)/>
NLBlackEagle #13
Posted 20 January 2013 - 03:26 PM
ok so a few issues here outlined below:

Firstly for the controllerSide variable you want to do this

local controllerSide = sensors.getController()
note the ( ) at the end… this is because sensors.getController is a function and we must call it… by not using the ( ) at the end you are in fact telling Lua that the controllerSide is a pointer to the sensors.getController in memory…

Second issue, when passing values to a function you do it like this, the first is a variable, the second is a string, 3rd is a number and 4th is a function pointer…

someFunction( someVariable, "some string", 3, someFunction )
Now in your case you are trying to pass variables, but you have surrounded them with " making them strings… remove the " from around the variables in the getProbes and getAvailableTargetsforProbe and it should be good :)/>

local controllerSide = sensors.getController()
local sensorName = "A1"
local WorldProbe = sensors.getProbes (controllerSide,"sensorName")
local targets = sensors.getAvailableTargetsforProbe(controllerSide,sensorName,WorldProbe)

This seems to work (No errors but I still have a blanc screen, guess nothing should be appearing, lets add in the uhm playercount thing
theoriginalbit #14
Posted 20 January 2013 - 03:30 PM
local WorldProbe = sensors.getProbes (controllerSide,"sensorName")
Missed a set of quotes… should be

local WorldProbe = sensors.getProbes (controllerSide,sensorName)
Black screen was because the sensor with the name sensorName didn't exist and the peripheral is coded badly so crashes the computer instead of showing an error :/
NLBlackEagle #15
Posted 20 January 2013 - 03:37 PM
local WorldProbe = sensors.getProbes (controllerSide,"sensorName")
Missed a set of quotes… should be

local WorldProbe = sensors.getProbes (controllerSide,sensorName)
Black screen was because the sensor with the name sensorName didn't exist and the peripheral is coded badly so crashes the computer instead of showing an error :/

getting complicated haha, oh wait [Edit] seems computercraft.info has some bugs, instead of just local WorldProbe = sensors.getProbes (controllerSide,sensorName) I saw like ColourID1831728> [font=helvetica, arial etc in front of it
theoriginalbit #16
Posted 20 January 2013 - 03:42 PM
local WorldProbe = sensors.getProbes (controllerSide,"sensorName")
Missed a set of quotes… should be

local WorldProbe = sensors.getProbes (controllerSide,sensorName)
Black screen was because the sensor with the name sensorName didn't exist and the peripheral is coded badly so crashes the computer instead of showing an error :/

getting complicated haha, oh wait [Edit] seems computercraft.info has some bugs, instead of just local WorldProbe = sensors.getProbes (controllerSide,sensorName) I saw like ColourID1831728> [font=helvetica, arial etc in front of it
Yeh that was my fault I got lazy and copy pasted it from previous post, and when you do that inside code tags it removes all the formatting and changes them to code tags… sorry
NLBlackEagle #17
Posted 20 January 2013 - 04:06 PM
Ohh, no need to say sorry ya re helping me out pretty good. Im starting to understand but its like knowing how a bottle of beer looks like but not knowing the tast of it. So still having trouble with understanding everything. Anyway thanks for the tip about the () that will be usefull. But, im stuck again now with this:

local controllerSide = sensors.getController()
local sensorName = "A1"
local WorldProbe = sensors.getProbes (controllerSide,sensorName)
local targets = sensors.getAvailableTargetsforProbe(controllerSide,sensorName,WorldProbe)
local playerCount = ???

So, lets get this straight… with all those links, "targets" are the controller>sensor>probe>targets> ???
Guess thats what this code is? (not used to code like this and kinda unpractical for sutch a short code XD but thats my opinion, would come in handy with uhm my elevator! with around 50 rs.setoutputblabla strings for 3 floors so 150 >.<
But, guess the code is nearly done.

Anyway, if im correct you may give me the ''complete'' code/solution, because when you where talking about "vq" I didnt had a clue on how to put that into a code :P/>
Guess a complete code will explain a lot of things, and if I still dont understand it I could always ask and hope for an answer :P/>
theoriginalbit #18
Posted 20 January 2013 - 04:49 PM
Ohh, no need to say sorry ya re helping me out pretty good. Im starting to understand but its like knowing how a bottle of beer looks like but not knowing the tast of it. So still having trouble with understanding everything. Anyway thanks for the tip about the () that will be usefull. But, im stuck again now with this:

local controllerSide = sensors.getController()
local sensorName = "A1"
local WorldProbe = sensors.getProbes (controllerSide,sensorName)
local targets = sensors.getAvailableTargetsforProbe(controllerSide,sensorName,WorldProbe)
local playerCount = ???

So, lets get this straight… with all those links, "targets" are the controller>sensor>probe>targets> ???
Guess thats what this code is? (not used to code like this and kinda unpractical for sutch a short code XD but thats my opinion, would come in handy with uhm my elevator! with around 50 rs.setoutputblabla strings for 3 floors so 150 >.<
But, guess the code is nearly done.

Anyway, if im correct you may give me the ''complete'' code/solution, because when you where talking about "vq" I didnt had a clue on how to put that into a code :P/>
Guess a complete code will explain a lot of things, and if I still dont understand it I could always ask and hope for an answer :P/>

Without knowing exactly how your setup is I cant do a "complete" code to how you want it… but here is what I can do http://pastebin.com/S1wmCiw5 … this will scan all the living entites in the world (this is mobs too… but we can easily check if the name is "vq" and if it is count the players…

I think for what you want to do you will need to have a loop around this to constantly check… then at the end just use
if #players > 0 then
NLBlackEagle #19
Posted 20 January 2013 - 05:22 PM
startup:10: bad argument: table expected, got nil

Getting this error, (with the code you posted) Tried various ways to solve it but didnt worked

And yes, that exacly what I was planning to make :)/>
theoriginalbit #20
Posted 20 January 2013 - 05:27 PM
change line 3 to the name of the sensor to read… and if that fails just manually change "controllerSide" on line 1 to be "right" or what ever side the controller is on… that code definitely works… I tested a few times before posting it…
NLBlackEagle #21
Posted 20 January 2013 - 05:53 PM
Already had line 3 set to the name of the sensor and my bad didnt typed the whole error, its as following:

CraftOS 1.3
right
hello
Startup:10: bad argument: table expected, got nil

(seems that it reconises the controller on the right side (otherwise it wont print "right" )
Also reconised the sensorname "Hello"

Ahh, oh! Kidding me, I typed date instead of data! That was the error (was double checking) Finaly! it works :D/> Well, not totaly but "assume" the rest is easy :)/> Great! Really great, thanks man :)/>

But uhm, 0 players? But im there XD Within the range of the Sensor, well Ima going to test that tomorrow, thanks for your help man! And Ill give some feedback :)/>


[Edit]

Created a loop but the if #players > 0 then doesnt seems to work, or wel without the # the loop works but it does not check the ''how many players are here now"

Anyway, I'll continue tomorrow, im now going to sleep, Night man and thanks for your help!
theoriginalbit #22
Posted 20 January 2013 - 07:49 PM
Haha good to hear… typos suck sometimes… i type words funny sometimes too…

It rest is fairly easy… its just using the redstone api for the lights…

Hmmm odd. it was showing me with mine…

Ok until tomorrow :)/>
remiX #23
Posted 20 January 2013 - 10:32 PM
Ok so now to the problem… It seems to me that your trying to use the World sensors to detect players… This is actually done using the proximity sensor… unfortunately I am not aware of any module that can tell you how many people are connected to the world… only how many are within the range of the sensor… ( can you confirm remiX? )

Yeah, the proximity module detects living entities around the sensor. This does infact include cows, sheep, mobs which is a pain to filter to players! Even click on the 'players' probe shows animals :/

The player targets start with 'qr' or something. I'll quickly make a code to filter it to players removing mobs etc, and I'll check what the World module does :P/>

Edit:

Take this for example, proximity module is really buggy…

Here is a picture of it not showing my info


Here is a picture of it showing my info 2 seconds later, where I'm actually further away from the sensor…


I don't understand… lol
theoriginalbit #24
Posted 20 January 2013 - 11:19 PM
Ok so now to the problem… It seems to me that your trying to use the World sensors to detect players… This is actually done using the proximity sensor… unfortunately I am not aware of any module that can tell you how many people are connected to the world… only how many are within the range of the sensor… ( can you confirm remiX? )

Yeah, the proximity module detects living entities around the sensor. This does infact include cows, sheep, mobs which is a pain to filter to players!

The player targets start with 'qr' or something. I'll quickly make a code to filter it to players removing mobs etc, and I'll check what the World module does :P/>
Yeh I already did that :P/>
NLBlackEagle #25
Posted 21 January 2013 - 03:34 AM
Hello back guys,
Well I did some testing and it still does not seems to work which is kinda weird, I've put in the exact code as the one in the pastebin and it does not seems to work, well the first thing is that is says there are 0 people nearby the sensor without editting anything of the code, I've tested this with 2 players (Another person and me) When I reboot, no matter what I do it says this:

right
Hello
number of players: 0

(Hello is the sensor name so it is connected)

I've also tested the program with:

if #players > 0 then and if# players > 1 then (also tried if #players > 1 do and if #players > 0 do
rs.setBundledOutput("back", 1)
sleep(1)
rs.setBundledOutput("back", 0)

when i typed "do" instead of "then" it says "then" expected.

otherwise It keeps giving me this message: (when using "then")

startup:23: attempt go get length of number

So, what am I doing wrong?


[Edit] Also tried this in singleplayer, does not work either, bweh http://www.youtube.com/watch?v=34R4KfLmMSY

[When I figured it all out I might make a Tutorial on this]
theoriginalbit #26
Posted 21 January 2013 - 07:44 AM
otherwise It keeps giving me this message: (when using "then")

startup:23: attempt go get length of number
That is because in the example I wrote the number of players is already a number, so you don't need to have the # infront… The hash is only needed for string length and table length…
NLBlackEagle #27
Posted 21 January 2013 - 08:05 AM
Hmm, maybe because the controller isnt properly connected to the computer, the dots in the corners of the controller are red and when I logg out an in the Sensor reset its name back to ''Sensor"

Edit, i've checked the sensor out and it seems that its not vq but ahv
Could try that out
theoriginalbit #28
Posted 21 January 2013 - 08:12 AM
Hmm, maybe because the controller isnt properly connected to the computer, the dots in the corners of the controller are red and when I logg out an in the Sensor reset its name back to ''Sensor"

Edit, i've checked the sensor out and it seems that its not vq but ahv
Could try that out
Yeh I did have a note that on SMP the sensor name is Sensor. And it should be 'vq' since your running mc 1.2.5
NLBlackEagle #29
Posted 21 January 2013 - 08:18 AM
Thats weird, so i can only set up 1 sensor each controller combined with computercraft?
I mean, computer>controller>sensor.
If i add like 5 more sensors it wont know wich one to chooce if I do it on 1 controller XD
theoriginalbit #30
Posted 21 January 2013 - 08:27 AM
Thats weird, so i can only set up 1 sensor each controller combined with computercraft?
I mean, computer>controller>sensor.
If i add like 5 more sensors it wont know wich one to chooce if I do it on 1 controller XD
Multiple should work, and I say should because I've had them work, someone else couldn't get them to work.
NLBlackEagle #31
Posted 21 January 2013 - 09:16 AM
I just cant find the problem :(/> As you see there is a player nearby + me and the computer still does not detect them

Spoiler
Getalife #32
Posted 22 January 2013 - 01:45 AM
I also can't get the proximity module to work :(/>
remiX #33
Posted 22 January 2013 - 01:46 AM
Sorry if I missed if you said this, but is the World Module or Proximity Module?

I also can't get the proximity module to work :(/>

Yeah… I need more people to confirm that it's buggy or maybe I'm doing something wrong?
NLBlackEagle #34
Posted 22 January 2013 - 06:22 AM
Sorry if I missed if you said this, but is the World Module or Proximity Module?

I also can't get the proximity module to work :(/>

Yeah… I need more people to confirm that it's buggy or maybe I'm doing something wrong?

Somehow the code TheOriginalBIT posted in a pastebin didnt work for me ( http://pastebin.com/S1wmCiw5 ) I tried, and tried. The program does run but it does not detect any players. There is one last thing I could do and thats testing it in singleplayer. Or is there another way to get it to work? Another code which might does work?

And I tried both the World Module and the Proximity Module. Either does not work with this code =P All I want to get is a redstone signal when someone comes near to a certain point
remiX #35
Posted 22 January 2013 - 07:28 AM
This works with World Module.

Spoiler

controllerSide = sensors.getController()

if not controllerSide then
	print("No CCsensor controller found.")
	return
end

function select( x, y, title, tData )
	local function writeAt(xPos, yPos, text)
		term.setCursorPos(xPos, yPos)
		write(text)
	end
	
	writeAt( x, y, title..": "..#tData )
	
	for i, text in pairs(tData) do
		writeAt( x + 2, y + 1 + i, text )
	end
	
	local sel = 1
	writeAt( x + 1, y + 1 + sel, "*")
	while true do
		_, key = os.pullEvent("key")
		writeAt( x + 1, y + 1 + sel, " ")
		if key == 200 then
			-- Up
			sel = sel - 1
		elseif key == 208 then
			-- Down
			sel = sel + 1
		elseif key == 28 then
			-- Enter
			return tData[sel]
		end
		if sel < 1 then sel = #tData 
		elseif sel > #tData then sel = 1 end
		
		writeAt( x + 1, y + 1 + sel, "*")
	end
end

term.clear()
Sensors = sensors.getSensors(controllerSide)
dataSensor = select( 1, 1, "Select the correct sensor", Sensors )
dataProbe = "WorldProbe"

while true do
        Targets = sensors.getAvailableTargetsforProbe( controllerSide, dataSensor, dataProbe )
	readings = sensors.getSensorReadingAsDict( controllerSide, dataSensor, Targets[1], dataProbe)
	term.setCursorPos(1, 1)
	term.clear()
	print("Current World Player Count: " ..readings.PlayerCount)
	sleep(5)
end

I tested it and it works on SSP. Not sure about SMP. Although, I'm unsure it will update when a player joins (i haven't tested that), but I'm sure it will…
NLBlackEagle #36
Posted 22 January 2013 - 08:05 AM
Thanks man! I'll test it out straight away :)/> If it wont work im afraid there is something wrong with the server settings/files as we experienced before with the redpower computers. (the earlier version) Altough its fixed now due a new instal of them and replacement to another IP adress, kinda weird. Anyway I will give some feedback as soon im done with uhm, copying yes :P/>
NLBlackEagle #37
Posted 22 January 2013 - 08:30 AM
bios:33: bad argument: string expected, got nil

– up
sel = sel - 1
elseif key == 208 then
– down
sel = sel - 1
elseif key == 28 then
– Enter
return tData[sel]
end
if sel < 1 then sel = #tData
elseif sel > #tData then sel = 1 end

Bios:33: not for shure if it ments string 33, anyway "end" is on string 33



Solved, made an mistake! Ok, lets check it out.


Ahh, got my next error but I assume that i need to put in the coordinates? Ypos, xpos?

Guess here: "local function writeAt(xPos, yPos, text)"
anyway, this is the error i get:


( After pressing "Enter" on "*Sensor")


Spoiler
remiX #38
Posted 22 January 2013 - 06:23 PM
Hm.. The code as is should work (it did for me). No adjustments need to made but just set up the world module in the sensor.
NLBlackEagle #39
Posted 23 January 2013 - 05:38 AM
You mean change the name of the sensor to module?

[Edit] Oh nevermind misreaded it.

[Edit]

Well, here is the picture of it but it still gives the same error :P/>


Spoiler


Tried it on singleplayer, now it says startup 50 attempt to call nil.

Thats the setCursorPos string, really weird. Well, might I ask you one last fafour? Could you join the server and check it out for yourself? if that doesnt does the trick then its game over for ccSensors
theoriginalbit #40
Posted 23 January 2013 - 11:23 AM
You sure I can jump on and try to fix… Give me about an hour (got some other stuff need to do around house) and pm the IP…
NLBlackEagle #41
Posted 24 January 2013 - 12:44 AM
Thanks for all the help guys! Glad to have it solved, now I could set up a defence line and maybe even make a showoff video with the link to this topic on youtube :)/>
remiX #42
Posted 26 January 2013 - 06:19 AM
I'm curious to know what the problem was, do tell :P/>
theoriginalbit #43
Posted 26 January 2013 - 01:30 PM
His sensor was actually picking up players as EntityPlayer not vq. So I added a check for both in the code. Fixed it in op code too.
Mordokk #44
Posted 26 February 2013 - 08:23 PM
Hello, my question is more about commands i need to do this – (other then commands already covered in this thread and in the "inventory Module — By remiX: http://pastebin.com/8QZzwre9")

I have a large factory and sorting setup, I would like the inventory sensors to detect whats in the chests and display the total of each item on a monitor. which either updates constantly or just every minute if that's easier with a wait loop.

The sorting system is large and will require several sensors, so it needs to detect all items in several chests and then just list the total of each type of item instead of just listing each 64 stack. Any examples of something like this out there? i've been searching but not having any luck.

*edit* so i'm just looking for a short example i can build from that gets item counts, adds it together and then displays it, keeping the total updated as it changes.
theoriginalbit #45
Posted 28 February 2013 - 02:19 AM
- snip -
The commands you need to do this is really all in the 'Inventory Module' by remiX. As for a snippet, well there really cant be anything better than that code too.

The main point is to loop through the chests and count items with the same identifier. this can be achieved easily with tables. take a look at the PIL for more on tables.
ItsRodrick #46
Posted 17 July 2013 - 09:16 PM
Cool! Now I can see my MFSU' status by a monitor… :D/>