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

Please help (thanks)

Started by Seth.P, 13 October 2015 - 02:44 AM
Seth.P #1
Posted 13 October 2015 - 04:44 AM
Hello. I am creating a map in the tekkit modpack, and I wanted to make a few computers in offices that had a cool startup program. What I want to do is have the program write;

"Hello, user"
(clear screen)
"Please enter password"
(clear screen)
"[_ _ _ _ _]"
"[*]"
"[*]"
"[*]"
"[*]"
"[*]"
(Make this look like it has been typed by the player, please.)
Then
(clear screen)
"Welcome, user, please enter command."
(end)
This of course won't do anything, but will be to make the offices seem a lot better. A tutorial-or better yet, the program itself-would be greatly appreciated. Thank you in advance cor helping me out here. I've never been much of a programming genious (I even tried it on KhanAcademy. Didn't do too well :/ ), so any help would be the equivlant of helping someone with normal skill do a simple "write" function. Again, thank you very much, and I hope you have a great day. :)/>
valithor #2
Posted 13 October 2015 - 06:08 AM
It should be noted very few people are willing to write a program for someone else, seeing as that is not what this section is for. We would, however, be more than willing to help you learn how to do it yourself (point of the mod is to make it easy to learn how to code).

A few things that might help you get started if you decide to try:

print("hello") --# this would print the word hello

term.setCursorPos(5,10) --# would move where the cursor is on the screen to the coordinates 5, 10

sleep(1) --# will sleep for 1 second / 20 in game ticks

term.clear() --# will clear the screen

variable = read() --# will set the variable to whatever the user inputs

if variable == "password" then --# checking to see if what the user inputed what the password
  print("Correct password!")
end

Just know if you get stuck anywhere along the way feel free to ask for help! That is what we are here for :D/>
Bomb Bloke #3
Posted 13 October 2015 - 08:13 AM
An additional note on read() - if you pass it a parameter, then whatever symbols the user types will appear as that parameter on-screen.

For eg, if you wanted a password to appear as stars, you'd do:

variable = read("*")