WayScript's Java editor lets you reference Variables that exist in your program. To do this, you can reference them through the variables map.
As an example, let's create a variable called "Location" and set a value of "Brooklyn, NY"
You can reference the String-type
Location variable in Java with this code:
// Since all WayScript variables are Java Objects,// call "toString" to convert to a String representationString location = WayScript.variables.get( "Location" ).toString();// Or cast to a String, if you know it's a string variableString location = (String)WayScript.variables.get( "Location" );
More abstractly, you reference a variable of any type by declaring it as an Object:
Object var = WayScript.variables.get( "<var_name>" );
You can also output data from your Java code and turn these into variables that can be used by other Modules in your program.
You can do this with the variables map in the following format:
WayScript.variables.put( "<Var Name>", variable );
While working on your script, you can press the "Run Code" button inside the Java module to run the your code and see updated results.
The Java module comes with many pre-installed Java Packages. However, if you would like to use a package that isn't already installed, you can declare those in the "Dependencies" tab.
WayScript uses Maven to install dependencies. Declare these dependencies as you would any mvn dependency, in the format of
org.apache.maven:maven-artifact:3.2.1, placing one dependency on each line.
You can use code from the other Java classes in your File Browser. For example, suppose you have a class called
Foo.java, which has a method
Foo class and
bar method will be available for use in