Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

Archived

This topic is now archived and is closed to further replies.

pedrosgali

[OC1.2] Some tips on loading your own APIs

Recommended Posts

MOD NOTE: The information in this thread is for OC 1.2 which is now unsupported.

 

Okay, I don't know if anyone else has found this or if I'm just a being a noob but I had real trouble loading an API that I wrote for my networking program.

After a bit of head scratching I found a solution that worked and thought I'd post it here to hopefully save someone else that time.

 

I traditionally store APIs in a folder of the same name, and when calling them I found 2 things that you should know.

 

1)  The API should always be suffixed with .lua in the filesystem so my path would read:  c/API/myAPI.lua

2)  When you call the API you should drop that suffix eg:  

 myAPI = require("c/API/myAPI")

As I said, I may be just a noob but that is the one major problem I have run into so far.

 

I hope this saves someone some time.

Share this post


Link to post
Share on other sites

If you store your libraries in a standard location, such as /lib or /usr/lib (and probably /home/lib), they get loaded with a require("libraryName"), without the path.

To do this for /lib or /usr/lib, you will need to mount your own drive as root, since the default root file system is the rom which is read only.

Share this post


Link to post
Share on other sites

If you store your libraries in a standard location, such as /lib or /usr/lib (and probably /home/lib), they get loaded with a require("libraryName"), without the path.

To do this for /lib or /usr/lib, you will need to mount your own drive as root, since the default root file system is the rom which is read only.

I should point out that in OC 1.3, the OS is mounted at root, but is installed on the HDD and is therefore fully editable =)

Share this post


Link to post
Share on other sites

If you store your libraries in a standard location, such as /lib or /usr/lib (and probably /home/lib), they get loaded with a require("libraryName"), without the path.

 

absolutely this.

 

as a standard, i say it's best to use /home/lib as your storage for any custom libraries, it does - as you suggest - allow the short-form loading, and ensures that your own libraries are separate from any you may download using oppm - which get put into /usr/lib - or from an OS reinstall, which could overwrite your /lib

 

similarly, putting all your own programs [i.e. non libraries] into /home/bin allows shell.execute(path) to find your files without qualification 

Share this post


Link to post
Share on other sites

Yeah, I wrote this before openOS was installable. It was OC 1.2 or something, the /lib folder was read only.

*Edit: Can a moderator delete this thread as it is out of date and may cause confusion to some.

Share this post


Link to post
Share on other sites

Yeah, I wrote this before openOS was installable. It was OC 1.2 or something, the /lib folder was read only.

*Edit: Can a moderator delete this thread as it is out of date and may cause confusion to some.

 

sorry, i wasn't commenting on your post really, i was adding to the previous 2 posts

it's a fair enough tip, you could edit the first post and just say pre 1.3, post 1.3 for some of it...

better to have the tip, than get rid all together :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.