Table Of Contents

Previous topic

std.graphics.ScaleDragHandler

Next topic

std.graphics

This Page

fl

Constructor

class fl()

Methods

exec(s)
Arguments:
  • s (String) – Script to execute in the UI.

Executes the given JavaScript in the UI. To maintain modularity of the UI from the server, this should only be used for debugging.

globalData(key)
Arguments:
  • key (String) – The name of the variable to read.
Returns:

The value of the global variable.

Gets the global data variable with the given key (name).

iterateUserData(func)
Arguments:
  • func (Function) – The function to call.

For each user X, calls the given function passing X’s user data as the parameter.

  //This example finds the high score for a game by iterating over each user's score.
var highscore = -1;
var highscore_user = "";
fl.iterateUserData(function(user) {
    if (user['score'] > highscore) {
        highscore = user['score'];
        highscore_user = user['viewer']['id'];
    }
});
system.print(highscore_user+" has the highest score of "+highscore+" points!\n");
onButtonPressed(func, me)
Arguments:
  • func (Function) – The callback to execute.
  • me (Presence) – The presence whose UI should trigger this callback. Defaults to system.self.

Sets the callback to be invoked when a button on the UI is pressed (the button’s callback must be set to notifyController). The callback takes as parameters the text on the button and the button’s scripter-defined metadata.

onConnection(func, me)
Arguments:
  • func (Function) – The callback to execute.
  • me (Presence) – The presence whose UI should trigger this callback. Defaults to system.self.

Sets the callback to be invoked when the UI for the given presence is served to an avatar. The callback takes as a parameter the ID of the avatar who requested the UI.

onUserDataDidChange(func, me)
Arguments:
  • func (Function) – The function to execute.
  • me (Presence) – The presence whose UI should trigger this callback. Defaults to system.self.

Sets the callback to be invoked after the UI for the given presence saves a user’s data to the server. The callback takes no parameters.

onUserDataWillChange(func, me)
Arguments:
  • func (Function) – The function to execute.
  • me (Presence) – The presence whose UI should trigger this callback. Defaults to system.self.

Sets the callback to be invoked just before the UI for the given presence saves a user’s data to the server. The callback takes as a parameter the new user data. If the callback returns false, the changes to user data will be rejected.

script(s, me, clearData)
Arguments:
  • s (String) – The script to set as the UI script for the presence.
  • me (Presence) – The presence to set the UI for. Defaults to system.self.
  • clearData (Boolean) – If true, all user and global data, including the IDs of avatars who have interacted with this UI, will be deleted.

Sets the UI script for the given presence (defaults to system.self). The UI script is a string of JavaScript code that will be executed in a dialog window when a user right-clicks on the given presence.

sendAllViewers(msg)
Arguments:
  • msg (Object) – The message to send.

Sends the given message to all avatars currently viewing any of the UIs defined for presences on this entity.

setGlobalData(key, value)
Arguments:
  • key (String) – The name of the variable to write.
  • value – The value to assign to the variable.

Sets the global data variable with the given key (name) to the given value.

userData(user, key)
Arguments:
  • user (Presence) – The ID of the avatar whose user data is to be retrieved.
  • key (String) – The name of the variable to read.
Returns:

The value of the user variable.

Gets the value of the user data variable with the given key (name), for the given user.