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

Steam Engine sensor readings

Started by snowmansmartie, 26 September 2012 - 07:40 PM
snowmansmartie #1
Posted 26 September 2012 - 09:40 PM
Hi guys,

I've been playing around with CC and Sensors to get some information for a control program for a mine.

The sensor I have is to monitor the engines and I have got all the information I need, all accept the actual readings I am struggling to get the exact info I need.

Code is as follows:

function printDict(data)
  for i,v in pairs(data) do
	print(tostring(i).." - "..tostring(v))
  end
end
ctrl = sensors.getController()
mySensor = sensors.getSensors(ctrl)
mySensor = mySensor[1]
sensorInfo = sensors.getSensorInfo(ctrl,mySensor)
myProbes = sensors.getProbes(ctrl,mySensor)
myProbes = myProbes[3]
myTargets = sensors.getAvailableTargetsforProbe(ctrl,mySensor,myProbes)
rightEng = myTarget[1]
leftEng = myTargets[2]
bottomEng = mytargets[3]
rEngInfo = sensors.getSensorReadingAsDict(ctrl,mySensor,rightEng,myProbes)
rEngTemp = -- This needs to be the engine.energyStage variable and this is the part that falls over and I cannot get the information for this.  I have tried rEngInfo[8] and engine.energyStage and neither produces the "colour" of the engine temp.

So what I am trying to eventually display to the user is something like:

Right Engine Temp = Yellow
Left Engine Temp = Red
Bottom Engine Temp = Yellow

obviously colours dependant on the actual engine state :P/>/>!

Hope this all makes sense, and I would appreciate anyones help.

Cheers

PS - Yes I have trawled through Google/Forums/WIKI's etc and I'm all searched out.
snowmansmartie #2
Posted 28 September 2012 - 01:33 AM
So just an update I have looked through some other example code and have now tried:

print(rEngInfo.energyState)

and

print (rEngInfo[8])

Now with either of these I dont get any errors I just get a blank line, so it looks like its working but still doesn't give me the correct return.

Has anyone got any ideas as to what on earth I am doing wrong?

Cheers
Tbone #3
Posted 14 October 2012 - 04:57 PM
I have the same problem with "engine.heat"

I have a working program with MFSU energy and it is working fine.

Think i has something to do with the "engine "dot" heat" it seems to work when there is no dot in the reading index.