Jump to content




Question about loading APIs


  • You cannot reply to this topic
3 replies to this topic

#1 mantricore

  • New Members
  • 2 posts

Posted 20 April 2013 - 07: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.

#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 20 April 2013 - 07: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?

#3 mantricore

  • New Members
  • 2 posts

Posted 20 April 2013 - 08: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 ?

#4 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 20 April 2013 - 10: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()






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users