Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Peripheral Wrapper
- local function open()
- local bOpen, sFreeSide = false, nil
- for n,sSide in pairs(rs.getSides()) do
- if peripheral.getType( sSide ) == "modem" then
- sFreeSide = sSide
- if rednet.isOpen( sSide ) then
- bOpen = true
- break
- end
- end
- end
- if not bOpen then
- if sFreeSide then
- rednet.open( sFreeSide )
- sOpenedSide = sFreeSide
- return true
- else
- print( "No modem attached" )
- return
- end
- end
- return true
- end
- open()
- print("Running lights program...")
- while true do
- event, id, text = os.pullEvent()
- if event == "rednet_message" then
- if id == 0 then
- if text == "Light-on" then
- redstone.setOutput(bottom,true)
- else
- if text == "Light-off" then
- redstone.setOutput(bottom,false)
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment