Posted 15 November 2012 - 02:25 PM
Hello,
i just started with computercraft, and LUA in general, and thought i could use some help on a project I'm working on.
For the record i use computercraft in conjunction with other mods from Tekkit.
Since Combustion Engines have a tendency of blowing up i thought it a smart idea to build a system for it.
I want computercraft to make a bundled wire, but at the end a red wire, turn on if the engine is not "Red"
for this I use ccSensor and a sensor close to the Combustion Engine.
this is my code so far, I don't get any errors but it doesn't show anything on my screen so i would
like you guys to maybe take a look into it.
Mauroq
i just started with computercraft, and LUA in general, and thought i could use some help on a project I'm working on.
For the record i use computercraft in conjunction with other mods from Tekkit.
Since Combustion Engines have a tendency of blowing up i thought it a smart idea to build a system for it.
I want computercraft to make a bundled wire, but at the end a red wire, turn on if the engine is not "Red"
for this I use ccSensor and a sensor close to the Combustion Engine.
this is my code so far, I don't get any errors but it doesn't show anything on my screen so i would
like you guys to maybe take a look into it.
Mauroq
os.unloadAPI("sensors")
os.loadAPI("/rom/apis/sensors")
ctrl=sensors.getController()
_sensor="Sensor"
function getTemp()
target=sensors.getAvailableTargetsforProbe(ctrl,_sensor,"CombustionEngine")
data=sensors.getSensorReadingAsTable(ctrl,_sensor,target[1],"CombustionEngine")
return data[14]
end
function enableWire(color)
local currentSet = rs.getBundledOutput("back")
if not colors.test(currentSet, color) then
currentSet = colors.combine(currentSet, color)
rs.setBundledOutput("back", currentSet)
end
end
function disableWire(color)
local currentSet = rs.getBundledOutput("back")
if colors.test(currentSet, color) then
currentSet = colors.subtract(currentSet, color)
rs.setBundledOutput("back", currentSet)
end
end
while true do
if getTemp()=="Red" then
enableWire(colors.red)
sleep(30)
else
disableWire(colors.red)
end
end
While true do
local evt, arg = os.pullEvent()
local mon = peripheral.wrap("top")
mon.setCursorPos(1,3)
if getTemp()=="Blue" then
mon.write("Engine 1: Blue")
elseif getTemp()=="Green" then
mon.write("Engine 1: Green")
elseif getTemp()=="Yellow" then
mon.write("Engine 1: Yellow")
end
end