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

[Error] print Doesn't Work

Started by deathzone, 12 May 2012 - 03:56 AM
deathzone #1
Posted 12 May 2012 - 05:56 AM
Alright, i used the simple door lock and changed only A FEW things.

Here is the startup code that doesn't error:


function pass()
t = io.read()
if t == "bacon" then
redstone.setOutput("back", true)
term.clear
term.setCursorPos(1,1)
sleep(5)
redstone.setOutput("back", false)
pass()
else
pass()
end
end
pass()

That works fine.

It's this code that doesn't work right:


function pass()
t = io.read()
if t == "bacon" then
redstone.setOutput("back", true)
print("Password Accepted!")
term.clear
term.setCursorPos(1,1)
sleep(5)
redstone.setOutput("back", false)
pass()
else
pass()
end
end
pass()

All i added was the
print("Password Accepted!")
And it errors.

The error i get is:

bios:206: [string "startup"]:7: '=' expected

when i reboot.

Please help, Thanks.

EDIT(In the middle of writing post): I just tested it without the print and stuff and now that's not even working?

Ugh..
ComputerCraftFan11 #2
Posted 12 May 2012 - 06:28 AM
Change

term.clear
to

term.clear()
Since term.clear is a function, so it needs ()

And, add a sleep(1) after print("Password accepted!") because it clears before you can even read it.
Edited on 12 May 2012 - 04:29 AM
deathzone #3
Posted 12 May 2012 - 07:10 AM
but will that even make the print work?

EDIT: 2 more questions, how can i make it so it like "exits" the computer window when it opens the door, so i dont have to click Esc, and also, how can i make a program that displays stuff on a monitor, like i want to display the text "Welcome" on the monitor.
ComputerCraftFan11 #4
Posted 12 May 2012 - 07:14 AM
but will that even make the print work?

Yea. The print works but you can't see it since it clears it right after it got printed
deathzone #5
Posted 12 May 2012 - 07:21 AM
Can you maybe check my edit on that if you haven't sorry, just thought you might have not seen it
ComputerCraftFan11 #6
Posted 12 May 2012 - 07:24 AM
but will that even make the print work?

EDIT: 2 more questions, how can i make it so it like "exits" the computer window when it opens the door, so i dont have to click Esc, and also, how can i make a program that displays stuff on a monitor, like i want to display the text "Welcome" on the monitor.

1) You currently can't do that
2) To display stuff on a monitor, add this code:

local mPrint = function(text, side)
  monitor = peripheral.wrap(side) --Let the PC know there is a monitor on the side you selected
  term.redirect(monitor) --Switch to the monitor
  print(text) --Print the text on the monitor
  term.restore() --Switch to the PC
end

then you can print it like this:

mPrint("Welcome", "right")
This will print Welcome to the monitor on the right
deathzone #7
Posted 12 May 2012 - 07:55 AM
Wow thanks! They should really add the first one in though, makes it easier if you want the user to see something displayed on a monitor, like it would cool if i could make it exit the screen and display "Password Accepted/Denied" on the monitor.
ComputerCraftFan11 #8
Posted 12 May 2012 - 08:00 AM
Wow thanks! They should really add the first one in though, makes it easier if you want the user to see something displayed on a monitor, like it would cool if i could make it exit the screen and display "Password Accepted/Denied" on the monitor.

Well actually, if you get to far from the screen, it closes.

So if you have a turtle, you can make it fly up when you get it right, or if you have a PC, you can make a piston drop water on you and push you away (it's slow but it still works)
deathzone #9
Posted 12 May 2012 - 08:23 AM
Lol, i'm in single player it's just for fun, i'm good, thanks
deathzone #10
Posted 12 May 2012 - 08:52 AM
Sorry for the double post, but i wanted it to show i had a new post.

How can i make a turtle mine forward forever or a set amount of time/blocks, because i made one that did it unlimited, but everytime it rebooted so it lagged so much. Thanks
ComputerCraftFan11 #11
Posted 12 May 2012 - 09:21 AM
Sorry for the double post, but i wanted it to show i had a new post.

How can i make a turtle mine forward forever or a set amount of time/blocks, because i made one that did it unlimited, but everytime it rebooted so it lagged so much. Thanks

Try this:

mine = 0 --how much blocks it mines
for n=1,mine do
  turtle.dig()
  turtle.forward()
end
It will mine forward how many times you select
deathzone #12
Posted 12 May 2012 - 06:23 PM
You sir, are amazing!