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

CCSensors D:

Started by Sane, 19 December 2012 - 03:46 PM
Sane #1
Posted 19 December 2012 - 04:46 PM
This is the 2nd help topic I've posted today, sorry.

Anyways, I'm having a LOT of trouble with CCSensors. I don't understand the API at all, I'm trying to get the information for a condenser's current emc etc and what item it is making. Is this possible? If so can someone please explain how I could go about this?
cmurtheepic #2
Posted 19 December 2012 - 05:56 PM
well it is not really possible to work with the equivalent exchange module using CCsensors because it is a IC2 an other mods peripheral :(/>
but I really can't help you with CCsensors I don't know much about it myself.
oh and hit the up bottom on the lower right corner of this comment :)/>
Zamithal #3
Posted 19 December 2012 - 06:13 PM
If your using tekkit/technic, there is a EE Sensor Module (I assume its there if you don't use tekkit too) That can get you the current EMC Here is my code for it

----------------------getEMCInformation-----------------------------------
ctrl = sensors.getController() -- set the Sensor Controler's data
data = sensors.getSensors(ctrl) -- Find and access the Sensor Controler, bring up all avaiable sensors.
EMC = data[3] -- The EE Sensor Module is thrid on the list, pick it, make note of it.
data = sensors.getProbes(ctrl,EMC) -- Bring up a list of avalable options (TargetInfo, Collector, Furnace ect.)
EMCProbe = data[2] -- Pick #5 Because we are using a condesor
data = sensors.getAvailableTargetsforProbe(ctrl,EMC,EMCProbe) -- Get available blocks
EMCPos = data[1] -- Select the first condensor seen
data = sensors.getSensorReadingAsDict(ctrl,EMC,EMCPos,EMCProbe) -- GET THE DATA!!
---------------------printEMC--------------------------
print(data.displayEnergy) -- Print the current reading to the screen
Im fairly new at this so this is probably not the correct way to do it, but it works…

As for the checking items thing, do the same process and use a Inventory Sensor Module instead..

PS. Put this at the top of your code

function printDict(data)
for i,v in pairs(data) do
  print(tostring(i).." - "..tostring(v))
end
end
and then use printDict(data) whenever your not sure what data[x] your supposed to pick, its helped me lots!
Sane #4
Posted 20 December 2012 - 09:04 AM
If your using tekkit/technic, there is a EE Sensor Module (I assume its there if you don't use tekkit too) That can get you the current EMC Here is my code for it

----------------------getEMCInformation-----------------------------------
ctrl = sensors.getController() -- set the Sensor Controler's data
data = sensors.getSensors(ctrl) -- Find and access the Sensor Controler, bring up all avaiable sensors.
EMC = data[3] -- The EE Sensor Module is thrid on the list, pick it, make note of it.
data = sensors.getProbes(ctrl,EMC) -- Bring up a list of avalable options (TargetInfo, Collector, Furnace ect.)
EMCProbe = data[2] -- Pick #5 Because we are using a condesor
data = sensors.getAvailableTargetsforProbe(ctrl,EMC,EMCProbe) -- Get available blocks
EMCPos = data[1] -- Select the first condensor seen
data = sensors.getSensorReadingAsDict(ctrl,EMC,EMCPos,EMCProbe) -- GET THE DATA!!
---------------------printEMC--------------------------
print(data.displayEnergy) -- Print the current reading to the screen
Im fairly new at this so this is probably not the correct way to do it, but it works…

As for the checking items thing, do the same process and use a Inventory Sensor Module instead..

PS. Put this at the top of your code

function printDict(data)
for i,v in pairs(data) do
  print(tostring(i).." - "..tostring(v))
end
end
and then use printDict(data) whenever your not sure what data[x] your supposed to pick, its helped me lots!


Alright, thanks and cheers.
Tiin57 #5
Posted 20 December 2012 - 09:08 AM
oh and hit the up bottom on the lower right corner of this comment :)/>
That is despicable. You didn't help him at all, then you ask for a +1? -.-
cmurtheepic #6
Posted 20 December 2012 - 09:28 AM
sorry i thought i helped
but i did clear somethings in a way for him/her
Lyqyd #7
Posted 20 December 2012 - 11:13 AM
sorry i thought i helped
but i did clear somethings in a way for him/her

You didn't help, and you didn't clear anything up. You were completely wrong. Don't try to help if you don't know anything about the solution.
Sane #8
Posted 20 December 2012 - 12:51 PM
Topic update, what does he mean the ee sensor module is third on the list. Third on what list? I'm trying to do this with inventory module right now and I don't understand what he means.


ctrl = sensors.getController() -- set the Sensor Controler's data
data = sensors.getSensors(ctrl) -- Find and access the Sensor Controler, bring up all avaiable sensors.
EMC = data[3] -- The EE Sensor Module is thrid on the list, pick it, make note of it.
data = sensors.getProbes(ctrl,EMC) -- Bring up a list of avalable options (TargetInfo, Collector, Furnace ect.)
EMCProbe = data[2] -- Pick #5 Because we are using a condesor
data = sensors.getAvailableTargetsforProbe(ctrl,EMC,EMCProbe) -- Get available blocks
EMCPos = data[1] -- Select the first condensor seen
data = sensors.getSensorReadingAsDict(ctrl,EMC,EMCPos,EMCProbe) -- GET THE DATA!!
print(data.displayEnergy) -- Print the current reading to the screen
Lyqyd #9
Posted 20 December 2012 - 01:05 PM
It means that whoever wrote that code had at least three sensors attached to their sensor controller, and their EE sensor was the third one.
Sane #10
Posted 20 December 2012 - 02:12 PM
Another topic update, whenever I use this code it doesn't print anything:


ctrl = sensors.getController() -- set the Sensor Controler's data
data = sensors.getSensors(ctrl)
SENSOR = data[1]
data = sensors.getProbes(ctrl,SENSOR)
SENSProbe = data[2]
data = sensors.getAvailableTargetsforProbe(ctrl,SENSOR,SENSProbe)
SENSPos = data[1]
data = sensors.getSensorReadingAsDict(ctrl,SENSOR,SENSPos,SENSProbe)
print(data.TotalItems)
Zamithal #11
Posted 20 December 2012 - 09:54 PM
Copy pasting that into my game, it prints fine, the only thing different in mine is I create the printDict function first, you sure its not printing anything?


function printDict(data)
for i,v in pairs(data) do
  print(tostring(i).." - "..tostring(v))
end
end

ctrl = sensors.getController() -- set the Sensor Controler's data
data = sensors.getSensors(ctrl)
SENSOR = data[1]
data = sensors.getProbes(ctrl,SENSOR)
SENSProbe = data[2]
data = sensors.getAvailableTargetsforProbe(ctrl,SENSOR,SENSProbe)
SENSPos = data[1]
data = sensors.getSensorReadingAsDict(ctrl,SENSOR,SENSPos,SENSProbe)
print(data.TotalItems)
Thats my code that I just tested, prints 0 items for an empty chest.