Class Starscript

java.lang.Object
meteordevelopment.starscript.Starscript

public class Starscript extends Object
A VM (virtual machine) that can run compiled starscript code, Script.
  • Constructor Details

    • Starscript

      public Starscript()
  • Method Details

    • run

      public Section run(Script script, StringBuilder sb)
      Runs the script and fills the provided StringBuilder. Throws StarscriptError if a runtime error happens.
    • run

      public Section run(Script script)
      Runs the script. Throws StarscriptError if a runtime error happens.
    • push

      public void push(Value value)
      Pushes a new value on the stack.
    • pop

      public Value pop()
      Pops a new value from the stack.
    • peek

      public Value peek()
      Returns a value from the stack without removing it.
    • peek

      public Value peek(int offset)
      Returns a value from the stack with an offset without removing it.
    • popBool

      public boolean popBool(String errorMsg)
      Pops a value from the stack and returns it as boolean. Calls error(String, Object...) with the provided message if the value is not boolean.
    • popNumber

      public double popNumber(String errorMsg)
      Pops a value from the stack and returns it as double. Calls error(String, Object...) with the provided message if the value is not double.
    • popString

      public String popString(String errorMsg)
      Pops a value from the stack and returns it as String. Calls error(String, Object...) with the provided message if the value is not String.
    • error

      public void error(String format, Object... args)
      Throws a StarscriptError.
    • set

      public ValueMap set(String name, Supplier<Value> supplier)
      Sets a variable supplier for the provided name.
    • set

      public ValueMap set(String name, Value value)
      Sets a variable supplier that always returns the same value for the provided name.
    • set

      public ValueMap set(String name, boolean bool)
      Sets a boolean variable supplier that always returns the same value for the provided name.
    • set

      public ValueMap set(String name, double number)
      Sets a number variable supplier that always returns the same value for the provided name.
    • set

      public ValueMap set(String name, String string)
      Sets a string variable supplier that always returns the same value for the provided name.
    • set

      public ValueMap set(String name, SFunction function)
      Sets a function variable supplier that always returns the same value for the provided name.
    • set

      public ValueMap set(String name, ValueMap map)
      Sets a map variable supplier that always returns the same value for the provided name.
    • getGlobals

      public ValueMap getGlobals()
      Returns the underlying ValueMap for global variables.
    • getCompletions

      public void getCompletions(String source, int position, CompletionCallback callback)
      Calls the provided callback for every completion that is able to be resolved from global variables.