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

os.loadApi: attempt to call nil

Started by ascobol, 27 February 2014 - 07:06 AM
ascobol #1
Posted 27 February 2014 - 08:06 AM
Hello there,

I hope anyone can help me.

I tried to write a small farming program for a turtle and wanted to put some functions, that I maybe could use in the future or for other programs as well, in an api.

Unfortunately, everytime I try to load the api via os.loadapi(), I get the error "attempt to call nil"

I tried to load the api in my script and as well on the lua prompt directly. Both give the same result.

I have three scripts:
  1. a downloader –> http://pastebin.com/VxA8YVyc
  2. It just downloads first the api and then the program itself
  3. the api –> http://pastebin.com/WSeMJrTY
  4. the program –> http://pastebin.com/vnn9f5aj
The download works ok.
After that I start the program ("farming"). And get the error "farming:17: attempt to call nil".
If I try to load the api directly on the lua prompt, I get "lua:52: attempt to call nil".

Anyone an idea what I do wrong?

I read some posts here on the forum already and tried some solutions (on other problems) already.
For example, use a absolute path, like "/farmingApi", I tried another name for the api or to put in a sub-folder instead of root.

But it didn't help.

I even tried it with a simple testApi, like

function sayHello()
   print("Hello there!")
end

Even that gets the same error when I try to load it.

I use ComputerCraft 1.53 (FTB Unleashed).

Thanks in advance
Ascobol
Lyqyd #2
Posted 27 February 2014 - 03:57 PM
Line 17 in the linked code is a comment. Can you post the actual code?
ascobol #3
Posted 27 February 2014 - 04:49 PM
Line 17 in the linked code is a comment. Can you post the actual code?
Hi Lyqyd,

thanks for the reply.
Yes, I found the error already. But I couldn't take the post back. I couldn't find it anywhere till was approved. Sorry for the inconvience.

My error the function typing:

I used: os.loadApi(…)

But it must be os.loadAPI(…)

Found that out after I read every faq and tutorial twice again. Unfortunately, as said, I couldn't delete the post then or mark it as solved.

But thanks for the reply.

Ascobol

PS: I read the faqs and tutorials before several times too, but somehow oversaw the capitlized API. Sorry.