1. 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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Java' started by pepper82, Apr 18, 2018.

  1. pepper82

    pepper82 Member

    Joined:
    Jan 26, 2017
    Messages:
    272
    Likes Received:
    1
    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!
     
  2. Pikachu

    Moderator Supporter Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    871
    Likes Received:
    139
    Medals:
    look at the variables class
     
  3. pepper82

    pepper82 Member

    Joined:
    Jan 26, 2017
    Messages:
    272
    Likes Received:
    1
  4. it_twit

    it_twit Member

    Joined:
    Jan 26, 2017
    Messages:
    37
    Likes Received:
    3
    Medals:
    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
     
    • Agree Agree x 1
  5. pepper82

    pepper82 Member

    Joined:
    Jan 26, 2017
    Messages:
    272
    Likes Received:
    1
    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 (Skript):
    1.                           String variable = args[1];
    2.                             System.out.println("Checked Variable " + variable);
    3.                             System.out.println("RAW " + Variables.getVariable(variable, null, false));
    4.                             Map<String, Integer> skriptMap = (Map<String, Integer>) Variables.getVariable(variable, null, false);
    5.                             System.out.println(skriptMap);
    6.                             Set<String> keys = skriptMap.keySet();
    7.                             System.out.println(keys);
    8.                             for (String s : keys) {
    9.                                 if (s != null) {
    10.                                     System.out.println(s);
    11.                                 }
    12.                             }

    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?

     

Share This Page

Loading...