This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
sciencedude100's profile picture

Advanced Computer forgot to turn on redstone?!?!

Started by sciencedude100, 10 October 2013 - 04:48 PM
sciencedude100 #1
Posted 10 October 2013 - 06:48 PM
Whenever I rumn my script the computer dosn't activate any redstone, I have a line to verify a valid signal:

print("Comp#: " ..id .. "> " .. text)
It recieved the signal perfectly, but it still won't work.
Lua:

print("Terminal Application")
rednet.open("bottom")
while true do
event, id, text = os.pullEvent()
if event == "rednet_message" then
  print("Comp#: " ..id .. "> " .. text)
  if text == "N" then
   if rs.getOutput("top") then
	rs.setOutput("back", false)
	rs.setOutput("left", false)
	print("NORTH")
   elseif text == "W" then
	rs.setOutput("back", true)
	rs.setOutput("left", false)
	print("WEST")
   elseif text == "E" then
	rs.setOutput("back", false)
	rs.setOutput("left", true)
	print("EAST")
   else
	print("Invalid Signal")
   end
  end
end
end
Lyqyd #2
Posted 10 October 2013 - 08:17 PM
Split into new topic.

Because of the way you have your code structured, the only parts of the code it can reach are:


print("Terminal Application")
rednet.open("bottom")
while true do
 event, id, text = os.pullEvent()
 if event == "rednet_message" then
  print("Comp#: " ..id .. "> " .. text)
  if text == "N" then
   if rs.getOutput("top") then
    rs.setOutput("back", false)
    rs.setOutput("left", false)
    print("NORTH")
   else
    print("Invalid Signal")
   end
  end
 end
end

You've misplaced an end, meaning that it won't even check if the text is W or E unless it's N, which is a bit of a problem. Move one of the ends up to close the if statement inside the code for N.
HurricaneCoder #3
Posted 10 October 2013 - 10:29 PM
What it should look like:

print("Terminal Application")
rednet.open("bottom")
while true do
event, id, text = os.pullEvent()
if event == "rednet_message" then
  print("Comp#: " ..id .. "> " .. text)
  if text == "N" then
   if rs.getOutput("top") then
	    rs.setOutput("back", false)
	    rs.setOutput("left", false)
	    print("NORTH")
   end -- end here. to end the second if statement
   elseif text == "W" then
	    rs.setOutput("back", true)
	    rs.setOutput("left", false)
	    print("WEST")
   elseif text == "E" then
	    rs.setOutput("back", false)
	    rs.setOutput("left", true)
	    print("EAST")
   else
	    print("Invalid Signal")
  
  end
end
end