Link Search Menu Expand Document

App

Represents the AlloApp.

Mediates communication with backend, and maintains the runloop. Create one of these, configure it, connect it and run it, and you have an alloapp.

Constructor

 local app = App(client)

Arguments

Name Type Description
client Client The AlloNet client wrapper

Returns

Nothing


Methods

app:openPopupNearHand (popup, hand, distance, entity)

Open a ui.View as a popup near a hand. Call from e g a button handler to display it right where the user could easily interact with it. You can use this to open a “new item” or a “settings” UI near a user. Since apps are multi-user, sometimes it’s nice to give a user some personal UI that they can do input in, so that they don’t have to fight over control of input with another user.

Arguments

Name Type Description
popup ui.View The view to show to the user. It will be instantiated in
the world at the appropriate location.    
hand Entity The hand entity that the popup should be shown near.
In a button handler, this is the first argument to the callback.    
distance number The distance in meters from the hand to show. Default 0.6
entity Callback(view, ) cb The callback to call when the popup is present in-world

Returns

Nothing


app:addWristWidget (avatarOrHand, widget, callback)

Add a widget to the user’s left wrist, and arrange it to fit with the other widgets already present. Use this to provide some portable UI to the user, such as a remote control.

Arguments

| Name | Type | Description | | ———— | ————– | ————— | | avatarOrHand | Entity | The avatar of the user to add the widget to. Can also be any child entity to the avatar, such as a hand, and the avatar will be looked up for you. | | widget | ui.View | The widget to add. Must be at most 3cm wide. You can make it a button or something that opens more UI nearby if you need more space. | | callback | Callback(bool) | Callback for when adding widget finishes. Its argument is true if successful. |

Returns

Nothing


app:scheduleAction (delay, repeats, callback)

Schedule work to be done later

Arguments

Name Type Description
delay number The time (in seconds) until the callback is called.
repeats boolean Whether The callback should repeat (with the same delay) or only occur once.
callback function The function to be called (with no arguments).

Returns

Nothing


app:clientTime ()

Current client time. This is monotonically increasing.

Arguments

None

Returns

Nothing


app:serverTime ()

Current server time. Might jump around a little to compensate for lag.

Arguments

None

Returns

Nothing


app:updateComponents (changes, removals)

Asks the backend to update components on the server.

Use this to update things you’ve specified in :specification() but now want to change.

Arguments

Name Type Description
changes table A table with the desired changes, for example: {transform={…}, collider={…}}
removals table A table with the keys of componets to remove, for example: {“collider”, “skeleton”}

Returns

Nothing