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

Question about loading APIs

Started by mantricore, 20 April 2013 - 06:45 AM
mantricore #1
Posted 20 April 2013 - 08:45 AM
Each time I try to use a function in the API I made , it tells me : No such programs.

Here's my code:

os.loadAPI("exampleAPI")
– this is the file exampleAPI
– our first function

function printMessage(message)

print(message)

end

____________

And here's how I try to use my function:

exampleAPI.printMessage("anymessage")

____________

This is a code I got from the computercraft.info tutorial section.
Lyqyd #2
Posted 20 April 2013 - 08:58 AM
Split into new topic.

You need to load the API from the file you want to use it in, not the API itself. Can you link to the tutorial so we can fix it if necessary?
mantricore #3
Posted 20 April 2013 - 09:18 AM
http://computercraft..._API_(tutorial)

Here it is

I am not sure to really understand what you tell me to do…

Could you please give me an example ?
Lyqyd #4
Posted 20 April 2013 - 11:12 AM
The os.loadAPI line needs to be at the top of the file that calls the API function, not the file that declares the API function.


os.loadAPI("example")
example.doStuff()