3 posts
Posted 10 November 2015 - 12:01 PM
Hi,
So I wanted to make an "environment manager", e.g. periodically set time to 0 and weather to clear
This requires the OS APi
Even if there's a better way to do the above, I'd still like the OS API!
I'm using ComputerCraft 1.7.4, and when I type 'apis' into a Command Computer it returns the full list as specified @
http://www.computercraft.info/wiki/Category:APIsHowever, when I cd into the rom/apis fodler, many of the APIs are missing!
Why is this? I've downloaded another copy of the JAR from the CC website and unzipped, the other APIs are still missing!
How can I get it?
Does anyone have the API files so I can just upload or inject into jar and re-upload to the server?
8543 posts
Posted 10 November 2015 - 07:58 PM
Moved to Ask a Pro.
The os API is exposed directly from the Java side, so there are no Lua files you can inspect. You can still override or add new functions to the API by setting new values in the table during startup, for example.
3057 posts
Location
United States of America
Posted 10 November 2015 - 11:24 PM
Some of the os functions are defined in
bios.lua
1140 posts
Location
Kaunas, Lithuania
Posted 11 November 2015 - 05:28 AM
Which function do you need from the OS API exactly? To have the command computer run a command you'd use the commands API, not OS API.
7083 posts
Location
Tasmania (AU)
Posted 11 November 2015 - 05:41 AM
I'm using ComputerCraft 1.7.4, and when I type 'apis' into a Command Computer it returns the full list as specified @
http://www.computercraft.info/wiki/Category:APIs
Just to be clear, this means you
have the API loaded. It's not missing.
3 posts
Posted 11 November 2015 - 12:19 PM
Thanks for the replies all.
Well last night I discovered I can use the 'commands' API (as stated by MKlegoman) to do most things, such as set time
However still missing a sleep function, which I really do want
So how do I call os functions then? Because if I try in the shell (or on the prompt..) I get 'No program avilable' and if I try in a script I also get 'No program available'. An example would be fab
2679 posts
Location
You will never find me, muhahahahahaha
Posted 11 November 2015 - 04:01 PM
the sleep function is simply:
sleep(time)
To run code:
1. type "edit <path>"
2. write the code
3. exit the editor
4. type "<path>"
The OS api can be accesse through:
os.theFunctionINeed(arguments)
779 posts
Location
Kerbin
Posted 11 November 2015 - 04:52 PM
Thanks for the replies all.
Well last night I discovered I can use the 'commands' API (as stated by MKlegoman) to do most things, such as set time
However still missing a sleep function, which I really do want
So how do I call os functions then? Because if I try in the shell (or on the prompt..) I get 'No program avilable' and if I try in a script I also get 'No program available'. An example would be fab
Some of the APIs are Java side (like fs), rom/apis only contains Lua side apis (like rednet), which are written in Lua. Some apis have functions on both sides (like the os API).
7083 posts
Location
Tasmania (AU)
Posted 11 November 2015 - 11:36 PM
You can only call functions via either the Lua console or via scripts. If you get errors when you attempt to do so, then show us the code you're using.
3 posts
Posted 12 November 2015 - 08:34 AM
Thanks again for all the replies.
I definitely got 'Program not found' (or similar) with a simple os.sleep(n) in a script
Also sure I tried it without the api prefix (i.e. sleep(n)) but will try again tonight and post if this doesn't work
Cheers
3057 posts
Location
United States of America
Posted 12 November 2015 - 01:25 PM
Program not found cannot happen unless you are:
1) Not writing a program, and trying to run lua code as if it were a program
OR
2) Using shell.run or os.run in your program
51 posts
Location
Germany
Posted 12 November 2015 - 08:08 PM
Use CommandComputer for quenue Commands