Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.rico.adventure.script
Class ScriptInterpreter

    java.lang.Object
      de.rico.adventure.script.ScriptInterpreter

    public class ScriptInterpreter

extends java.lang.Object

This class can be used to access and interpret script files in connection with a room.

Author:
  Frank Bruns

Constructor Summary
`ScriptInterpreter(java.util.List<Room> rooms, java.util.List<Conversation> cons)` Creates a new script interpreter that can be used with the specied rooms.

Method Summary
`void` | `bindVariable(java.lang.String scriptId, java.lang.Object variable)` Binds a variable to the script interpreter.
`void` | `invokeMethod(java.lang.String methodName)` Invoke a method from the script file the interpreter has been initialized with.
`void` | `runCode(java.lang.String code)` Runs the specified scripted code.
`void` | `runScript(java.lang.String scriptFile)` Executes the specified script file line by line
`void` | `unbindVariable(java.lang.String scriptId)` Unbinds the variable referenced by the specified script id from the script interpreter.
`void` | `updateBinding()` Updates the binding of the rooms entities to the interpreter.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ScriptInterpreter

    public ScriptInterpreter(java.util.List<Room> rooms,
                             java.util.List<Conversation> cons)

  Creates a new script interpreter that can be used with the specied rooms.

  Parameters:
    `rooms` - rooms to bind to the script interpreter
    `cons` - conversations to bind to the script interpreter

Method Detail

### updateBinding

    public void updateBinding()

  Updates the binding of the rooms entities to the interpreter. This removes bindings to objects that are no longer part of the rooms or adds bindings to objects that are new to the rooms.

### bindVariable

    public void bindVariable(java.lang.String scriptId,
                             java.lang.Object variable)

  Binds a variable to the script interpreter. The provided script id will be used as a reference name.

  Parameters:
    `scriptId` - id to reference the object by
    `variable` - variable to bind to the script interpreter

### unbindVariable

    public void unbindVariable(java.lang.String scriptId)

  Unbinds the variable referenced by the specified script id from the script interpreter.

  Parameters:
    `scriptId` - id to reference the variable by

### invokeMethod

    public void invokeMethod(java.lang.String methodName)

  Invoke a method from the script file the interpreter has been initialized with.

  Parameters:
    `methodName` - method name in the script file

### runCode

    public void runCode(java.lang.String code)

  Runs the specified scripted code.

  Parameters:
    `code` - script code to run

### runScript

    public void runScript(java.lang.String scriptFile)

  Executes the specified script file line by line

  Parameters:
    `scriptFile` - script file to execute

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD