Posted 15 September 2012 - 03:48 PM
Can someone help me? Im trying to make my combustion engines to turn off automatic when it gets to hot (Heat level > 50000)
Whole script: (Still a beta)
Whole script: (Still a beta)
os.unloadAPI("sensors")
os.loadAPI("/rom/apis/sensors")
rs.setOutput("left",true)
function printDict(data)
for i,v in pairs (data) do
print(tostring(i).." - "..tostring(v))
end
end
ctrl = sensors.getController()
print("SensorController befinder sig på siden: "..ctrl)
data = sensors.getSensors(ctrl)
print("———")
printDict(data)
bcSensor = data[1]
print("———")
data = sensors.getSensorInfo(ctrl,bcSensor)
printDict(data)
print("———")
sensors.setSensorRange(ctrl,bcSensor,"10")
data = sensors.getProbes(ctrl,bcSensor)
printDict(data)
print("———")
cbEngineProbe = data[2]
function getHeatLevel()
for b=1,12 do
data = sensors.getAvailableTargetsforProbe(ctrl,bcSensor,cbEngineProbe)
target = data
sensors.setTarget(ctrl,bcSensor,target)
data = sensors.getSensorReadingAsDict(ctrl,bcSensor,target,cbEngineProbe)
for i,v in pairs (data) do
if tostring(i)=="engine.heat" then
print(:)/>/>
print(tostring(v))
if tostring(v)>="50000" and tostring(v)~="500" then
rs.setOutput("left", false)
print("NØDLUKNING")
error()
end
end
end
end
end
while true do
getHeatLevel()
sleep(1)
end