1lann, on 31 October 2012 - 01:51 PM, said:
Sadly computers cannot read our minds and tell exactly what we want it to do, so you have to be ultra specific and take note of what each function actually "does". Fs.list returns a "table" of the files and folders in "string" form in a specified directory. Fs.delete deletes a file and accept only "string" as arguments. What you're doing is like trying to stick money notes into a coin slot. It won't work. So what you need to do is go through every entry of the table and fs.delete the entry. (Not deleting the entry, deleting the file the entry is referring to). We can do this by using a for statement. The code would look something like this for k, v in pairs(fs.list("disk")) do fs.delete(v) end The variable k represents the index of the table you're at, the variable v represents the value of that index.
ok so i got this code, it works perfectly, accept it dont wipe the disk. there is no errors or anything. here is the code. il then go through the steps underneath so you know what the code is surposed to do:
here is the code:
write("Please Enter Drive Side: ")
local a = io.read()
if a == "top" or a == "bottom" or a == "left" or a == "right" or a == "front" or a == "back" then
print("Checking for drive...")
local b = peripheral.isPresent(a)
local function dclean()
print("Please Enter Disk")
while true do
local c = disk.isPresent(a)
sleep(1)
if c then
print("Disk Found")
sleep(1)
print("Wiping The Disk...")
sleep(1)
for k,v in pairs(fs.list("disk/")) do
fs.delete(v)
print("Disk Wiped")
disk.eject(a)
sleep(1)
break
end
end
end
end
if b then
sleep(1)
print("Drive Found")
dclean()
else
sleep(1)
print("No Drive Found")
end
else
sleep(1)
print("Invalid Drive Side")
end
1. input the drive side -- if no drive side is found then it prints that and ends the program. it does the same for a invalid side
2. it asks for a disk, if the disk is found it then prints wiping disk then ejects it. it ejects it but does not wipe it.