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

Api Error Bug Please Help

Started by Lewisk3, 26 October 2013 - 02:20 PM
Lewisk3 #1
Posted 26 October 2013 - 04:20 PM
Heres my api code:

function Install()
shell.run("rom/apis/win/install")
end


Heres what i put to start it

WCE.Install()

And heres the error i get:

WCE:2: attempt to index ? (a nil value)

Please help!
Lyqyd #2
Posted 26 October 2013 - 04:25 PM
Not a bug. Moved to Ask a Pro.

APIs do not have access to the shell "API", as they aren't programs. Try using os.run instead.
LBPHacker #3
Posted 26 October 2013 - 05:15 PM
Or pass the shell API:
-- the API
function Install(shell)
    shell.run("rom/apis/win/install")
end
-- the program
WCE.Install(shell)
Lewisk3 #4
Posted 28 October 2013 - 04:25 PM
ok i will try that thanks also i have another problem


function del(file)
if fs.isDir("RecycleBin") then
else
fs.makeDir("RecycleBin")
end
if fs.exists(file) then
fs.copy(file,"RecycleBin/"..file)
fs.delete(file)
else
error("No Such File")
end
end

Its says Copy Failed

whats the problem with this code?
LBPHacker #5
Posted 28 October 2013 - 04:35 PM
That's because the second argument given to fs.copy is the destination folder, not the full path of the new file. By the way, use fs.move. It's the same as copying and deleting something.