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

CC Help Coding

Started by Asgard2693, 10 June 2012 - 04:21 PM
Asgard2693 #1
Posted 10 June 2012 - 06:21 PM
Hey I am new to CC and new to Lua and as such I am confused I am trying to make a simple installer that starts off with some text saying installing….blah blah but at the end I want it to delete the "startup" file and replace it with my own but I cant figure out for the life of me how to do it so just to explain basically what I am trying to do is.

Computer boots up from the floppy>Runs a Startup file in the main Directory (goes through all the install)>Deletes the startup file on the computer and replaces it with one from a Directory on the floppy i.e. (Disk/OS/Startup file)

Is there anyway I can do this really this is all that is holding me back any help would be greatly appreciated

a copy of my code is bellow in a .TXT file

Asgard
kazagistar #2
Posted 10 June 2012 - 06:34 PM
http://computercraft.info/wiki/index.php?title=Fs.move
http://computercraft.info/wiki/index.php?title=Fs.delete
Asgard2693 #3
Posted 10 June 2012 - 06:49 PM

Ok I used your links the fs.Delete line I know and works fine but the fs.move does not it gives me an error no such program

fs.move("disk/OS/startup", "rom/startup")
Asgard2693 #4
Posted 10 June 2012 - 08:33 PM
Ok I have found that the cp disk…… line works I just need to find out hpw to Implement it into the Startup script
Asgard2693 #5
Posted 10 June 2012 - 09:20 PM
Scratch that I need help I am getting an Error
No such Program
startup:109: attempt to call boolean

What am I doing wrong I type into the vanilla shell "cp diskOSstartup startup and it copys over why wont it work inside this script

term.clear()
term.setCursorPos (1,1)
print ("_:(/>/>_:)/>/>_-_-/>/>_-_-/>/>_-_-/>/>_-_-/>/>_-_-/>/>_-_-/>/>_-_-/>/>_-_-/>/>_-_-/>/>_-_-/>/>_-")
term.setCursorPos (20,2)
print ("Computek 1.1")
sleep(2)
term.clear()
term.setCursorPos (1,1)
print ("Starting Install Please wait")
sleep(2)
term.clear()
term.setCursorPos (1,1)
print ("Locating Primary HDD")
sleep(1)
term.clear()
term.setCursorPos (1,1)
print ("C:")
sleep(1)
term.clear()
term.setCursorPos (1,1)
print ("Begining Install….. This may take a while")
term.clear()
term.setCursorPos (1,1)
print ("Copying Files to Main DIR")
sleep(0.5)
term.clear()
term.setCursorPos (1,1)
print ("sys.sys")
sleep(0.5)
term.clear()
term.setCursorPos (1,1)
print ("mp3.sys")
sleep(0.5)
term.clear()
term.setCursorPos (1,1)
print ("DOS 1.9.BAT")
sleep(0.5)
term.clear()
term.setCursorPos (1,1)
print ("explorer.sys")
sleep(0.1)
term.clear()
term.setCursorPos (1,1)
print ("iPhone.exe")
sleep(0.1)
term.clear()
term.setCursorPos (1,1)
print ("sys4.sys")
sleep(0.1)
term.clear()
term.setCursorPos (1,1)
print ("sys2.sys")
sleep(0.1)
term.clear()
term.setCursorPos (1,1)
print ("sys1.sys")
sleep(0.1)
term.clear()
term.setCursorPos (1,1)
print ("File manager")
sleep(0.1)
term.clear()
term.setCursorPos (1,1)
print ("Data Manager")
sleep(0.1)
term.clear()
term.setCursorPos (1,1)
print ("Rom codex")
sleep(0.1)
term.clear()
term.setCursorPos (1,1)
print ("Deleting Temp files")
sleep(1)
term.clear()
term.setCursorPos (1,1)
print ("5%")
sleep(1)
term.clear()
term.setCursorPos (1,1)
print ("10%")
sleep(1)
term.clear()
term.setCursorPos (1,1)
print ("20%")
sleep(1)
term.clear()
term.setCursorPos (1,1)
print ("50%")
sleep(1)
term.clear()
term.setCursorPos (1,1)
print ("70%")
sleep(1)
term.clear()
term.setCursorPos (1,1)
print ("99%")
sleep(1)
term.clear()
term.setCursorPos (1,1)
print ("Delete complete")
sleep(1)
term.clear()
term.setCursorPos (1,1)
print ("Please Wait")
sleep(3)
term.clear()
term.setCursorPos (1,1)
shell.run ("delete", "startup")
shell.run ("cp diskOS startup") ("startup")
shell.run ("eject", "top")
shell.run ("eject", "bottom")
shell.run ("eject", "left")
shell.run ("eject", "right")
sleep(5)
os.reboot()
MysticT #6
Posted 10 June 2012 - 10:08 PM
This line:

shell.run ("cp diskOSstartup") ("startup")
causes the error. It should be:

shell.run("cp", "disk/OS/startup", "startup")
But I wouldn't recommend using shell.run for things that you can do with functions.
You should use:

fs.copy("/disk/OS/startup", "/startup")
to copy the file.

To delete a file:

fs.delete("filename")
And to eject a disk:

disk.eject("<side>") -- replacing <side> with the side of the drive

BTW, that's what kazagistar told you, to use the fs api functions, wich are not programs you run from the shell.
Asgard2693 #7
Posted 11 June 2012 - 12:31 PM
Thank you so much I am just running some errands so the moment I get home I will fix the issue