os.loadAPI
From ComputerCraft Wiki
Function os.loadAPI | |
Loads a user created API from a file located at path.
| |
Syntax | os.loadAPI(string path) |
Returns | boolean did the API load successfully? |
Part of | ComputerCraft |
API | OS |
Examples
Example | |
Loads an API saved at "test/myAPI" and runs the global function "hello" from it. | |
Code |
--test/myAPI: local text = "Hello World!" -- this won't be seen from outside of the API because it is localized function hello () -- this will be seen from outside the API because it is not localized print(text) end --The program that will use "myAPI" os.loadAPI("test/myAPI") -- load the API myAPI.hello() -- runs the function "hello" from the API |
Output | Hello World! |
Additional Notes
- path must be an absolute path.
- All variables which will be needed to be accessed through <apiname>.<variable/function> must be global.
- By default APIs cannot access shell API and multishell API.