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

Basic Programing help: Need more help :x

Started by Zombiebrine, 17 April 2012 - 02:37 AM
Zombiebrine #1
Posted 17 April 2012 - 04:37 AM
How would i write a program that gives me a custom startup message, and emits a redstone pulse when you turn it on. And then emits another redstone pulse when you turn it off.
cant_delete_account #2
Posted 17 April 2012 - 04:45 AM
Type 'edit startup' and type this code (change "left" to "right", etc, whatever side your redstone is on):

term.clear()
term.setCursorPos(1,1)
print("Custom OS Startup Message Here")
rs.setOutput("left",true)
sleep(2)
rs.setOutput("left",false)
Change the "Custom OS Startup Message Here" too.
Sadly, there is no way to make it emit one when it shuts down, you would have to edit the BIOS, which you wouldn't want to do.
Zombiebrine #3
Posted 17 April 2012 - 04:45 AM
Damn your fast
cant_delete_account #4
Posted 17 April 2012 - 04:46 AM
Damn your fast
Yup, that's my job. xD
Zombiebrine #5
Posted 17 April 2012 - 04:56 AM
Ok sO now i want to put this on a floppy and install it on other computers. How would i do that step by step?
Justforlawls #6
Posted 17 April 2012 - 05:02 AM
If I understand you correctly, a solution seems simpering to me, although it may not be the best.

For the custom message and redstone pulse when you turn it on, you will want to edit your startup file. Start by opening your computer and typing 'edit startup' without the quotes. Now you should see a blank screen. For the custom message, you should use print as opposed to write. That is,

print("<message here>")

On my startup, I changed that to

textutils.slowPrint("Welcome to the LawlComp.")

Now, if you noticed, I used textutils.slowPrint instead of print. This will write one letter at a time, which I think gives my computer a 'l33t' appearance, but it's a matter of personal preference.

On to the redstone pulse. This depends on which side you want the pulse on, but for example's sake I'm going to make the pulse go left. This will still be in your startup file. Here's a simple way to turn it on for one second, and then off again.

rs.setOutput("left", true)
wait(1)
rs.setOutput("left", false)

You can change "left" to any side:

"left"
"right"
"front"
"back"
"top"
"bottom"

Now, I'm on a mobile device and can't test an idea, but this isn't too much more difficult. This is for your pulse upon shutdown. Let's save and exit our startup file, and type

edit turnoff

So within your turnoff file, you are sending another one-second pulse. You can use the same code as above to turn on a side, wait, and turn it back off. Now, to shut down your computer, add the following code at the end of the file:

shell.run(shutdown)

Again, save and exit. Normally, people type shutdown to turn off their computer, but now you will be using your new program by typing turnoff.

At this point you should reboot and check for errors in both your startup and your turnoff programs. There is an excellent guide to fixing errors which is stickies in the Tuorials section, and if you still need help, just ask.

:)/>/>
Zombiebrine #7
Posted 17 April 2012 - 12:50 PM
Ok so now i want to put this on a floppy and install it on other computers. How would i do that step by step?
OminousPenguin #8
Posted 17 April 2012 - 03:46 PM
Put the code in a file on the floppy. For this example we'll use filename 'program'
Create a startup file on the floppy and put the following:

fs.copy("/disk/program", "/startup")

Insert the disk and start the computer. The above line will be executed which will copy the program from the disk to a file called startup on the computer.

Untested and I've never used disks.
Zombiebrine #9
Posted 18 April 2012 - 04:37 PM
So to copy my new startup program to a disk that auto starts up on the computer i put it into i do what?
Wolvan #10
Posted 18 April 2012 - 05:03 PM
You can even write edit shutdown and then type

rs.setOutput("side", true)
print("Goodbye")
sleep(2)
os.shutdown()