Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
# User-specific stuff
.idea/
.vscode/

*.iml
*.ipr
Expand DownExpand Up@@ -116,3 +117,6 @@ run/

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Bin folder
bin/
Original file line numberDiff line numberDiff line change
Expand Up@@ -1606,8 +1606,26 @@ public enum ScriptActionType {
}
})),

RANDOM_NUMBER(builder -> builder.name("Random Number")
.description("Generates a random number between two other numbers.")
RANDOM_INT(builder -> builder.name("Random Int")
.description("Generates a random whole number between two other numbers.")
.icon(Items.HOPPER)
.category(ScriptActionCategory.NUMBERS)
.arg("Result", ScriptActionArgumentType.VARIABLE)
.arg("Min", ScriptActionArgumentType.NUMBER)
.arg("Max", ScriptActionArgumentType.NUMBER)
.action(ctx -> {
int min = (int) ctx.value("Min").asNumber();
int max = (int) ctx.value("Max").asNumber();
Random random = new Random();
int result = random.nextInt(max + 1 - min) + min;
ctx.context().setVariable(
ctx.variable("Result").name(),
new ScriptNumberValue(result)
);
})),

RANDOM_DOUBLE(builder -> builder.name("Random Double")
.description("Generates a random floating point number between two other numbers.")
.icon(Items.HOPPER)
.category(ScriptActionCategory.NUMBERS)
.arg("Result", ScriptActionArgumentType.VARIABLE)
Expand All@@ -1623,8 +1641,26 @@ public enum ScriptActionType {
);
})),

RANDOM_NUMBER(builder -> builder.name("Random Number")
.description("Generates a random number between two other numbers.")
.icon(Items.HOPPER)
.category(ScriptActionCategory.NUMBERS)
.deprecate(RANDOM_DOUBLE)
.arg("Result", ScriptActionArgumentType.VARIABLE)
.arg("Min", ScriptActionArgumentType.NUMBER)
.arg("Max", ScriptActionArgumentType.NUMBER)
.action(ctx -> {
double min = ctx.value("Min").asNumber();
double max = ctx.value("Max").asNumber();
double result = Math.random() * (max - min) + min;
ctx.context().setVariable(
ctx.variable("Result").name(),
new ScriptNumberValue(result)
);
})),

REPEAT_FOREVER(builder -> builder.name("RepeatForever")
.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."})
.description("Repeats for eternity.\nMake sure to have a Stop Repetition, Stop Codeline or Wait somewhere in the code!\nThere's a lagslayer for the repetition actions.\nIt activates after 100000 iterations with no Wait.")
.icon(Items.GOLD_INGOT)
.category(ScriptActionCategory.MISC)
.hasChildren(true)
Expand All@@ -1633,7 +1669,7 @@ public enum ScriptActionType {
ctx.scheduleInner(null, context -> context.setLastIfResult(true));
})),
ELSE(builder -> builder.name("Else")
.description(new String[]{"Executes if the last IF condition failed.","And ELSE also works as a valid IF condition for ELSE."})
.description("Executes if the last IF condition failed.\nAnd ELSE also works as a valid IF condition for ELSE.")
.icon(Items.END_STONE)
.category(ScriptActionCategory.MISC)
.group(ScriptGroup.CONDITION)
Expand DownExpand Up@@ -1682,7 +1718,7 @@ public enum ScriptActionType {
})),

REGEX_REPLACE_TEXT(builder -> builder.name("Replace Text using Regex")
.description(new String[]{"Searches for part of a text", "using a regex and replaces it."})
.description("Searches for part of a text\nusing a regex and replaces it.")
.icon(Items.LEAD, true)
.arg("Result", ScriptActionArgumentType.VARIABLE)
.arg("Text to change", ScriptActionArgumentType.TEXT)
Expand DownExpand Up@@ -1869,17 +1905,11 @@ private ScriptActionType category(ScriptActionCategory category) {

private ScriptActionType description(String description) {
this.description.clear();
this.description.add(description);
this.description.addAll(Arrays.asList(description.split("\n", -1)));

return this;
}

private ScriptActionType description(String[] description) {
this.description.clear();

this.description.addAll(Arrays.asList(description));

return this;
}
private ScriptActionType group(ScriptGroup group) {
this.group = group;
return this;
Expand Down