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

Help needed with installer code

Started by Feolthanos, 01 March 2017 - 09:45 AM
Feolthanos #1
Posted 01 March 2017 - 10:45 AM
Hi, I'm working on a random passcode (9-digit) generator. All of my files work including the installer, BUT only if the folder called "AppData" doesn't exist. So I tried to add a function that lets you fill in a folder name and it checks if it exists. If it doesn't exist, it will install all the files in that folder and write to the shortcut which program to open. But when I try to run the extra function, it gives me the error: HbsPAJXZ:43: attempt to call nil


term.clear()
term.setCursorPos(1,1)
if fs.exists("/AppData") == false then
shell.run("mkdir AppData")
shell.run("cd AppData")
shell.run("pastebin get U1WMptac bckgrnd4")
shell.run("pastebin get e34AtnyV bckgrnd5")
shell.run("bckgrnd4")
event,whichone,x,y = os.pullEvent("mouse_click")
while true do
if x == 3 and y == 9 then
  shell.run("cd ..")
  shell.run("pastebin get FR8z7TgA safegen")
  shell.run("cd AppData")
  shell.run("pastebin get jUMWnCTZ safegenmenu")
  shell.run("pastebin get Hp1gqbRF safegencre")
  shell.run("pastebin get 9H7QPJ9T safegengen")
  shell.run("pastebin get 7nLMahF5 bckgrnd1")
  shell.run("pastebin get LSmMsDXi bckgrnd2")
  shell.run("pastebin get ZVM7iuHa bckgrnd3")
  shell.run("delete bckgrnd4")
  shell.run("delete bckgrnd5")
  shell.run("cd ..")
  term.clear()
  term.setCursorPos(1,1)
  print("Install finished!")
  sleep(1)
  shell.run("shell")
elseif x == 3 and y  == 11 then
  shell.run("delete /AppData/bckgrnd4")
  shell.run("delete /AppData/")
  shell.run("shell")
  end
end
else
shell.run("pastebin get e34AtnyV bckgrnd5")
shell.run("bckgrnd5")
term.setCursorPos(14,7)
folder = read()
event,whichone,x,y = os.pullEvent("mouse_click")
while true do
if x == 14 and y == 11 then
  if fs.check(folder) == true then
   term.setCursorPos(14,13)
   print("Folder exists!")
   sleep(1)
   shell.run("safegeninstall")
else
  shell.run("mkdir "..folder)
  FileSystem = fs.open("safegen")
  FileSystem.writeLine("shell.run('/'..folder'/safegenmenu'")
  FileSystem.close("safegen")
  shell.run("cd "..folder)
  shell.run("pastebin get jUMWnCTZ safegenmenu")
  shell.run("pastebin get Hp1gqbRF safegencre")
  shell.run("pastebin get 9H7QPJ9T safegengen")
  shell.run("pastebin get 7nLMahF5 bckgrnd1")
  shell.run("pastebin get LSmMsDXi bckgrnd2")
  shell.run("pastebin get ZVM7iuHa bckgrnd3")
  shell.run("delete bckgrnd4")
  shell.run("cd ..")
  term.clear()
  term.setCursorPos(1,1)
  print("Install finished!")
  sleep(1)
  shell.run("shell")
end
end
end
end
Could someone please help me ?
Bomb Bloke #2
Posted 01 March 2017 - 09:34 PM
Line 43 reads:

  if fs.check(folder) == true then

And indeed, there's no "check" key in the fs table, so attempting to call it will indeed lead to that error.

You meant to use either "isDir" or "exists".