Posted 02 February 2013 - 04:59 PM
So i have the following code for the purpose of sending a redstone signal either solid state or pulsing out the bottom of a computer when it gets the message "[WAREHOUSE] Toggle RS" or "[WAREHOUSE] Pulse RS ON/OFF" from another computer.
however when i run another computer set the rednet and boradcast the following in the lua prompt: rednet.broadcast( "[WAREHOUSE] Toggle RS") and hit enter the computer returns true and the drone computer returns message received, but no redstone pulse or redstone solid state.. i'm pretty sure the rs.setOutput is written properly and im almost certain the message is being read properly…. what am i missing?
local function findPeripheral( pType, errMsg )
for _, v in pairs( rs.getSides() ) do
if peripheral.isPresent( v ) and peripheral.getType( v ) == pType then
return v
end
end
print( "Cannot find a "..errMsg or pType.." attached to this computer " )
error()
end
local modemSide = findPeripheral( "modem" )
rednet.open( modemSide )
local pulseDuration = nil
local pulseTime = os.startTimer( duration or 0.5 )
local pulseActive = false
while true do
local event = { os.pullEventRaw( ) }
if event[1] == "rednet_message" then
print( "Message received" )
local msg = textutils.unserialize( event[3] )
if msg["target"] == "[WAREHOUSE]" then
local action = msg["action"]
if action == "Toggle RS" then
rs.setOutput( "bottom", not rs.getInput( "bottom" ) )
elseif action == "Pulse RS ON" then
pulseDuration = tonumber( msg["duration"] )
pulseActive = true
pulseTime = os.startTimer( duration or 0.5 )
elseif action == "Pulse RS OFF" then
pulseActive = false
rs.setOutput( "bottom", false )
end
end
elseif event[1] == "timer" and event[2] == pulseTime and pulseActive then
rs.setOutput( "bottom", not rs.getInput( "bottom" ) )
pulseTime = os.startTimer( pulseDuration or 0.5 )
end
end
rednet.close( modemSide )
however when i run another computer set the rednet and boradcast the following in the lua prompt: rednet.broadcast( "[WAREHOUSE] Toggle RS") and hit enter the computer returns true and the drone computer returns message received, but no redstone pulse or redstone solid state.. i'm pretty sure the rs.setOutput is written properly and im almost certain the message is being read properly…. what am i missing?