Skip to content
Gilberto Romero edited this page Sep 6, 2016 · 9 revisions

StarOS is a terminal-based OS which provides basic APIs, programs, and utilities for users who are looking for rapid programming. The OS itself can be bought from the Outpost (Not yet implemented) or crafted for quick availability. Here you'll find information about how to use the various APIs provided to users and the programs that come built-in.

Table of Contents

Programs

  • Adv
  • Cdisp
  • Cmd
  • Edit
  • Lua
  • Paint

Libraries

Programs

Libraries

Event

Font

The Font API is a table index by characters usable by keyboards. It contains said data in texture format as to be drawn to the GPU quickly, as well as extra information such as character offset to be used by the Term API. Be aware that it's not like the Keys API, and that while you would do keys.one for the Keys API, you would do font["1"] for the Font API.

Filesystem

The filesystem API, shortened to just "fs", is built ontop of the IO API, providing for protection and automatic folder generation when referring to paths that don't exist. The protection offered by the fs API can easily be bypassed by the IO API, if one ever needs to do so.

fs.open( string file, string mode )

Returns: file File

Works just like io.open, except it prevents writing to files that are protected.

fs.preparePath( string path )

Automatically creates folders to the given path if there aren't any already.

fs.makeDir( string dir )

Works just like io.makeDir, except it prevents writing to files that are protected.

fs.copy( string path1, string path2 )

Copies the entire folder or file from path1 to path2, given path2 is non-existant and is not protected.

fs.move( string path1, string path2 )

Moves the entire folder or file from path1 to path2, given path2 is non-existant and is not protected.

fs.delete( string path1, string path2 )

Works just like os.remove, except it prevents the deletion of protected files and folders.

fs.listFiles( string path )

Returns: table fileList

Uses io.list to return a table indexed numerically with file names.

fs.listFolders( string path )

Returns: table fileList

Uses io.list to return a table indexed numerically with folder names.

fs.protect( string path )

Protects the file or entire folder given from modification.

fs.isProtecting( string path )

Returns: boolean hasProtection

Returns whether or not the file or folder given is being protected by fs.

Term

The Term API is used to display text, be it colored or not, on the screen, making it very useful for outputting text that needs to be easily seen.

term.setCursorPos(number x, number y)

term.getCursorPos()

term.offsetCursorPos(number offsetX, number offsetY)

term.setOrigin(number originX, number originY)

term.getOrigin()

term.setSize(number width, number height)

term.getSize()

term.setTextColor(number color)

term.setBackColor(number color)

term.push( <...> )

term.pop()

term.scroll(number lines)

term.write(string text <, number x, number y>)

term.read(<string replaceChar, table history>)

Colors

The Colors API is a table full of color names for more convienient and readable color switching. It has 16 names, the names being that of the colors available to the first tier GPU. They are as follows: colors.black

colors.camarone

colors.jlaurel

colors.green

colors.blue

colors.bribbon

colors.azurer

colors.cyan

colors.red

colors.iorange

colors.worange

colors.yellow

colors.magenta

colors.pinkf

colors.lrose

colors.white

Json

The Json API allows for the encoding of tables into JSON formatted strings, and the conversion of said strings back into table format.

json.encode( table Json )

Returns: string Json

Turns a table into a JSON formatted string, useful for saving to file to allow for easily editable user configs. It should be noted that it cannot encode functions, userdata, nor threads. It should also be noted that it doesn't do very well with mixed tables; If the table has any non-nil value at it's first index, then it will treat the table as an array. If not, it will treat the table as an object, so be sure to keep your tables non-mixed. Lastly, the only way to have any particular value be saved as a null is to set said value to the string "null".

json.decode( string Json )

Returns: table Json

Turns a formatted JSON string into it's table equivalent. All values set to null will be ignored.

Keys

The Keys API is simply a table to allow for number to key conversion and back. For example, if you wanted to know what the letter "a" was in number format when checking keyboard input, you'd lookup keys.a. However, if you wanted to know what letter the number 43 represents, you'd lookup keys[43].

Shell

Soundsystem

Other

The following don't really belong anywhere else but here.

print( ... )

Writes the values given to it on screen with a new line for every value given.

printError(string error)

Writes the given error string on screen in the color red. Be aware that this does not actually exit from your program.

The following functions have been re-implemented in the OS:

os.tmpname()

**Returns: ** string fileName

Returns a temporary file name that can be written to.

os.getenv(string varname)

Returns: var

Can be used to get OS environment variables, where var is usually a string or number. The following variables are currently gettable/settable:

  • OS (Defaults to "StarOS")
  • Version (Defaults to 1.0)
  • ComputerName (Defaults to "Computer")
  • %TMP% (Defaults to "C:/tmp")
  • %DATA% (Defaults to "C:/data")
  • %STARTUP% (Defaults to "C:/startup.lua")

os.setenv(string varname, data)

Can be used to set OS environment variables, where data is recommended to be a string or number.

os.execute(string command)

Uses a separate shell, works as an alias for shell.execute() for said separate shell.

io.tmpfile()

Returns: file temporaryFile

Returns a file that can be written to.

io.stdin()

Currently an alias for term.read()

io.stdout()

Currently an alias for term.write()

io.stderr()

Currently an alias for printError()

Clone this wiki locally