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"); |
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}); |
This will:
- Trigger the dice animation for everyone in the space
- Run the roll dice command and print the result in chat
- Play the dice rolling sound
- Stop the dice from animating
Enjoy!