Jump to content




[Question] computer wont print on redstone input


  • You cannot reply to this topic
6 replies to this topic

#1 Mtshaw113

  • Members
  • 3 posts

Posted 20 October 2012 - 11:47 PM

Ok so I have an IC2 Nuclear Reactor running and if you know this, you need a redstone signal for it too run. I have a green RP2 lamp and a red one, red has a not Gate connected so when its running, the red light turns on. I have the wire thats connected to the red lamp in a yellow cable, and I have a white cable thats connected to the green lamp. I connected the 2 with bundled cable and put it into the back of my computer. I also have a monitor set up next to it. What i want, is for the monitor to say "Reactor is ON and dangerous, Caution is advised!!" When the yellow wire is on, and when the white wire is on to say "Reactor is OFF and Safe, Approach at your own risk". I do have some code right now, but it wont print on the monitor or in the computer(when i dont do "monitor left <name>" it should print in the computer, i think)
Code:
while true do
local event = os.pullEvent("redstone")
local White=rs.testBundledInput("back", colors.white)
local Yellow=rs.testBundledInput("back", colors.yellow)
if White then
print " Reactor is OFF and Safe, Approach at your own risk"
elseif Yellow then
print "Reactor is ON and dangerous, Caution is advised!!"
shell.run"clear"
end
end
The shell.run"clear" I dont know what it means but i saw it somewhere and thought it was used for this(im probably wrong) And the computer gives no error, it just wont print. Sorry for all the writing, i was trying to accuratey describe it.

#2 OmegaVest

  • Members
  • 436 posts

Posted 21 October 2012 - 02:34 AM

shell.run("clear")

You need the parentheses around it. Also, very lag-happy way to do that. Better to use term.clear() and term.setCursorPos(1,1). Also, put a sleep in the while loop. And put the clear at the top, not the bottom. As you have it, this will only show the blank screen, because that is last.

#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 21 October 2012 - 03:02 AM

Sleep is not necessary, since he's got an os.pullEvent("redstone"), which is certainly the better way to do this. However, the pullEvent and the clear lines should be swapped.

#4 ChunLing

  • Members
  • 2,027 posts

Posted 21 October 2012 - 03:23 AM

You don't want to run any kind of clear at the end of your loop, that erases any text you printed in the same frame you printed it. The text is probably printing and you're not seeing it because you're clearing the terminal immediately. Like Lyqyd says, swap those lines.

#5 cheekycharlie101

  • Members
  • 231 posts

Posted 21 October 2012 - 04:51 PM

to solve the print issue your simpley missing the brackets. for instance
this is what you have done
print"Hello World"

this is the right way of doing it
print("Hello World")
that should make it print for you
thanks -Cheeky

#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 21 October 2012 - 04:57 PM

View Postcheekycharlie101, on 21 October 2012 - 04:51 PM, said:

to solve the print issue your simpley missing the brackets. for instance
this is what you have done
print"Hello World"

this is the right way of doing it
print("Hello World")
that should make it print for you
thanks -Cheeky

Technically, when the only argument is a string literal, the parentheses are not required. I'm not certain what effect the lack of a space may have had.

#7 ChunLing

  • Members
  • 2,027 posts

Posted 21 October 2012 - 07:18 PM

It's fine, the lua interpreter picks off "print" from the string in quotes just fine, since there is no other valid interpretation. It may not be the best habit, but it works in CC's implementation.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users