System docs

The core Ancient Brain system defines the following global variables for your JavaScript.

 AB;               // instance of class ABClass - general Ancient Brain functionality  
 ABRun;            // instance of class ABRunClass - extra functionality for runs   

AB object

The AB object contains Ancient Brain settings. Here are some core settings you can change (default values shown):


AB.clockTick       = 100;    

	// Speed of run: Step every n milliseconds.  
AB.maxSteps        = 1000;    

	// Length of run: Maximum length of run in steps.  

AB.screenshotStep  = 50;   
	// For automatic generation of World images.
	// Take screenshot on this step. (All resources should have finished loading.)  

AB.drawRunControls = true;			

	// Add run controls (Run/Step/Pause) to the run window  

Here are AB functions used for loading screens and splash screens. The normal use is that a loading screen vanishes automatically when resources load. Splash screen needs user click to vanish.


AB.loadingScreen();                  // draw standard loading screen   
AB.removeLoading();                  // remove loading screen 

AB.newSplash();                      // draw standard splash screen  
AB.newSplash ( html );               // draw standard splash screen with this html as the message 
AB.removeSplash();                   // remove splash screen 

Here are further AB functions which may be useful:


AB.onDesktop();                      // return if running on desktop
AB.onMobile();                       // return if running on mobile 

AB.randomFloatAtoB ( A, B );         // return random float between A and B
AB.randomIntAtoB ( A, B );           // return random int between A and B
AB.randomBoolean();                  // return random true or false 
AB.randomPick ( a, b );              // return a or b randomly 
AB.randomPick3 ( a, b, c );          // return a, b or c randomly 
AB.randomElementOfArray ( array );   // return random element of this array 

AB.distance2D ( x1, y1, x2, y2 );    // return distance between two points on 2D plane 

AB.audioIsPlaying ( audio );         // return if this audio is currently playing 

AB.standardAudioButtons ( audio );   // draw standard play/pause buttons for this audio 

AB support for "logged in" runs

Here are AB functions and data used in "logged in" runs.
These functions call various World "logged in" functions.


AB.runloggedin;                 // Boolean. Is this a "logged in" run or not.
AB.myuserid;                    // The userid of a run, if running "logged in".  

AB.saveData();  // Save data for this World for this user (running the World).
                // Only works if user is running "logged in".
                // Data is public and can be browsed in user uploads. 
                // This calls World.saveData to get the data. 

AB.restoreData();   // Recover the data saved for this World for this user.
                    // When this returns, it calls World.restoreData to process the data. 	

AB.queryDataExists();  // Query if data exists on the server for this World for this user.
                       // When this returns, it calls World.queryDataExists.

ABRun object

The ABRun object starts and manages the run itself. It has the following public interface (default values shown):

ABRun.runReady = true;      // Are we ready to go into the run loop? 

   // This is useful when a World loads resources from files.
   // We often prefer to load all resources first, before the run loop starts.
   // To do this:
   // In World.newRun(), set ABRun.runReady = false, and then start load resources.
   // When load finished, set ABRun.runReady = true and run loop will start.
   // This is also useful if there is a splash screen. 
   // Pause the run loop until the user dismisses the splash screen.
ABRun.step;					// the step of the run loop 

ABRun.abortRun = false;     // set this to true anytime to end the run early;                // The World in this run
ABRun.mind;                 // The Mind in this run

// The above two handles are useful if you want to put HTML controls on your page 
// that directly call functions in the World or Mind, like:
// <button onclick=';' 

The background is a program, showing the JavaScript graphics used on this site.

© Ancient Brain Ltd. All rights reserved.

Ancient Brain ™ is a trademark of Ancient Brain Ltd.

Beta      Bug bounty      Contact      Stats      The name      Terms and conditions