@@ -1631,10 +1631,46 @@ public enum ScriptActionType {
16311631 }
16321632 })),
16331633
1634+ RANDOM_INT (builder -> builder .name ("Random Int" )
1635+ .description ("Generates a random whole number between two other numbers." )
1636+ .icon (Items .HOPPER )
1637+ .category (ScriptActionCategory .NUMBERS )
1638+ .arg ("Result" , ScriptActionArgumentType .VARIABLE )
1639+ .arg ("Min" , ScriptActionArgumentType .NUMBER )
1640+ .arg ("Max" , ScriptActionArgumentType .NUMBER )
1641+ .action (ctx -> {
1642+ int min = (int ) ctx .value ("Min" ).asNumber ();
1643+ int max = (int ) ctx .value ("Max" ).asNumber ();
1644+ Random random = new Random ();
1645+ int result = random .nextInt (max + 1 - min ) + min ;
1646+ ctx .context ().setVariable (
1647+ ctx .variable ("Result" ).name (),
1648+ new ScriptNumberValue (result )
1649+ );
1650+ })),
1651+
1652+ RANDOM_DOUBLE (builder -> builder .name ("Random Double" )
1653+ .description ("Generates a random floating point number between two other numbers." )
1654+ .icon (Items .HOPPER )
1655+ .category (ScriptActionCategory .NUMBERS )
1656+ .arg ("Result" , ScriptActionArgumentType .VARIABLE )
1657+ .arg ("Min" , ScriptActionArgumentType .NUMBER )
1658+ .arg ("Max" , ScriptActionArgumentType .NUMBER )
1659+ .action (ctx -> {
1660+ double min = ctx .value ("Min" ).asNumber ();
1661+ double max = ctx .value ("Max" ).asNumber ();
1662+ double result = Math .random () * (max - min ) + min ;
1663+ ctx .context ().setVariable (
1664+ ctx .variable ("Result" ).name (),
1665+ new ScriptNumberValue (result )
1666+ );
1667+ })),
1668+
16341669 RANDOM_NUMBER (builder -> builder .name ("Random Number" )
16351670 .description ("Generates a random number between two other numbers." )
16361671 .icon (Items .HOPPER )
16371672 .category (ScriptActionCategory .NUMBERS )
1673+ .deprecate (RANDOM_DOUBLE )
16381674 .arg ("Result" , ScriptActionArgumentType .VARIABLE )
16391675 .arg ("Min" , ScriptActionArgumentType .NUMBER )
16401676 .arg ("Max" , ScriptActionArgumentType .NUMBER )
@@ -1649,7 +1685,7 @@ public enum ScriptActionType {
16491685 })),
16501686
16511687 REPEAT_FOREVER (builder -> builder .name ("RepeatForever" )
1652- .description (new String []{ "Repeats for eternity." , "Make sure to have a Stop Repetition, Stop Codeline or Wait somewhere in the code!" , "There 's a lagslayer for the repetition actions." , "It activates after 100000 iterations with no Wait."} )
1688+ .description ("Repeats for eternity.\n Make sure to have a Stop Repetition, Stop Codeline or Wait somewhere in the code!\n There 's a lagslayer for the repetition actions.\n It activates after 100000 iterations with no Wait." )
16531689 .icon (Items .GOLD_INGOT )
16541690 .category (ScriptActionCategory .MISC )
16551691 .hasChildren (true )
@@ -1658,7 +1694,7 @@ public enum ScriptActionType {
16581694 ctx .scheduleInner (null , context -> context .setLastIfResult (true ));
16591695 })),
16601696 ELSE (builder -> builder .name ("Else" )
1661- .description (new String []{ "Executes if the last IF condition failed." , "And ELSE also works as a valid IF condition for ELSE."} )
1697+ .description ("Executes if the last IF condition failed.\n And ELSE also works as a valid IF condition for ELSE." )
16621698 .icon (Items .END_STONE )
16631699 .category (ScriptActionCategory .MISC )
16641700 .group (ScriptGroup .CONDITION )
@@ -1707,7 +1743,7 @@ public enum ScriptActionType {
17071743 })),
17081744
17091745 REGEX_REPLACE_TEXT (builder -> builder .name ("Replace Text using Regex" )
1710- .description (new String []{ "Searches for part of a text" , "using a regex and replaces it."} )
1746+ .description ("Searches for part of a text\n using a regex and replaces it." )
17111747 .icon (Items .LEAD , true )
17121748 .arg ("Result" , ScriptActionArgumentType .VARIABLE )
17131749 .arg ("Text to change" , ScriptActionArgumentType .TEXT )
@@ -1894,17 +1930,10 @@ private ScriptActionType category(ScriptActionCategory category) {
18941930
18951931 private ScriptActionType description (String description ) {
18961932 this .description .clear ();
1897- this .description .add ( description );
1933+ this .description .addAll ( Arrays . asList ( description . split ( " \n " , - 1 )) );
18981934 return this ;
18991935 }
19001936
1901- private ScriptActionType description (String [] description ) {
1902- this .description .clear ();
1903-
1904- this .description .addAll (Arrays .asList (description ));
1905-
1906- return this ;
1907- }
19081937 private ScriptActionType group (ScriptGroup group ) {
19091938 this .group = group ;
19101939 return this ;
0 commit comments