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

Trying to loop through command list.

Started by Waterspark63, 22 July 2018 - 05:24 AM
Waterspark63 #1
Posted 22 July 2018 - 07:24 AM
So I am trying to do a 'sanity' check before the program continues, the only problem is that when I attempt to run it, it seems like it completely skips the check, I don't know what I'm doing wrong… Any help?

Code:

local CHECKDIRS = {
"fs.exists('/SparkOS/boot/')",
"fs.exists('/SparkOS/home/')",
"fs.exists('/SparkOS/media/')",
"fs.exists('/SparkOS/programs/')",
"fs.exists('/SparkOS/system/')"
}
for i=1,#CHECKDIRS do
if not CHECKDIRS[i] then
  term.clear()
  print("HEY! The folder exists check failed on the following folder!")
  print("Command: "..CHECKDIRS[i]..".")
  sleep(1)
  FAILED = true
end
if FAILED == true then
  print("Please fix the reported problems before booting SparkOS!")
  sleep(1)
end
end
Bomb Bloke #2
Posted 22 July 2018 - 08:23 AM
local CHECKDIRS = {
"/SparkOS/boot/",
"/SparkOS/home/",
"/SparkOS/media/",
"/SparkOS/programs/",
"/SparkOS/system/"
}
if not fs.exists( CHECKDIRS[i] ) then

You've simply been checking to see whether the strings exist in the table.