added a config that determines the order loaded scripts are run in

This commit is contained in:
luisc committed 2025-06-11 17:36:03 -05:00
1 parent 43bf4d3427
commit 7044d8ed63
3 files changed
+27 -9

No files matched your search

@@ -93,22 +93,31 @@ public class ScriptContainer {
if (!this.evaluated) {
// build includes first
StringBuilder sb = new StringBuilder();
for (String loc : this.scripts) {
String code = ScriptController.Instance.scripts.get(loc);
if (code != null && !code.isEmpty()) {
sb.append(code).append("\n");
}
if (ConfigScript.RunLoadedScriptsFirst) {
this.appendExternalScripts(sb);
}
// then your per‐hook script
if (this.script != null && !this.script.isEmpty()) {
sb.append(this.script).append("\n");
}
if (!ConfigScript.RunLoadedScriptsFirst) {
this.appendExternalScripts(sb);
}
this.fullscript = sb.toString();
this.unknownFunctions = new HashSet<>();
}
return this.fullscript;
}
private void appendExternalScripts(StringBuilder sb) {
for (String loc : this.scripts) {
String code = ScriptController.Instance.scripts.get(loc);
if (code != null && !code.isEmpty()) {
sb.append(code).append("\n");
}
}
}
public void run(ScriptEngine engine) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);