How to access a skript global variable from "outside" ?

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

pepper82

Member
Jan 26, 2017
272
1
18
41
Hi all,
can anybody tell me how to access a global variable (example: {test}) from another java plugin? Is it possible? Somebody has an example? Always wanted this to know. Thanks a bunch!
 
ok :emoji_grinning:
[doublepost=1524265934,1524171508][/doublepost]DO you know what value (event) the getvariable function needs?

https://github.com/bensku/Skript/bl.../ch/njol/skript/variables/Variables.java#L277

getVariable(final String name, final @Nullable Event e, final boolean local) {

What is "final @Nullable Event e" ?

I'm fairly certain that can be null if you aren't trying to access local variables (the local parameter is false)
But it's just an instance of the current scope to get local variables from
 
Ok thanks. We were able to get it to work except that we have some strange issues (strange characters?) in the output:

This is the list variable that we read using the following java code:

code_language.skript:
                          String variable = args[1];
                            System.out.println("Checked Variable " + variable);
                            System.out.println("RAW " + Variables.getVariable(variable, null, false));
                            Map<String, Integer> skriptMap = (Map<String, Integer>) Variables.getVariable(variable, null, false);
                            System.out.println(skriptMap);
                            Set<String> keys = skriptMap.keySet();
                            System.out.println(keys);
                            for (String s : keys) {
                                if (s != null) {
                                    System.out.println(s);
                                }
                            }


And here is the output from console:

01:33:22
CONSOLE:

RAW {bobo=500, flopp=2848, mama=200, pupu=333, sternchen=33}
01:33:22
CONSOLE:

{bobo=500, flopp=2848, mama=200, pupu=333, sternchen=33}
01:33:22
bobo,:
flopp, mama, pupu, sternchen]

You see. As soon as we print the keys, there is some strange issue and the console output is bugged.
Do you know why?