Posted 04 November 2018 - 08:19 AM
Hey! Me again. Sorry for the incessant posts but I just can't get enough of lua! Been programming my butt off.
Here's the code.
The error I receive when first running the code on a blank computer is this.
Afterward, if I check the list of programs under the CnS/ dir, auto.lua is the only one showing up.
There should be a few more than that.
I believe it's attempting to copy the program twice which is producing the error but I cannot for the life of me figure out where it's doing that? I need an extra pair of eyes if anyone is willing to take a look.
Thank you!
OH and don't get the wrong idea I still need help with my other posts! I've got a bunch of different projects that I'm bouncing between.
EDIT:
I've patched my bug but I'm not sure if this is the roundabout way or the exact way I needed to do it.
In order to fix it I simply put fs.delete("CnS/"..disk_commandList) right before the fs.copy(…) and that seems ot have fixed it.
Here's the code.
Spoiler
ID = os.getComputerID()
os.setComputerLabel("CnS_Turtle_"..ID)
verify = fs.list("")
disk_commandList = fs.list("disk/CnS")
--verify that there is or is not a CnS directory
for i = 1, #verify do
if verify[i] == "CnS" then
term.clear()
term.setCursorPos(1,1)
print(" ...CnS Turtle Successfully booted...")
print("Turtle ID is "..ID..".")
print("Please issue a command in order to begin.")
print("Type \"prog\" to see the list of loaded applications and type \"auto\" to setup automation.")
break
else
--install CnS package
for i = 1, #disk_commandList do
fs.copy("disk/CnS/"..disk_commandList[i], "CnS/"..disk_commandList[i])
end
os.reboot()
end
end
commandList = fs.list("CnS")
function commandPrompt()
command = io.read()
for i = 1, #commandList, 1 do
if command..".lua" == commandList[i] then
if command == "terminal" then
return os.run({}, "CnS/terminal.lua")
elseif command == "auto" then
return os.run({}, "CnS/auto.lua")
else
print("*You issued the "..command.." command.*")
os.run({}, "CnS/"..command..".lua")
return commandPrompt()
end
end
end
print("Not a valid command.")
sleep(.5)
return commandPrompt()
end
commandPrompt()
The error I receive when first running the code on a blank computer is this.
startup.lua:19: auto.lua: File Exists
The idea is to be installing a load of programs from the disk/CnS/ dir onto the turtle that's parked by the disk drive.Afterward, if I check the list of programs under the CnS/ dir, auto.lua is the only one showing up.
There should be a few more than that.
I believe it's attempting to copy the program twice which is producing the error but I cannot for the life of me figure out where it's doing that? I need an extra pair of eyes if anyone is willing to take a look.
Thank you!
OH and don't get the wrong idea I still need help with my other posts! I've got a bunch of different projects that I'm bouncing between.
EDIT:
I've patched my bug but I'm not sure if this is the roundabout way or the exact way I needed to do it.
In order to fix it I simply put fs.delete("CnS/"..disk_commandList) right before the fs.copy(…) and that seems ot have fixed it.
Edited on 04 November 2018 - 07:29 AM