OWL scripting basics

36 views
Skip to first unread message

Morris Ford

unread,
Mar 11, 2010, 7:32:25 PM3/11/10
to Open Wonderland Scripting
This is an initial set of questions and answers about the scripting
module. As questions show up in the forum, I will create another set.

Q: What is the Scripting Component?
A: Scripting Component is a component for Open Wonderland that
implements a client side scripting environment. A component in the
Open Wonderland environment is a type of plugin that implements a set
of capabilities for a module. A component can be attached to almost
any object in a Wonderland world.

Q: What is the scripting language implemented by Scripting Component?
A: The Scripting Component uses the JSR-223 feature of java to
implement an interface that allows almost any scripting language. So,
there is not one specific language but rather, a variety of already
well known scripting languages.

Q: What scripting languages have been tested with this interface?
A: Javascript, PHP, Groovy, JRuby, Java, Jython and Sleep have been
verified.

Q: Are there sample scripts for these languages?
A: Yes. Another post in this forum will have examples of these
languages except for Java. Java can be used as a scripting language
with this interface but the interfacing to the system is quite messy.
If you really want to use Java, just ask and I'll post a couple of
sample programs.

Q: What is the structure of the scripting environment?
A: The structure of the environment is individual scripts that respond
to events within the attached module. There are about 25 specific
types of events and hence about 25 possible scripts. The scripts are
stored at the Open Wonderland server so that all clients have access.

Q: Why does the scripting component use individual scripts instead of
one single script?
A: Multiple scripts were used as a way to isolate actions to
individual files. Also, in order to allow for the use of different
scripting languages for different events.

Q: How does the scripting component deal with maintaining state?
A: The component has a large number of variables that can be read and
written from scripts specifically for maintaining state.

Q: Are there communications capabilities implemented in the component?
A: Yes, the component has several types of communications
capabilities. There is a socket interface that allows for incoming or
outgoing socket connections. There is an inter-module message passing
mechanism that allows any module to communicate with any or all other
modules. Both of these messaging systems carry a message number and an
arbitrary length string parameter.

Q: How is the Scripting Component connected to a module?
A: There are two ways to connect to a module, through the properties
menu and by calling the component in the Java code for the module. The
code to add the component to a module is 5 lines of code.

Q: Where do I find the Scripting Component?
A: Open Wonderland has a module warehouse at
http://openwonderland.org/index.php?option=com_docman&cat=add_ons&Itemid=123
The Scripting Component is available there along with several
scripting enabled modules.

Q: What is a scripting enabled module?
A: The component has a command structure that can be incorporated
inside a module to allow commands in the module to be called by name
from scripts.

Q: Is the command interface easy to implement in a module?
A: That depends greatly on how the module is implemented. If a module
exposes its commands in the main client side java module, the command
interface can be easily implemented.

Q: What are the command enabled modules available in the module
warehouse?
A: Scripting NPC. Implements a scripting controlled bot. Scripting
Imager. Implements an image display module. Scripting Poster.
Implements a scripting controlled message board. There will be several
more in the near future.

oksamyt

unread,
Apr 28, 2010, 1:43:19 PM4/28/10
to Open Wonderland Scripting
I have a question: is it possible to make the scripts available for
all the users? For example, I have a world where an authenticated user
has created some objects and scripted their behavior (for example,
when user clicks on an object, an npc moves to this object), but it
only works for the user the scripts belong to. How can I 'share' the
scripts?

Morris Ford

unread,
Apr 28, 2010, 3:02:01 PM4/28/10
to open-wonderl...@googlegroups.com
You would put the scripts in the 'global' area. 

.wonderland-server/*/run/content/scripts/cellName/startup.js etc.

oksamyt

unread,
May 3, 2010, 1:03:51 PM5/3/10
to Open Wonderland Scripting
I have tried this, but which user should create the objects (npc and
the model)? Here is client log:

******************** Cell name = npc_cell
ScriptingComponent : Cell
org.jdesktop.wonderland.modules.scriptingNpc.client.cell.NpcCell@2c1b13
- id = 3 : Enter ScriptingComponent constructor
ScriptingComponentClientState : In getInfo - info = Default
ScriptingComponentClientState : In getEventNames
ScriptingComponentClientState : In getScriptType
ScriptingComponentClientState : In getCellOwner - oksamyt
ScriptingComponentClientState : In getUseGlobalScripts - false
ScriptingComponent : Cell 3 : In setClientState - info = Default
******************** Cell name = walle
ScriptingComponent : Cell
org.jdesktop.wonderland.client.cell.ModelCell@16ce9df - id = 2 : Enter
ScriptingComponent constructor
ScriptingComponentClientState : In getInfo - info = Default
ScriptingComponentClientState : In getEventNames
ScriptingComponentClientState : In getScriptType
ScriptingComponentClientState : In getCellOwner - oksamyt
ScriptingComponentClientState : In getUseGlobalScripts - false
ScriptingComponent : Cell 2 : In setClientState - info = Default
...
ScriptingComponent : Cell 2 : scriptPath =
http://lucidity:8080//webdav/content/users/oksamyt/scripts/walle/startup.js
ScriptingComponent : Cell 2 : Script type = javascript
ScriptingComponent : Cell 2 : This script takes Compiled path
ScriptingComponent : Cell 2 : General exception in the whole mechanism
of compiling and executing the script java.io.FileNotFoundException:
http://lucidity:8080//webdav/content/users/oksamyt/scripts/walle/startup.js

It searches for the scripts on the 'user's' directory, doesn't find
them and doesn't work.
I am using user preview 4 revision 4418 with scripting component and
scripting npc modules from the warehouse.

On Apr 28, 10:02 pm, Morris Ford <morrishf...@gmail.com> wrote:
> You would put the scripts in the 'global' area.
>
> .wonderland-server/*/run/content/scripts/cellName/startup.js etc.
>

Morris Ford

unread,
May 3, 2010, 1:46:53 PM5/3/10
to open-wonderl...@googlegroups.com
You will need to bring up the script editor and turn off the 'user' choice for this cell.

oksamyt

unread,
May 4, 2010, 12:34:27 PM5/4/10
to Open Wonderland Scripting
Thanks! I didn't pay attention at that checkbox earlier %)

Oxana Zhuravlyova

unread,
Jun 2, 2010, 6:16:21 AM6/2/10
to Open Wonderland Scripting
I have one more question: where exactly can I find the 5 lines of code
I need to add to my module to add the scripting capability to it?

--
Oxana Zhuravlyova

Morris Ford

unread,
Jun 2, 2010, 9:54:29 AM6/2/10
to open-wonderl...@googlegroups.com
In the *Cell.java add:

    @UsesCellComponent
    private ScriptingComponent scriptingComponent;

In the *CellMO.java constructor add:

        addComponent(new ScriptingComponentMO(this), ScriptingComponentMO.class);

Both files will need the imports added.

Reply all
Reply to author
Forward
0 new messages