<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
	<id>https://www.lets-role.wiki/index.php?action=history&amp;feed=atom&amp;title=Manage_Roll</id>
	<title>Manage Roll - Historique des versions</title>
	<link rel="self" type="application/atom+xml" href="https://www.lets-role.wiki/index.php?action=history&amp;feed=atom&amp;title=Manage_Roll"/>
	<link rel="alternate" type="text/html" href="https://www.lets-role.wiki/index.php?title=Manage_Roll&amp;action=history"/>
	<updated>2026-05-25T04:40:48Z</updated>
	<subtitle>Historique des versions pour cette page sur le wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://www.lets-role.wiki/index.php?title=Manage_Roll&amp;diff=105&amp;oldid=prev</id>
		<title>Neo-Teyrall : Page créée avec «  This page explains how to perform dice rolls using a script, how to present sub-rolls to the user, and how to interact with the results.  Several examples of roll construction are presented here.  Among the different ways to build a roll, the most recommended one is using the &#039;&#039;&#039;RollBuilder&#039;&#039;&#039;. ----  == Simple Roll == A simple roll consists of performing a dice roll triggered by a button through a script.  This action can be done without a complex script.  === R... »</title>
		<link rel="alternate" type="text/html" href="https://www.lets-role.wiki/index.php?title=Manage_Roll&amp;diff=105&amp;oldid=prev"/>
		<updated>2025-10-08T16:59:36Z</updated>

		<summary type="html">&lt;p&gt;Page créée avec «  This page explains how to perform dice rolls using a script, how to present sub-rolls to the user, and how to interact with the results.  Several examples of roll construction are presented here.  Among the different ways to build a roll, the most recommended one is using the &amp;#039;&amp;#039;&amp;#039;RollBuilder&amp;#039;&amp;#039;&amp;#039;. ----  == Simple Roll == A simple roll consists of performing a dice roll triggered by a button through a script.  This action can be done without a complex script.  === R... »&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nouvelle page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
This page explains how to perform dice rolls using a script, how to present sub-rolls to the user, and how to interact with the results.  Several examples of roll construction are presented here.&lt;br /&gt;
&lt;br /&gt;
Among the different ways to build a roll, the most recommended one is using the &amp;#039;&amp;#039;&amp;#039;RollBuilder&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Simple Roll ==&lt;br /&gt;
A simple roll consists of performing a dice roll triggered by a button through a script.  This action can be done without a complex script.&lt;br /&gt;
&lt;br /&gt;
=== Required Components ===&lt;br /&gt;
For this script, you will need:&lt;br /&gt;
&lt;br /&gt;
* an icon that acts as a button (&amp;#039;&amp;#039;&amp;lt;code&amp;gt;roll1_button&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;),&lt;br /&gt;
* a text input containing the dice expression (&amp;#039;&amp;#039;&amp;lt;code&amp;gt;roll1_value&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;).&lt;br /&gt;
&lt;br /&gt;
=== The script performs the following actions: ===&lt;br /&gt;
&lt;br /&gt;
# retrieves the components by their ID, &lt;br /&gt;
# creates a function that prepares the roll using the provided expression (for example: &amp;#039;&amp;#039;1d20&amp;#039;&amp;#039;), &lt;br /&gt;
# connects this function to the “click” event of the button.&lt;br /&gt;
&lt;br /&gt;
 const initSimpleRoll = function (sheet, id_roll_button, id_roll_value) {&lt;br /&gt;
     // 1 &lt;br /&gt;
     let roll_button = sheet.get(id_roll_button);&lt;br /&gt;
     let roll_value = sheet.get(id_roll_value);&lt;br /&gt;
     // 2&lt;br /&gt;
     const roll = function () {&lt;br /&gt;
         log(&amp;quot;START : simple roll cliked&amp;quot;);&lt;br /&gt;
         // creer le jet&lt;br /&gt;
         let roll = new RollBuilder(sheet);&lt;br /&gt;
             // configuer le jet&lt;br /&gt;
             roll = roll.expression(roll_value.value());&lt;br /&gt;
             roll = roll.visibility(&amp;quot;all&amp;quot;);&lt;br /&gt;
             roll = roll.title(&amp;quot;Simple Roll&amp;quot;);&lt;br /&gt;
             // lancer le jet&lt;br /&gt;
             roll.roll();&lt;br /&gt;
             log(&amp;quot;END : simple roll clicked&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     // 3 &lt;br /&gt;
     roll_button.on(&amp;quot;click&amp;quot;, roll);&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Add an Action to a Roll ==&lt;br /&gt;
In many game systems, player actions consist of multiple rolls.  For example, an attack may require a first roll to determine if the target is hit, and a second roll to calculate the damage.&lt;br /&gt;
&lt;br /&gt;
You can add &amp;#039;&amp;#039;&amp;#039;sub-actions&amp;#039;&amp;#039;&amp;#039; to your rolls.  These actions appear as small white buttons below the result of the main roll.&lt;br /&gt;
&lt;br /&gt;
=== View Composition ===&lt;br /&gt;
For this example, you will need: &lt;br /&gt;
&lt;br /&gt;
* two text inputs containing the expressions of the main and sub-rolls (&amp;#039;&amp;#039;&amp;lt;code&amp;gt;roll2_value&amp;lt;/code&amp;gt;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;lt;code&amp;gt;roll2_action_value&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;),&lt;br /&gt;
* one button to trigger the first roll (&amp;#039;&amp;#039;&amp;lt;code&amp;gt;roll2_button&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;).&lt;br /&gt;
&lt;br /&gt;
The corresponding script:&lt;br /&gt;
&lt;br /&gt;
# retrieves the components by their IDs,&lt;br /&gt;
# creates a function that performs the sub-action when it is clicked,&lt;br /&gt;
# prepares the first roll and attaches the action to it,&lt;br /&gt;
# connects everything to the click event on the button.&lt;br /&gt;
&lt;br /&gt;
 const initActionRoll = function (sheet, id_roll_button, id_roll_value, id_roll_action_value) {&lt;br /&gt;
     // 1&lt;br /&gt;
     let roll_button = sheet.get(id_roll_button);&lt;br /&gt;
     let roll_value = sheet.get(id_roll_value);&lt;br /&gt;
     let roll_action_value = sheet.get(id_roll_action_value);&lt;br /&gt;
     // 2  &lt;br /&gt;
     const rollAction = function (result) {&lt;br /&gt;
         log(&amp;quot;START : action roll cliked&amp;quot;);&lt;br /&gt;
         let roll_action = new RollBuilder(sheet);&lt;br /&gt;
         roll_action = roll_action.expression(roll_action_value.value());&lt;br /&gt;
         roll_action = roll_action.visibility(&amp;quot;all&amp;quot;);&lt;br /&gt;
         roll_action = roll_action.title(&amp;quot;Action Roll&amp;quot;);&lt;br /&gt;
         roll_action.roll();&lt;br /&gt;
         log(&amp;quot;END : action roll clicked&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     // 3&lt;br /&gt;
     const roll = function () {&lt;br /&gt;
         log(&amp;quot;START : roll cliked&amp;quot;);&lt;br /&gt;
         let roll = new RollBuilder(sheet);&lt;br /&gt;
         roll = roll.expression(roll_value.value());&lt;br /&gt;
         roll = roll.visibility(&amp;quot;all&amp;quot;);&lt;br /&gt;
         roll = roll.title(&amp;quot;Roll&amp;quot;);&lt;br /&gt;
         roll = roll.addAction(&amp;quot;Action name&amp;quot;, rollAction);&lt;br /&gt;
         roll.roll();&lt;br /&gt;
         log(&amp;quot;END : roll clicked&amp;quot;);&lt;br /&gt;
     }&lt;br /&gt;
     // 4&lt;br /&gt;
     roll_button.on(&amp;quot;click&amp;quot;, roll);&lt;br /&gt;
 }&lt;br /&gt;
This allows you to add multiple actions to your rolls.  &lt;br /&gt;
&lt;br /&gt;
For each additional action, simply create a new function (&amp;lt;nowiki&amp;gt;&amp;#039;&amp;#039;rollAction1&amp;#039;&amp;#039;, &amp;#039;&amp;#039;rollAction2&amp;#039;&amp;#039;&amp;lt;/nowiki&amp;gt;, etc.) with the desired behavior and add it to the main roll.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;nowiki&amp;gt;&amp;#039;&amp;#039;results&amp;#039;&amp;#039;&amp;lt;/nowiki&amp;gt; argument passed to an action function contains the result of the parent roll.  &lt;br /&gt;
&lt;br /&gt;
This allows you to detect specific cases such as critical hits and adjust the behavior accordingly.&lt;br /&gt;
&lt;br /&gt;
== Automatic Action ==&lt;br /&gt;
An automatic action is a secondary effect that triggers as soon as a roll is completed.  It can be used, for example, to:&lt;br /&gt;
&lt;br /&gt;
* automatically record the result of a roll on the sheet,&lt;br /&gt;
* update a resource such as mana or health points.&lt;br /&gt;
&lt;br /&gt;
==== Building the View ====&lt;br /&gt;
For this example, you will need:&lt;br /&gt;
&lt;br /&gt;
* a button to trigger the roll (&amp;lt;code&amp;gt;roll3_button&amp;lt;/code&amp;gt;),&lt;br /&gt;
* a text input containing the roll expression (&amp;lt;code&amp;gt;roll3_value&amp;lt;/code&amp;gt;),&lt;br /&gt;
* a component where the result will be displayed (&amp;lt;code&amp;gt;roll3_mark&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
The associated script: &lt;br /&gt;
&lt;br /&gt;
# retrieves the components by their IDs, &lt;br /&gt;
# creates a function that writes the roll result automatically in the designated component, &lt;br /&gt;
# creates a function that is triggered when the button is clicked, &lt;br /&gt;
# links both functions together to execute the automatic action.&lt;br /&gt;
&lt;br /&gt;
 const initAutoAction = function(sheet,id_roll_button, id_roll_value, id_roll_mark){&lt;br /&gt;
     // 1 &lt;br /&gt;
     let roll_button = sheet.get(id_roll_button);&lt;br /&gt;
     let roll_value = sheet.get(id_roll_value);&lt;br /&gt;
     let roll_mark = sheet.get(id_roll_mark);&lt;br /&gt;
     //2&lt;br /&gt;
     const autoAction = function (result) {&lt;br /&gt;
         log(&amp;quot;START : action roll cliked&amp;quot;);&lt;br /&gt;
         roll_mark.value(result.total);&lt;br /&gt;
     }&lt;br /&gt;
     // 3&lt;br /&gt;
     const roll = function () {&lt;br /&gt;
         log(&amp;quot;START : roll cliked&amp;quot;);&lt;br /&gt;
         let roll = new RollBuilder(sheet);&lt;br /&gt;
         roll = roll.expression(roll_value.value());&lt;br /&gt;
         roll = roll.visibility(&amp;quot;all&amp;quot;);&lt;br /&gt;
         roll = roll.title(&amp;quot;Roll&amp;quot;);&lt;br /&gt;
         // renseigner la fonction automatique&lt;br /&gt;
         roll = roll.onRoll(autoAction);&lt;br /&gt;
         roll.roll();&lt;br /&gt;
         log(&amp;quot;END : roll clicked&amp;quot;)&lt;br /&gt;
     }&lt;br /&gt;
     //4 &lt;br /&gt;
     roll_button.on(&amp;quot;click&amp;quot;, roll);&lt;br /&gt;
 }&lt;br /&gt;
This approach allows you to add many automation features to your character sheet.  &lt;br /&gt;
&lt;br /&gt;
You can also combine regular and automatic actions, or even nest actions inside other actions to create complex game mechanics.&lt;/div&gt;</summary>
		<author><name>Neo-Teyrall</name></author>
	</entry>
</feed>