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

What did i do wrong?

Started by microfix, 04 October 2012 - 12:51 PM
microfix #1
Posted 04 October 2012 - 02:51 PM
I don't if this is the place to post it.
But I can't figure this out.
Minalien #2
Posted 04 October 2012 - 02:55 PM
elsif should be elseif

Also, you don't need the "== true" or "== false", you can just do:
if redstone.getInput("front")
and simply use an else statement (rather than elseif).
microfix #3
Posted 04 October 2012 - 03:00 PM
How will you make it with the else statement??. I'm not that good to cc..
Minalien #4
Posted 04 October 2012 - 03:12 PM
Here, this script should give you the results you're looking for.


local mon = peripheral.wrap("back");
if mon then
  term.redirect(mon);
  print("Admin")
  print("is")
  if redstone.getInput("front") then
    print("OFFLINE")
  else
    print("ONLINE")
  end
end

Unfortunately, it isn't a very good one. If you're looking for something that'll react to the redstone signal as it changes, you'll want something like this:
local mon = peripheral.wrap("right");

function updateOnline()
    mon.setCursorPos(1, 3);

    if redstone.getInput("front") then
        mon.write("OFFLINE")
    else
        mon.write("ONLINE ")
    end
end

if mon then

    mon.setCursorPos(1, 1);
    mon.write("Admin");
    mon.setCursorPos(1, 2);
    mon.write("is")

    updateOnline();

    while true do
        local evt = os.pullEvent();

        if evt == "redstone" then
            updateOnline();
        end
    end
end
microfix #5
Posted 04 October 2012 - 03:26 PM
nothing is getting printet to the monitor when i do that program. :S
Minalien #6
Posted 04 October 2012 - 03:29 PM
You mistyped part of it (you put "if more then" instead of "if mon then")
microfix #7
Posted 04 October 2012 - 03:30 PM
i did if more then. I did the if mon then. and it works. thanks. :(/>/>