mob: a reference to the player mob of this client
mainOutput: name of the interface element to send default messages to (ex: 'interface1.output1' )
mainWebStyle: string containing CSS to be used as a web style (ex '.test{font-weight: bold;}.test2{color: #000;}' ); style can be referenced by the name 'default'
xEdgeLimit: amount of black tiles that can be seen on the left and right of the view
yEdgeLimit: amount of black tiles that can be seen on the top and bottom of the view
xViewEyeOffset: amount of pixels the client's view is offset by from the view eye on the x-axis
yViewEyeOffset: amount of pixels the client's view is offset by from the view eye on the y-axis
screenBackground: string containing a color (null for transparent) to set the client's screen background to, for example '#000' for black; default is '#000'
webBackground: a string containing the HTML to display behind the game screen; #web_background to set the style of the entire background
color: hex, rgb, rgba, or color matrix value; applies color filter to entire map; ex ( '#000' ); ex ( 'rgb(10, 20, 30)' )
ex (
[-1, 0, 0, 0, 1,
0, -1, 0, 0, 1,
0, 0, -1, 0, 1,
0, 0, 0, 1, 0,
0, 0, 0, 0, 1
]
)
mapView: an object containing variables for the mapView (ex: {'width': 640,'height':640} )
{
height: height in pixels of the map view on the game screen
width: width in pixels of the map view on the game screen
xPos: amount of pixels from the left for the map view to be drawn on the game screen
yPos: amount of pixels from the top for the map view to be drawn on the game screen
scale: an object {'width': 2, 'height': 2} containing width and height scaling information
angle: number between 0 and 2PI radians to set the mapView's angle to
xTiles: optional; only set if you want to change; number of tiles shown on the x-axis
yTiles: optional; only set if you want to change; number of tiles shown on the y-axis
}
screenView: an object containing variables for the screenView (ex: {'scaleTo': 'ratio', 'scaleNearest': true})
{
scaleNearest: true or false; default false; if true pixels will base themselves off nearest neighbor when scaled; if false pixels will be smoothed out to blend with other pixels when scaled
scaleTo: default 'normal'; how to handle scaling of the screen; possible values:
'normal': normal scaling
'ratio': keep aspect ratio
'multiple': scale to only multiples of two
'none': no scaling
}
onNew(pPar)
pPar: URL parameters sent when the client connected; loading a game URL such as "http://127.0.0.1:1234/?test" would send "test" into onNew as pPar on both the server and client-side
called: when a client object has been created
onDel()
called: when a client object has been deleted
onWindowResize()
CLIENT ONLY
called: when the client window is resized
onWindowFocus()
CLIENT ONLY
called: when the client window is focused
onWindowBlur()
CLIENT ONLY
called: when the client window loses focus
onScreenMove(pX, pY, pOldX, pOldY)
CLIENT ONLY
pX: the screen's new x position
pY: the screen's new y position
pOldX: the screen's old x position
pOldY: the screen's old y position
called: when the client screen moves
onScreenRender()
CLIENT ONLY
called: when the client screen is rendered
onConnect()
called: when a client has successfully connected to the world; if solo world, called when the main user loads
onDisconnect()
called: when a client has disconnected from the world; if solo world, called just before the world closes
onCommand(pCommand, pData)
pCommand: name of command
pData: object containing information for command
called: when a client or server sends a command using client.sendCommand
onMouseClick(pDiob, pX, pY, pButton)
pDiob: object mouse clicked
pX: the x position on the screen of the mouse
pY: the y position on the screen of the mouse
pButton: the button used; 1 for left, 2 for middle, 3 for right
called: called when the mouse clicks an object
onMouseDblClick(pDiob, pX, pY, pButton)
pDiob: object mouse double clicked
pX: the x position on the screen of the mouse
pY: the y position on the screen of the mouse
pButton: the button used; 1 for left, 2 for middle, 3 for right
called: called when the mouse double clicks an object
onMouseEnter(pDiob, pX, pY)
pDiob: object moused on to
pX: the x position on the screen of the mouse
pY: the y position on the screen of the mouse
called: called when the mouse moves onto an object
onMouseExit(pDiob, pX, pY)
pDiob: object moused off of
pX: the x position on the screen of the mouse
pY: the y position on the screen of the mouse
called: called when the mouse moves off of an object
onMouseMove(pDiob, pX, pY)
pDiob: object moused over
pX: the x position on the screen of the mouse
pY: the y position on the screen of the mouse
called: called when the mouse moves over an object
onMouseDown(pDiob, pX, pY, pButton)
pDiob: object moused down on
pX: the x position on the screen of the mouse
pY: the y position on the screen of the mouse
pButton: the button used; 1 for left, 2 for middle, 3 for right
called: called when a mouse button has been pressed while over an object
onMouseUp(pDiob, pX, pY, pButton)
pDiob: object moused up on
pX: the x position on the screen of the mouse
pY: the y position on the screen of the mouse
pButton: the button used; 1 for left, 2 for middle, 3 for right
called: called when a mouse button is released while over an object
onMouseWheelScrollUp(pDiob, pX, pY)
pDiob: object under the mouse; if any
pX: the x position on the screen of the mouse
pY: the y position on the screen of the mouse
called: called when the mouse wheel scroll is scrolled upward
onMouseWheelScrollDown(pDiob, pX, pY)
pDiob: object under the mouse; if any
pX: the x position on the screen of the mouse
pY: the y position on the screen of the mouse
called: called when the mouse wheel scroll is scrolled downward
onKeyDown(pKey)
pKey: code for the pressed key
called: called when a key is pressed down
onKeyUp(pKey)
pKey: code for the released key
called: called when a key is released
setMouseCursor(pCursor, pX, pY)
pCursor: a string containing the name of the cursor for built-in cursors, a URL path to an image, or a diob; built-in (auto, all-scroll, crosshair, default, help, inherit, move, pointer, progress, text, vertical-text, wait, no-drop, not-allowed, e-resize, n-resize, s-resize, w-resize, col-resize, row-resize, ne-resize, nw-resize, se-resize, sw-resize); passing a diob will use the diob's icon; blank for default
pX: optional; offsets the icon left or right by pX pixels
pY: optional; offsets the icon up or down by pY pixels
called: sets the cursor of the client
getPlayerMob()
called: returns the mob that the client is controlling
setPlayerMob(pMob)
called: sets the client's playerMob to pMob
getAccountName()
called: returns the name of the account the client is logged in with
setMacroAtlas(pMacro)
pMacro: name of macro file to set client macros to
called: changes the macro file the client uses
addCustomMacro(pName, pKey, pDown, pUp)
pName: name of the custom macro
pKey: key code that will execute the macro
pDown: optional; string containing the command to be executed when the key is pushed down; example 'test(1)' would execute the 'test' client command with one parameter equal to '1'
pUp: optional; string containing the command to be executed when the key is let go of; example 'test(1)' would execute the 'test' client command with one parameter equal to '1'
called: creates a new custom macro named pName with the keyDown command of pDown and the keyUp command of pUp; custom macros override macro atlas macros
removeCustomMacro(pName)
pName: name of the custom macro
called: removes the custom macro pName from the client's custom macros
getCustomMacroNames()
called: returns an array of custom macro names
setFocus(pVal1, pVal2)
pVal1: if an interface element, this element is focused; if a string, then used as interface file name
pVal2: if set and is string and pVal1 is string, then used as name of interface element in interface file with name pVal1
called: focuses on the interface element object
getFocus()
called: returns object currently being focused by this client
setEdgeLimit(pX, pY)
pX: number of black tiles visible on the left and right edges of the map; -1 for default
pY: number of black tiles visible on the top and bottom edges of the map; -1 for default
called: sets the edge limit of the map for the client
addInterfaceElement(pType, pInterface, pName, pX, pY, pArgs)
pType: type of interface object to add
pInterface: name of the interface to add the interface element to
pName: optional; name to give the element being added
pX: optional; x position to give the element
pY: optional; y position to the give the element
pArgs: optional; array of arguments to pass to the onNew event of the interface element being created
called: adds an interface element to the interface and returns it
removeInterfaceElement(pInterface, pName)
pInterface: name of the interface to remove an interface element from
pName: name of the interface element to remove
called: removes an interface element from the interface
getInterfaceElement(pInterface, pElement)
pInterface: name of the interface to get element from
pElement: name of the element to get
called: returns the interface element object of the specified interface
getInterfaceElements(pInterface, pType, pChild)
pInterface: name of the interface to get element from
pType: optional; string containing type path to return
pChild: optional; boolean that determines if child types are included
called: returns an array of interface elements on the interface pInterface depending on the provided arguments; if pType is not set, all elements on the interface will be returned; if pType is set but pChild is not, elements on the interface with the exact type of pType will be returned; if pType is set and pChild is set, all elements with the type pType or a parent type of pType will be returned; for example, if pType is set to 'Interface/A' with pChild undefined, all elements with the exact type of 'Interface/A' will be returned, but if pChild is set, then all types starting with 'Interface/A' on the interface will be returned
showInterface(pInterface, pElement, pForce)
pInterface: name of interface to show
pElement: optional; name of interface element in pInterface to show
pForce: optional; if set, all hidden elements will be forced to be shown
called: displays the interface of pInterface, if not already displayed, along with all elements of the interface with that are not hidden by default; if pElement is specified, it makes that element no longer hidden
hideInterface(pInterface, pElement)
pInterface: name of the interface to hide or the interface containing pElement
pElement: optional; name of interface lement in pInterface to hide
called: hides the interface of pInterface if pElement is not specified, otherwise it only hides pElement
playSound(pSound)
pSound: either a string with the name of a sound file, or a string containing the path of a Sound object, or an actual Sound object, or a basic object with the proper information; ex ( {'soundName': 'name', 'volume': 50} )
called: plays a sound to this client
outputText(pText, pDisplay)
pText: text to be displayed
pDisplay: interface element to output text to
called: outputs text to an interface element; if pDisplay is not set or is invalid, text goes to client.mainOutput
setLocalStorage(pKey, pData)
pKey: key used to reference the stored data
pData: data as a string to store locally for the client
called: stores pData as a string locally on the client's computer and can be referenced using pKey; leaving pKey and pData blank will clear all local storage; 3000 characters are allowed to be saved per game (keys and values combined)
getLocalStorage(pKey)
pKey: key used to get data stored locally on the client's computer
called: gets the data as a string that is stored with the key pKey on the client's computer
setViewEye(pDiob)
pDiob: diob to have the client's screen view centered on
called: sets the view eye of the client to be centered on pDiob; the default is the player mob
getViewEye()
called: returns the diob the client's screen eye is currently set to
setViewEyeOffsets(pX, pY)
pX: amount of pixels for the screen to be offset from the client's view eye on the x-axis
pY: amount of pixels for the screen to be offset from the client's view eye on the y-axis
called: sets the client's view eye offsets
getViewEyeOffsets()
called: returns an object {'x': x, 'y': y} containing the x and y offsets of client's view eye
getScreenPos()
called: returns an object {'x': x, 'y': y} containing the x and y position of the client's screen on the map
changeServer(pAddress)
pAddres: address for the server to move the client to; example '127.0.0.1:1234'
called: moves the client to a new server located at the address pAddress
getAddress()
called: returns address of the client, 'localhost' for local or 'ip:port' if connected to a server
getMapView()
called: returns a mapView object containing the information of the client's mapView; for example {'width': 640, 'height': 640} would mean the client's mapView is 640 by 640 pixels in size
setMapView(pView)
pView: an object containing new information for the client's mapView; for example {'width': 640, 'height': 640} would set the client's mapView to 640 by 640 pixels
called: sets the client's mapView to pView or default if pView is null
getScreenView()
called: returns a screenView object containing the information of the client's screenView; for example {'scaleTo': 'ratio', 'scaleNearest': true} would mean the client's screenView keeps its ratio and scales pixels to their nearest neighbor
setScreenView(pView)
pView: an object containing new information for the client's screenView; for example {'scaleTo': 'ratio', 'scaleNearest': true} would mean the client's screenView keeps its ratio and scales pixels to their nearest neighbor; 'scaleNearest' means pixels will stay pixelated and will not try to blend with other pixels, 'scaleTo': 'normal' means normal scaling, 'scaleTo': 'ratio' means the width and height of the window keep their aspect ratio when scaled, 'scaleTo': 'multiple' means the game will only show in scales that are multiples of two when scaled, 'scaleTo': 'none' prevents all scaling
called: sets the client's screenView to pView or default if pView is null
getWindowSize()
CLIENT ONLY
called: returns an object containing the width and height of the game window; ex: {'width': 100, 'height': 100}
setScreenSize(pWidth, pHeight)
CLIENT ONLY
pWidth: width as a number
pHeight: height as a number
called: sets the client's game screen size to pWidth width and pHeight height
getScreenSize()
CLIENT ONLY
called: returns an object containing the width and height of the game screen; ex: {'width': 100, 'height': 100}
addWebStyle(pName, pStyle)
pName: unique name of style
pStyle: text as CSS to add to the client
called: adds CSS style
removeWebStyle(pName)
pName: unique name of style
called: removes a CSS style with the name pName
getWebTag(pID)
CLIENT ONLY
pID: id of the web tag
called: returns a reference to the web tag with the id pID
setWebTagStyle(pID, pStyle, pValue)
pID: id of the web tag to set the style of
pStyle: type of style to set
pValue: value as a string to set the style to
called: sets the style of pStyle to the value of pValue of the web tag with the id pID
setWebTagContent(pID, pContent)
pID: id of the web tag to set the content of
pContent: string containing the content to change the web tag's content to
called: sets the content of the web tag with the id pID to the value of pContent
getWebTagContent(pID, pContent)
CLIENT ONLY
pID: id of the web tag to get the content of
called: returns the content of the web tag with the id of pID
setWebTagFocus(pID)
pID: id of the web tag to set focus to
called: sets the focus on the web tag with the id pID
callWebTagEvent(pID, pEvent)
pID: id of the web tag to call the event of
pEvent: name of the event to call; onMouseDown, onMouseUp, onMouseClick, onMouseDblClick, onMouseMove
called: executes the event pEvent of the web tag with the id pID
removeWebTag(pID)
pID: id of the web tag to remove from the client's screen
called: removes a web tag with the id of pID from the client's screen
addWebScript(pName, pLink, pFunc)
CLIENT ONLY
pName: name to give the script
pLink: link to the JavaScript file to load
pFunc: function to call after the JavaScript file has loaded
called: loads a JavaScript file into the project
removeWebScript(pName)
CLIENT ONLY
pName: name of script to remove
called: removes the script with the pName name from the game
evalWebScript(pScript)
pScript: a string containing the JavaScript code to evaluate
called: evaluates the JavaScript code in the pScript string
callCommand(pCommand, pArgs)
pCommand: name of the client command to call
pArgs: array of arguments to pass to the command
called: calls the client command of pCommand with the arguments of pArgs
addCommand(pCommand, pFunc)
pCommand: name of the client command to be added
pFunc: function to be called when the command is executed
called: adds a new command to the client's commands; if pFunc is null and pCommand is the name of an pre-defined command, that command will be added
removeCommand(pCommand)
pCommand: name of the client command to remove
called: removes the client command from the client's commands
sendCommand(pCommand, pData)
pCommand: name of command to send
pData: an object containing data to be sent
called: sends a command to a client or server, depending on where the code is executed; client code executing this will send the command to the server; server code executing this will send the command to the client
getNavigator()
called: returns an object containing information about the client's browser and operating system; example {'platform': 'Netscape', 'version': 'Chrome/38.0.2125.104', 'vendor': 'Google', 'language': 'en-US', 'system': 'Windows 95'}
setScreenBackground(pBack)
pBack: string containing a color, for example '#000' for black
called: sets the background of the client's screen background
setWebBackground(pBack)
pBack: string containing HTML to set use in the web box behind the game screen
called: sets the HTML of the web box behind the game screen
createTopScreen(pName, pLayer, pSet)
pName: name of the top screen to create
pLayer: optional; layer to give the screen
pSet: optional; settings object; ex ( {'scaleNearest': true} );
{
'scaleNearest': true to prevent pixels from being blended together, false to smooth pixels
}
called: creates a new top screen named pName with the layer pLayer
setTopScreen(pName, pNewName, pNewLayer, pNewData, pNewSet)
pName: name of the top screen to set
pNewName: new name of the top screen
pNewLayer: new layer of the top screen
pNewData: optional; data to add to the screen
pNewSet: optional; new settings object
called: changes the name and layer of the top screen with the name pName; adding data optional
getTopScreen(pName, pType)
pName: optional; name of the top screen to get the data of
pType: type of data to get; 'url' or 'pixels'
called: grabs an object with the screen name, layer, settings, and either an array of pixel data or a data url depending on pType for the entire screen named pName or the default top screen if no name is given. The array of pixel data can then be changed and used elsewhere or drawn onto another screen. To read the width and height you could use object.width and object.height, where object is the object returned by the function. The object data array is as follows: object.data[0] is the red value (0-255) of the pixel at 0,0, object.data[1] is the green value (0-255) of the pixel at 0,0, object.data[2] is the blue value (0-255) of the pixel at 0,0, and object.data[3] is the alpha value (0-255) of the pixel at 0,0. Then object.data[4], object.data[5], object.data[6], and object.data[7] are the respective values for the pixel at 1,0. This trend continues through the whole array for every pixel. object ex: {'name': '', 'layer': 1, 'data': ''}
topScreenDraw(pArgs, pName)
pArgs: an object or array of objects which determines the settings of the draw
{
'type': type of draw
{
'image': draw an image
'image': either a path to an image or a diob, in which case the diob's icon will be used
'x': x position to draw the image
'y': y position to draw the image
'width': width of the image when drawn
'height': height of the image when drawn
'clipX': optional; x value inside of the image to start clipping
'clipY': optional; y value inside of the image to start clipping
'clipW': optional; width of the area to clip
'clipH': optional; height of the area to clip
'text': draw text
'text': text to draw
'color': color of the text; rgb value or hex; ex ( 'rgb(10, 10, 10)' ); ex ( '#000' )
'x': x position to draw the text
'y': y position to draw the text
'font': font size and type to use; ex ( '12px monospace' )
'maxWidth': max width to draw the text (shrink the text if it wont fit)
'fillRect': draw a filled in rectangle
'color': color of the rect; rgb value or hex; ex ( 'rgb(10, 10, 10)' ); ex ( '#000' )
'x': x position to start the rect
'y': y position to start the rect
'width': width of the rect
'height': height of the rect
'strokeRect': draw an unfilled rectangle
'color': color of the rect; rgb value or hex; ex ( 'rgb(10, 10, 10)' ); ex ( '#000' )
'x': x position to start the rect
'y': y position to start the rect
'width': width of the rect
'height': height of the rect
'clearRect': clear a rectangular area on the screen
'x': x position to start the area to clear
'y': y position to start the area to clear
'width': width of the area to clear
'height': height of the area to clear
'fillPath': create a path and fill it in (shapes)
'color': color to fill; rgb value or hex; ex ( 'rgb(10, 10, 10)' ); ex ( '#000' )
'path': array of path objects
{
'type': type of path object
'move': move path cursor
'line': draw path line from current cursor to new position
'x': x position
'y': y position
}
'strokePath': create a path of lines
'color': color to stroke; rgb value or hex; ex ( 'rgb(10, 10, 10)' ); ex ( '#000' )
'path': array of path objects
{
'type': type of path object
'move': move path cursor
'line': draw path line from current cursor to new position
'x': x position
'y': y position
}
}
'angle': angle of the draw; 0 to 2PI (radians)
'composite': how the draw will happen; possible values: source-over, source-atop, source-in, source-out, destination-over, destination-atop, destination-in, destination-out, lighter, copy, xor
'alpha': how visible the draw is; 0 to 1 (decimal)
}
pName: optional; name of the screen to draw on to
called: performs the specified draw function using the specified pArgs object; ex ( {'type': 'image', 'image': this, 'x': 1, 'y': 1} )
toggleScreenDrawing(pVal)
pVal: optional; true to resume screen drawing, false to pause all screen drawing, 'map' to pause only the map drawing
called: toggles screen drawing on and off
setColor(pColor)
pColor: hex, rgb, rgba, or color matrix value; applies color filter to entire map; ex ( '#000' ); ex ( 'rgb(10, 20, 30)' )
ex (
[-1, 0, 0, 0, 1,
0, -1, 0, 0, 1,
0, 0, -1, 0, 1,
0, 0, 0, 1, 0,
0, 0, 0, 0, 1
]
)
called: sets this client's color to pColor
addOverlay(pOver, pAppearance)
pOver: string of the type of object or overlay to add an overlay of or actual diob to get type from
pAppearance: optional; if true, this overlay will be be treated as if it is part of the the parent's actual appearance - appearance settings such as angle and alpha of the parent will be used for this overlay and the overlay will be drawn directly on top of the parent so no other diobs that are not an overlay of the parent can appear between it and the parent (it will basically be an extension of the parent's icon); if this is false, the overlay will be treated as an independent diob that just follows the parent around
called: adds an overlay to the client which is a visual icon that always follows the screen; returns the new overlay
removeOverlay(pOver)
pOver: string of the type of object or overlay to remove or actual overlay to remove
called: removes all overlays with the pOver type or the exact overlay matching pOver
getOverlays()
called: returns an array of the client's overlays
setOverlays(pOver)
pOver: array of overlays to set this client's overlays to
called: sets the client's overlays to the array pOver
getPlane(pPlane)
CLIENT ONLY
pPlane: value of plane to get
called: returns the diob plane pPlane; you can then alter is like any other diob and all visual changes will be applied to all diobs on this plane
setPlane(pPlane, pVar, pVal)
pPlane: value of plane to set
pVar: string containing name of variable to set
pVal: value to give this plane's pVar variable
called: sets the variable pVar to pVal for the plane pPlane