Difference between revisions of "API:Functions"

From Spherical
Jump to: navigation, search
(thread Module: mS 5.0)
(Added SphereFS link and Misc heading)
Line 194: Line 194:
 
</tt>
 
</tt>
  
= ...and more to come! =
+
= Miscellaneous =
 +
 
 +
* [[SphereFS]] - How the file system prefixes work.

Revision as of 20:25, 29 October 2017


The Sphere API is the collective name for the set of bindings (functions, objects, and methods) available for use by all Sphere games. The API provides access to a host of convenient features, allowing you to get up and running quickly.


Making new function/object pages

Simple steps:
  1. Before getting started, please check the Article standards and practices.
  2. Click a red link.
  3. Place the following code in the empty edit box:
    1. For a new function: {{subst:functemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}
    2. For a new object: {{subst:objecttemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}
  4. Check the minor edit flag and save.
  5. Click 'edit' at the top of the page to add content.
  6. Try to be objective when writing, and save when you're done.
  7. Remove description from this page, add page link to list at the top of the matching section.


Core API

The Core API provides low-level access to the engine's features and includes all bindings provided directly by the engine. These bindings are exposed to the global scope and can be used without importing any extra modules.

Sphere Game Platform

Debugging

Files and Directories

Random Number Generation

Sphere Runtime

The Sphere Runtime is a standard collection of JavaScript modules included with the engine. Some modules can even be used in Cellscripts as well! Unlike the Core API above which was organized by category, the following list is organized by module. Most modules export only a single object or function; to import more than one at a time, you can use an ES2015 import statement and import objects from the sphere-runtime or cell-runtime module, as appropriate:

In a Sphere game

import { from, Music, Thread } from 'sphere-runtime';

In a Cellscript

import { assert, transpile } from 'cell-runtime';

from Module

image Module

logger Module

music Module

prim Module

random Module

thread Module

Miscellaneous

  • SphereFS - How the file system prefixes work.