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

OS API missing

Started by cardybean, 10 November 2015 - 11:01 AM
cardybean #1
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:APIs

However, 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?
Lyqyd #2
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.
KingofGamesYami #3
Posted 10 November 2015 - 11:24 PM
Some of the os functions are defined in bios.lua
MKlegoman357 #4
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.
Bomb Bloke #5
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.
cardybean #6
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
Creator #7
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)
Konlab #8
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).
Bomb Bloke #9
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.
cardybean #10
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
KingofGamesYami #11
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
COOLGAMETUBE #12
Posted 12 November 2015 - 08:08 PM
Use CommandComputer for quenue Commands