<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Getting variables&#x2F;objects from other scripts]]></title><description><![CDATA[<p dir="auto">I'm trying to make an "Enemies" list to integrate with a suite of custom scripts that I'm developing; I have figured out how to create and use a FriendsConfig object to do this with the following:</p>
<pre><code>FriendsConfig = Java.type("net.ccbluex.liquidbounce.file.configs.FriendsConfig");
jFile = Java.type("java.io.File");
dir = new jFile(mc.mcDataDir, LiquidBounce.CLIENT_NAME + "-" + LiquidBounce.MINECRAFT_VERSION);

EnemiesConfig = new FriendsConfig(new jFile(dir, "enemies.json"));
EnemiesConfig.createConfig();

saveMethod = EnemiesConfig.getClass().getDeclaredMethod("saveConfig");
saveMethod.setAccessible(true);

loadMethod = EnemiesConfig.getClass().getDeclaredMethod("loadConfig");
loadMethod.setAccessible(true);
loadMethod.invoke(EnemiesConfig);
</code></pre>
<p dir="auto">My problem is that I need to transfer the FriendsConfig object stored in the EnemiesConfig variable to my other scripts to be able to check if a player is an enemy (for example, a killaura script that prioritizes targeting enemies over other players).<br />
I have tried import/export but have not been able to figure out how it works; whenever I reload my script shows an error saying something like "Expected an operand but found export".</p>
<p dir="auto">A possible solution I've thought of is to create a separate FriendsConfig object that reads from enemies.json in each script, but that seems like a messy solution as it would require constant re-reading from the file to check for changes.</p>
<p dir="auto">(I already have all of the code to add/remove/list enemies working via a command, I just need help getting the object from one script to the other)<br />
If it is of any importance, I am using CzechHek's Core.lib for all my scripts.</p>
]]></description><link>https://forum.liquidbounce.net/topic/4467/getting-variables-objects-from-other-scripts</link><generator>RSS for Node</generator><lastBuildDate>Thu, 18 Jun 2026 12:02:45 GMT</lastBuildDate><atom:link href="https://forum.liquidbounce.net/topic/4467.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 05 Sep 2022 19:36:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Getting variables&#x2F;objects from other scripts on Sun, 11 Sep 2022 09:53:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/idk-my-name" aria-label="Profile: idk-my-name">@<bdi>idk-my-name</bdi></a> Wouldn't that be too intrusive and confusing?</p>
<p dir="auto">I guess it would be better to do <code>importProperties("scriptname")</code> which would add script to list that no such property uses.</p>
]]></description><link>https://forum.liquidbounce.net/post/33589</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/33589</guid><dc:creator><![CDATA[CzechHek]]></dc:creator><pubDate>Sun, 11 Sep 2022 09:53:17 GMT</pubDate></item><item><title><![CDATA[Reply to Getting variables&#x2F;objects from other scripts on Sun, 11 Sep 2022 09:11:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/czechhek" aria-label="Profile: czechhek">@<bdi>czechhek</bdi></a> What about trying to get a variable from all available scripts in __noSuchProperty__?</p>
]]></description><link>https://forum.liquidbounce.net/post/33588</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/33588</guid><dc:creator><![CDATA[idk my name]]></dc:creator><pubDate>Sun, 11 Sep 2022 09:11:09 GMT</pubDate></item><item><title><![CDATA[Reply to Getting variables&#x2F;objects from other scripts on Fri, 09 Sep 2022 23:42:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/czechhek" aria-label="Profile: czechhek">@<bdi>czechhek</bdi></a> said in <a href="/post/33494">Getting variables/objects from other scripts</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/allison" aria-label="Profile: allison">@<bdi>allison</bdi></a> Since you are already using Core, this should work. I've even fixed more stuff with Reflector to make this easy to do.</p>
</blockquote>
<p dir="auto">This is now built into Core since 4.11.</p>
<pre><code class="language-js">EnemiesConfig = importFromScript("ScriptName", "EnemiesConfig");
</code></pre>
]]></description><link>https://forum.liquidbounce.net/post/33564</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/33564</guid><dc:creator><![CDATA[CzechHek]]></dc:creator><pubDate>Fri, 09 Sep 2022 23:42:25 GMT</pubDate></item><item><title><![CDATA[Reply to Getting variables&#x2F;objects from other scripts on Tue, 06 Sep 2022 15:15:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/allison" aria-label="Profile: allison">@<bdi>allison</bdi></a> Since you are already using Core, this should work. I've even fixed more stuff with Reflector to make this easy to do.</p>
<p dir="auto">Export.js script:</p>
<pre><code class="language-js">///api_version=2
(script = registerScript({
	name: "Export",
	authors: ["CzechHek"],
	version: "1.0"
})).import("Core.lib");

FriendsConfig = Java.type("net.ccbluex.liquidbounce.file.configs.FriendsConfig");
dir = LiquidBounce.fileManager.dir;

EnemiesConfig = new Reflector(new FriendsConfig(new File(dir, "enemies.json")));
EnemiesConfig.createConfig();
EnemiesConfig.loadConfig();
</code></pre>
<p dir="auto">Import.js script</p>
<pre><code class="language-js">///api_version=2
(script = registerScript({
	name: "Import",
	authors: ["CzechHek"],
	version: "1.0"
})).import("Core.lib");

module = {
	onEnable: function () {
		targetScript = new Reflector(Java.from(scriptManager.scripts).find(function (script) script.scriptName == "Export"));
		config = targetScript.scriptEngine.get("EnemiesConfig");
	}
}
</code></pre>
]]></description><link>https://forum.liquidbounce.net/post/33494</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/33494</guid><dc:creator><![CDATA[CzechHek]]></dc:creator><pubDate>Tue, 06 Sep 2022 15:15:34 GMT</pubDate></item></channel></rss>