system.<...>

Return to Introduction  Previous page  Next page

System level functions and variables.

 

Properties

 

script

Access document level script variables.

window

Control the position/size of the playback window.

folders

Strings for the disk locations of the various system folders.

contextMenu

Functions to enable/disable, add to or clear the player's context menu.

backgroundCol

Gets or sets the Color for the background of the player window (defaults to black).

timer

A system wide user timer.  Set to zero and it will increase in seconds as time passes.

timerDelta

A constant for each update pass representing the amount of time that has elapsed since the last update in seconds.

ui

User interface related properties, such as the mouse position or object that the 'mouse look' controls.

debug

Get/set whether the debug window is visible or not (true/false)

fullScreenMode

Get/set whether the player is running in full screen mode (true/false)

file

File system related functions.

clock

Call the update() method to set the following properties to the current time: day, month, year, hour, minute, second, dayOfWeek.  Months are numbered 1-12 and the day of the week returns 0 for Sunday, 1 for Monday, etc.

stamp

Returns a stamp that is unique to the document and who made it.  If the document is edited by someone else, this value will change.

effects

Allows access to all the top level effects.

fps

Returns the current frames per second.

registry

Provides access to read/write values in a DX Studio Player subkey of the system registry.

maxFPS

Get or sets the maximum frames per second the engine is allowed to display (float).

hasFocus

Returns true if the player has the input focus.

exitWithEscape

Bool property that if set to false will disable the ESC key from closing the player.

qualityMode

Set to false to disable the advanced lighting/rendering effects.

multiSample

Set to false to disable multisampling (anti-aliasing on pixels).

isEmbedded

Returns true if the player is running as a DLL (in a browser or container application).

xml

XML functions (Standard/Pro editions only).

consoleFileWrite

If you set this to true, a temporary file in the system.folders.temp folder (in subfolder dxcache) called console.txt will receive a copy of everything written to the console.

legacyMode

If this returns true, the player is running in a cut-back mode for older cards and drivers.

exitAbort

If you set this to true, the application will abandon the command to exit if running in the standalone player.  Trap the onExitRequest event to test for this condition.

multiSample

Bool property that sets/gets whether multisampling is enabled.

dynamicShadows

Bool property that defaults to true.  If you set it to false, dynamic shadows will be disabled for the whole document which should improve render speed.

resources

Provides access to the document level resources.  Currently you can extract a resource with the extract method.

debug

Provides access to the debugger from script.  Currently you can break the debug with the breakNow() method.

 

Methods

 

exit()

Causes the application to close immediately (not available when running in a browser).

restart()

Reloads the document and runs from the beginning again.

load(filename)

Loads and displays the specified document.

fullScreenToggle()

Switches between full screen and windowed playback.

saveScreenCapture(filename, [format], [postprefix])

Saves a screenshot of the current player window to a JPG, PNG, BMP or DDS file on disk.  The function will determine the type from the filename, or you can optionally pass a string of "jpg","png","dds" or "bmp" as a second parameter to force it to save a certain type.

 

If instead of a filename you pass a URL (such as http://www.dxstudio.com/examples/showscreenshot.aspx) the screenshot will be sent as a HTTP POST to the given URL.  By default the image will be sent as the value 'screenshot', but you can override this by setting the optional 'postprefix' string.  The last parameter sent in this string is always the image, so valid postprefixes would be for example "myscreenshotjpg=" or "client=dave&screenshot=".  The image file will be in base64, so you'll need to convert it to bytes before saving.  You may also need to replace spaces ' ' with the plus sign '+' in the data before conversion.  Some sample code can be found at http://www.dxstudio.com/examples/showscreenshot.aspx.

 

Any data returned from a URL post will be saved and can be retrieved as a string using getLastPostResponse().

 

The function returns true if successful.

postToURL(url, postdata)

This function takes a string url for the target to post to, and a string postdata that contains & separated name=value pairs.  e.g. myval=1&otherval=test

 

The function returns true if successful.

getLastPostResponse()

Returns a string containing the complete last response received from a post to a web server.

callDLL(dllFilename, functionName, [params]...)

Calls any function in any DLL given by the DLL file name and function name.  Additional simple parameters may also be passed, with their types being automatically converted to/from JavaScript.  String parameters in this version pass single byte characters (see callDLLW for wide).  Calling a DLL is an obvious security risk and so will prompt the user the first time a DLL level function is requested during the execution of a document.

callDLLW(dllFilename,

functionName, [params]...)

Wide character version of callDLL (see above).  In this version, all strings in the parameter list are passed as wide chars.

sceneLoad(newsceneid, filename, [inBackground])

Loads a new scene from disk or URL and assigns to to the newsceneid string.  If you pass true as the optional inBackground the scene will stream in a new thread.

sceneRemove(sceneid)

Unloads the scene with the given id.

sceneReload(sceneid)

Reloads the scene with the given id.

getLoadProgress(filename)

If the given file is being loaded in the background, this returns a float between 0 and 1 determining progress.

consoleClear()

Clears all of the output from the console.

uploadFile(srcFilename, destURL, [postprefix])

Uploads the given file as a form POST to the given URL with optional extra post data (see saveScreenCapture for postprefix format).  This is a Pro Edition feature only.

generateGUID()

Returns a new GUID as a string in the format {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} suitable for use in network settings.

datasourceAdd(id, type, connectionString)

Adds a new datasource to the document with the given string id.  The type can be 'textfile', 'oledb' or 'web'.

datasetAdd(id, sql, datasourceId, [refreshSeconds])

Adds a new dataset to the document with the given string id.  The sql string will be executed to read the data and the datasourceId determines the connection to use.  You can optionally pass a float for refreshing the data every so many seconds.

 

Remarks

 

System wide variables need to be declared in the document level script, outside of any function.  They can then be accessed from any script using the notation below.

 

Accessing script functions/variables

 

You can call functions defined in document script, or read/write variables.  Just prefix the function/variable with 'script.' to access...

 

system.script.<variable>

system.script.<function>

 

You can also change the whole script at runtime by setting the system.script.sourceCode value.  Note that when you change the script all variables defined in the script will be reset.  onInit will not be called automatically, but you could call it manually if you need to set up your variables in that function with the call to system.script.onInit().

 

See Also

 

Script Reference



Copyright ©2004 Worldweaver Ltd. DX Studio Home