File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
src/main/java/io/github/techstreet/dfscript/script/action Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -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 = ctx .value ("Min" ).asNumber ();
1618+ int max = ctx .value ("Max" ).asNumber ();
1619+ Random random = new Random ();
1620+ int result = random .nextInt ((int ) max + 1 - (int ) min ) + (int ) 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 )
You can’t perform that action at this time.
0 commit comments