Currently GlobalVars isn't great to say the least.
const GLOBAL_VAR_NAME = 'donut_smp_bone_macro_home_positions_cache';
// Use cache from GlobalVars if available
if (GlobalVars.getType(GLOBAL_VAR_NAME) === 'Object') {
Chat.log(GLOBAL_VAR_NAME);
Chat.log(GlobalVars.getType(GLOBAL_VAR_NAME));
Chat.log(GlobalVars.getObject(GLOBAL_VAR_NAME));
const cachedPositions = GlobalVars.getObject(GLOBAL_VAR_NAME) as Record<string, BlockPosHelper>;
state.homePositions = cachedPositions;
ChatHelper.log(
`Loaded ${Object.keys(cachedPositions).length} home positions from cache in GlobalVars.`
);
state.task.type = StateMachineTask.IDLE;
// Disable teleport listener
JsMacros.off(data.teleportListener);
break;
}
[12:48:43] [Render thread/INFO]: [CHAT] Home positions have not yet been dumped
[12:48:43] [ScriptEventListener:{"creator":"Script:{"trigger":"EVENT", "event":"Service", "file":"dist/donut-smp-bone-macro.js"}", "event":"Tick"}/INFO]: [STDERR]: java.lang.RuntimeException: org.graalvm.polyglot.PolyglotException: Context execution was cancelled.
[12:48:43] [ScriptEventListener:{"creator":"Script:{"trigger":"EVENT", "event":"Service", "file":"dist/donut-smp-bone-macro.js"}", "event":"Tick"}/INFO]: [STDERR]: at xyz.wagyourtail.jsmacros.js.library.impl.FWrapper$JSMethodWrapper.innerApply(FWrapper.java:239)
[12:48:43] [ScriptEventListener:{"creator":"Script:{"trigger":"EVENT", "event":"Service", "file":"dist/donut-smp-bone-macro.js"}", "event":"Tick"}/INFO]: [STDERR]: at xyz.wagyourtail.jsmacros.js.library.impl.FWrapper$JSMethodWrapper.innerAccept(FWrapper.java:147)
[12:48:43] [ScriptEventListener:{"creator":"Script:{"trigger":"EVENT", "event":"Service", "file":"dist/donut-smp-bone-macro.js"}", "event":"Tick"}/INFO]: [STDERR]: at xyz.wagyourtail.jsmacros.js.library.impl.FWrapper$JSMethodWrapper.accept(FWrapper.java:265)
[12:48:43] [ScriptEventListener:{"creator":"Script:{"trigger":"EVENT", "event":"Service", "file":"dist/donut-smp-bone-macro.js"}", "event":"Tick"}/INFO]: [STDERR]: at knot//xyz.wagyourtail.jsmacros.core.library.impl.FJsMacros$1.lambda$trigger$0(FJsMacros.java:378)
[12:48:43] [ScriptEventListener:{"creator":"Script:{"trigger":"EVENT", "event":"Service", "file":"dist/donut-smp-bone-macro.js"}", "event":"Tick"}/INFO]: [STDERR]: at knot//xyz.wagyourtail.jsmacros.core.threads.JsMacrosThreadPool$PoolThread.run(JsMacrosThreadPool.java:100)
[12:48:43] [ScriptEventListener:{"creator":"Script:{"trigger":"EVENT", "event":"Service", "file":"dist/donut-smp-bone-macro.js"}", "event":"Tick"}/INFO]: [STDERR]: Caused by: org.graalvm.polyglot.PolyglotException: Context execution was cancelled.
[12:48:43] [ScriptEventListener:{"creator":"Script:{"trigger":"EVENT", "event":"Service", "file":"dist/donut-smp-bone-macro.js"}", "event":"Tick"}/INFO]: [STDERR]: at <js>.analyzeHomesHandler(Unknown)
[12:48:43] [ScriptEventListener:{"creator":"Script:{"trigger":"EVENT", "event":"Service", "file":"dist/donut-smp-bone-macro.js"}", "event":"Tick"}/INFO]: [STDERR]: at <js>.tickListener(donut-smp-bone-macro.js:1084)
[12:48:43] [ScriptEventListener:{"creator":"Script:{"trigger":"EVENT", "event":"Service", "file":"dist/donut-smp-bone-macro.js"}", "event":"Tick"}/INFO]: [STDERR]: at org.graalvm.polyglot.Value.execute(Value.java:881)
[12:48:43] [ScriptEventListener:{"creator":"Script:{"trigger":"EVENT", "event":"Service", "file":"dist/donut-smp-bone-macro.js"}", "event":"Tick"}/INFO]: [STDERR]: at xyz.wagyourtail.jsmacros.js.library.impl.FWrapper$JSMethodWrapper.innerApply(FWrapper.java:237)
[12:48:43] [ScriptEventListener:{"creator":"Script:{"trigger":"EVENT", "event":"Service", "file":"dist/donut-smp-bone-macro.js"}", "event":"Tick"}/INFO]: [STDERR]: at xyz.wagyourtail.jsmacros.js.library.impl.FWrapper$JSMethodWrapper.innerAccept(FWrapper.java:147)
[12:48:43] [ScriptEventListener:{"creator":"Script:{"trigger":"EVENT", "event":"Service", "file":"dist/donut-smp-bone-macro.js"}", "event":"Tick"}/INFO]: [STDERR]: at xyz.wagyourtail.jsmacros.js.library.impl.FWrapper$JSMethodWrapper.accept(FWrapper.java:265)
[12:48:43] [ScriptEventListener:{"creator":"Script:{"trigger":"EVENT", "event":"Service", "file":"dist/donut-smp-bone-macro.js"}", "event":"Tick"}/INFO]: [STDERR]: at knot//xyz.wagyourtail.jsmacros.core.library.impl.FJsMacros$1.lambda$trigger$0(FJsMacros.java:378)
[12:48:43] [ScriptEventListener:{"creator":"Script:{"trigger":"EVENT", "event":"Service", "file":"dist/donut-smp-bone-macro.js"}", "event":"Tick"}/INFO]: [STDERR]: at knot//xyz.wagyourtail.jsmacros.core.threads.JsMacrosThreadPool$PoolThread.run(JsMacrosThreadPool.java:100)
[12:48:43] [ScriptEventListener:{"creator":"Script:{"trigger":"EVENT", "event":"Service", "file":"dist/donut-smp-bone-macro.js"}", "event":"Tick"}/INFO]: [STDERR]: at <js>.analyzeHomesHandler(Unknown)
[12:48:43] [ScriptEventListener:{"creator":"Script:{"trigger":"EVENT", "event":"Service", "file":"dist/donut-smp-bone-macro.js"}", "event":"Tick"}/INFO]: [STDERR]: at <js>.tickListener(donut-smp-bone-macro.js:1084)
[12:48:43] [Render thread/INFO]: [CHAT] donut_smp_bone_macro_home_positions_cache
[12:48:43] [Render thread/INFO]: [CHAT] Object
[12:48:43] [Render thread/INFO]: [CHAT] org.graalvm.polyglot.PolyglotException: Context execution was cancelled.\n at <js>.analyzeHomesHandler (Unknown)\n at <js>.tickListener (donut-smp-bone-macro.js 1084:?)\n at Value.execute (Value.java 881:?)\n at FWrapper$JSMethodWrapper.innerApply (FWrapper.java 237:?)\n at FWrapper$JSMethodWrapper.innerAccept (FWrapper.java 147:?)\n at FWrapper$JSMethodWrapper.accept (FWrapper.java 265:?)\n at FJsMacros$1.lambda$trigger$0 (FJsMacros.java 378:?)\n at JsMacrosThreadPool$PoolThread.run (JsMacrosThreadPool.java 100:?)\n at analyzeHomesHandler\n at tickListener (donut-smp-bone-macro.js 1084:22)
Currently GlobalVars isn't great to say the least.
Weird issues can happen sometimes with things like this for example:
Why when I call getObject does it error sometimes like this?
According to
Claude Sonnet 4.5, this is due to the execution context that that variable existed in being removed which makes sense. However,putObjectis supposed to avoid this by never putting a guest object in GlobalVars, why isn't this working?Additionally, we should really move all the
putmethods toset. Do they serve any specific benefit beingputinstead? I know AI models at the very least love to usesetfor the global vars so perhaps that's what we should be using given they're just spitting out what's most frequent.