@@ -1606,8 +1606,26 @@ public enum ScriptActionType {
16061606 }
16071607 })),
16081608
1609- RANDOM_NUMBER (builder -> builder .name ("Random Number" )
1610- .description ("Generates a random number between two other numbers." )
1609+ RANDOM_INT (builder -> builder .name ("Random Int" )
1610+ .description ("Generates a random whole number between two other numbers." )
1611+ .icon (Items .HOPPER )
1612+ .category (ScriptActionCategory .NUMBERS )
1613+ .arg ("Result" , ScriptActionArgumentType .VARIABLE )
1614+ .arg ("Min" , ScriptActionArgumentType .NUMBER )
1615+ .arg ("Max" , ScriptActionArgumentType .NUMBER )
1616+ .action (ctx -> {
1617+ int min = (int ) ctx .value ("Min" ).asNumber ();
1618+ int max = (int ) ctx .value ("Max" ).asNumber ();
1619+ Random random = new Random ();
1620+ int result = random .nextInt (max + 1 - min ) + min ;
1621+ ctx .context ().setVariable (
1622+ ctx .variable ("Result" ).name (),
1623+ new ScriptNumberValue (result )
1624+ );
1625+ })),
1626+
1627+ RANDOM_DOUBLE (builder -> builder .name ("Random Double" )
1628+ .description ("Generates a random floating point number between two other numbers." )
16111629 .icon (Items .HOPPER )
16121630 .category (ScriptActionCategory .NUMBERS )
16131631 .arg ("Result" , ScriptActionArgumentType .VARIABLE )
@@ -1623,8 +1641,26 @@ public enum ScriptActionType {
16231641 );
16241642 })),
16251643
1644+ RANDOM_NUMBER (builder -> builder .name ("Random Number" )
1645+ .description ("Generates a random number between two other numbers." )
1646+ .icon (Items .HOPPER )
1647+ .category (ScriptActionCategory .NUMBERS )
1648+ .deprecate (RANDOM_DOUBLE )
1649+ .arg ("Result" , ScriptActionArgumentType .VARIABLE )
1650+ .arg ("Min" , ScriptActionArgumentType .NUMBER )
1651+ .arg ("Max" , ScriptActionArgumentType .NUMBER )
1652+ .action (ctx -> {
1653+ double min = ctx .value ("Min" ).asNumber ();
1654+ double max = ctx .value ("Max" ).asNumber ();
1655+ double result = Math .random () * (max - min ) + min ;
1656+ ctx .context ().setVariable (
1657+ ctx .variable ("Result" ).name (),
1658+ new ScriptNumberValue (result )
1659+ );
1660+ })),
1661+
16261662 REPEAT_FOREVER (builder -> builder .name ("RepeatForever" )
1627- .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."} )
1663+ .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." )
16281664 .icon (Items .GOLD_INGOT )
16291665 .category (ScriptActionCategory .MISC )
16301666 .hasChildren (true )
@@ -1633,7 +1669,7 @@ public enum ScriptActionType {
16331669 ctx .scheduleInner (null , context -> context .setLastIfResult (true ));
16341670 })),
16351671 ELSE (builder -> builder .name ("Else" )
1636- .description (new String []{ "Executes if the last IF condition failed." , "And ELSE also works as a valid IF condition for ELSE."} )
1672+ .description ("Executes if the last IF condition failed.\n And ELSE also works as a valid IF condition for ELSE." )
16371673 .icon (Items .END_STONE )
16381674 .category (ScriptActionCategory .MISC )
16391675 .group (ScriptGroup .CONDITION )
@@ -1682,7 +1718,7 @@ public enum ScriptActionType {
16821718 })),
16831719
16841720 REGEX_REPLACE_TEXT (builder -> builder .name ("Replace Text using Regex" )
1685- .description (new String []{ "Searches for part of a text" , "using a regex and replaces it."} )
1721+ .description ("Searches for part of a text\n using a regex and replaces it." )
16861722 .icon (Items .LEAD , true )
16871723 .arg ("Result" , ScriptActionArgumentType .VARIABLE )
16881724 .arg ("Text to change" , ScriptActionArgumentType .TEXT )
@@ -1869,17 +1905,11 @@ private ScriptActionType category(ScriptActionCategory category) {
18691905
18701906 private ScriptActionType description (String description ) {
18711907 this .description .clear ();
1872- this .description .add (description );
1908+ this .description .addAll (Arrays .asList (description .split ("\n " , -1 )));
1909+
18731910 return this ;
18741911 }
18751912
1876- private ScriptActionType description (String [] description ) {
1877- this .description .clear ();
1878-
1879- this .description .addAll (Arrays .asList (description ));
1880-
1881- return this ;
1882- }
18831913 private ScriptActionType group (ScriptGroup group ) {
18841914 this .group = group ;
18851915 return this ;
0 commit comments