Posted 29 November 2014 - 11:46 PM
Basic turbine computer port to redstone port adaptor 1.0
Heya everyone.
As you may know, Big reactors turbines do not have a redstone port as of right now. This code is an easy work around using a computer port instead. It's notjing fancy put it gets the job done.
Features:
-Adaptabillity with wired modems
--Basic side determintation for wrapping
function getDeviceSide(deviceType)
deviceType = deviceType:lower()
for i, side in pairs(rs.getSides()) do
if (peripheral.isPresent(side)) then
if (string.lower(peripheral.getType(side)) == deviceType) then
return side;
end
end
end
return nil;
end
--Peripheral wrapping
function wrapThis(thing, f)
local wrapped = nil
while wrapped == nil and f <= 100 do
wrapped = peripheral.wrap(thing.."_"..f)
f = f + 1
end
if wrapped == nil then
side = getDeviceSide(thing)
if side ~= nil then
return peripheral.wrap(side)
else
return nil
end
else
return wrapped
end
end
--Finding turbine
local turbine = wrapThis("BigReactors-Turbine", 0)
if turbine == nil then
sleep(5)
finished = true
os.reboot()
end
--Redstone emitor
while true do
if turbine.getActive() then
rs.setOutput("right", true)
else
rs.setOutput("right", false)
end
sleep(5)
end