Dice Roller

Available in version 2.16+

The dice roller feature allows users to share the results of rolling different combinations of dice, by simply typing a command in the chat: /roll <expression>

Examples

Command in chat

Result

/roll

Roll a dice of 6 faces

/roll 2D12

Roll 2 dice of 12 faces and add the results together

/roll 3D6 + 1D12

Roll 3 dice of 6 faces and 1 dice of 12 faces, and add the results together

Note: /dice, /diceroll, /rolldice are also supported and equivalent to /roll.

Dice roll action

To use a dice roll in an action use the following. Change the /roll command to suit your purposes.

{"action":"rollDice", "expression":"2d6 + 10"}

To use a dice roll in an action use the following. Change the /roll command to suit your purposes.

{"action":"executeScript","script":"LB.uiController.bottomBar.multiUser.input.val('/roll 3d20 + 10');LB.chat.sendButtonClicked();"}

Tutorial: Create a clickable multiuser dice with sound

See the example in action here https://app.learnbrite.com/dashboard/spaces/visit/spc9e6e16edfe37ee62bbd826 

Add the dice 3D item to the space

Pink die https://cache.learnbrite.com/_assets_/environment/exported_gltf/inventory/red_dice/pink_dice.gltf

Black die https://cache.learnbrite.com/_assets_/environment/exported_gltf/inventory/red_dice/black_dice.gltf

Green die https://cache.learnbrite.com/_assets_/environment/exported_gltf/inventory/red_dice/green_dice.gltf

Red die https://cache.learnbrite.com/_assets_/environment/exported_gltf/inventory/red_dice/red_dice.gltf 

Change the item name

Change the name of the 3D item to Game dice

Stop the default animation On Start

In the On Start action add a conversation using Edit action

Add a Script action with the following

var myObject = LB.Utils.findItem("Game dice");
myObject.userData.animationMixer.clipAction(myObject.userData.animations[
0]).stop()

Roll the dice On Click

In On Click action add a conversation using Edit action

Add a Script action with the following

LB.Actions.executeAction(null, {"action":"executeScript","script":"var myObject = LB.Utils.findItem('Game dice'); myObject.userData.animationMixer.clipAction(myObject.userData.animations[0]).play();", "propagate":true});
LB.uiController.bottomBar.multiUser.input.val(
'/roll 1d6');
setTimeout(
function(){LB.Actions.playSFX({url:"https://cache.learnbrite.com/_assets_/audio/Dice_roll_0004526.mp3", volume:50,propagate:true});},4000);
setTimeout(
function(){LB.chat.sendButtonClicked();LB.Actions.executeAction(null, {"action":"executeScript","script":"var myObject = LB.Utils.findItem('Game dice'); myObject.userData.animationMixer.clipAction(myObject.userData.animations[0]).stop();", "propagate":true});},5000);

This will:

  1. Trigger the dice animation for everyone in the space
  2. Run the roll dice command and print the result in chat
  3. Play the dice rolling sound
  4. Stop the dice from animating

Enjoy!

How useful was this article?

Click on a star to rate it!

We are sorry that this article was not useful for you!

Let us improve this article!

Tell us how we can improve this article?