The mouse events need a little bit of explanation:
mouse1 - left mouse button
mouse1s - left mouse button + shift
mouse1c - left mouse button + control
mouse2 - middle mouse button
and the other two scripts
startup - this script executes on startup of the module. This is
ordinarily when the client starts.
ice - executes when the module receives an intercell event that
contains a code that the module has been instructed to listen for
The startup script instructs the module to listen to intercell
messages and to react to messages with code 300 by calling the ice
script. The ice script looks at the payload in the ice message and
decides what action to take. The calls to MyClass.executeAction() are
what calls to the module command interface look like. The four mouse
event scripts send the ice messages from '01' to '04'. If I didn't
make any typos typing this in, that set of scripts should show the
avatar walking and changing appearance. The ice script performs its
actions inside a new thread. This was not necessary since the module
commands each are executed in their own thread but I thought it would
be instructive. Using a structure like this would be important in a
script that is free running once executed.
startup.js
// startup script for NPC test
print("Hello from NPC test startup script\r\n");
MyClass.watchMessage(300);
ice.js
// intercell event script for NPC test
print("Enter ice.js script\r\n");
var v = new java.lang.Runnable()
{
run: function()
{
if(ICEEventMessage == '01')
{
print("ice start translate 1\r\n");
MyClass.executeAction("move", 1.0, 0.0, 1.0);
}
if(ICEEventMessage == '02')
{
print("ice start translate 2\r\n");
MyClass.executeAction("move", 10.0, 0.0, 10.0);
}
if(ICEEventMessage == '03')
{
print("ice start set avatar female\r\n");
MyClass.executeAction("selectAvatar", "assets/configurations/
FemaleD_AZ_00_bin.xml");
}
if(ICEEventMessage == '04')
{
print("ice start set avatar male\r\n");
MyClass.executeAction("selectAvatar", "assets/configurations/
MaleD_CA_01_bin.xml");
}
}
}
t = new java.lang.Thread(v);
i.start();
mouse1.js
// mouse1.js event script for NPC test
print("Enter mouse1.js script\r\n");
MyClass.postMessageEvent("01", 300);
mouse1s.js
// mouse1s.js event script for NPC test
print("Enter mouse1s.js script\r\n");
MyClass.postMessageEvent("02", 300);
mouse1c.js
// mouse1c.js event script for NPC test
print("Enter mouse1c.js script\r\n");
MyClass.postMessageEvent("03", 300);
mouse2.js
// mouse2.js event script for NPC test
print("Enter mouse2.js script\r\n");
MyClass.postMessageEvent("04", 300);
The startup and ice scripts must be attached to a Scripting NPC module
and the mouse scripts attached to another module that will accept
mouse clicks.
To make this work:
Checkout a scripting component and a scripting npc component from the
module warehouse.
Install both in your system using the web admin interface -> manage
modules.
In the client insert an npc module.
Since the npc module will not bring up the properties window on a
mouse click, click on some object in world and bring up the properties
window. Then go through the modules until you find the npc module.
Change the cell name to the name you want to use for the npc (no
spaces please).
Select (or insert) a module that is composed of just a model. Bring up
the properties for that module and change the name to a name for the
module. The name must be different than the npc name.
Assuming that you have full access to the server computer that is
running OWL and that you are using preview3, create the following
paths in the filesystem:
.wonderland-server/0.5-preview3/run/content/scripts/{npc-name} - npc-
name is the name you gave to the NPC.
.wonderland-server/0.5-preview3/run/content/scripts/{module-name} -
module-name is the name you gave to the module.
The scripts/names part of the path will be all that you actually have
to create.
Place the npc scripts (startup and ice) in the new npc directory.
Place the module scripts (mouse's) in the new module directory.
Create a new startup script in the module directory with contents
similar to this:
// startup script
print("Startup script\r\n");
This script is being created to give the module a script to run on
startup.
Restart the client.
You should see logging in the java console showing the two modules
starting up and running their start up scripts. If you see java
exceptions there is probably a mistake in the naming or in the paths
created.
Now you can click on the module you created with one of the mouse
button and key combinations to test the NPC.
NOTE:
I realize that is a lot of fooling around to get the scripts in place.
There are actually a couple of easier ways to go about this but doing
it this way at the start will help with understanding where the
scripts live and the relationship between module names and scripts.
Good luck
Morris
thanks for your instructions! I have been playing with it for a while
but cannot get it to work well.
I can place the NPC guy and it is reading the startup script for that
and showing the print statement in console. I can also make it move
through the controls in (Edit --> NPC 2 controls...) but I am having
trouble with the module that will receive the clicks.
When you say "Select (or insert) a module that is composed of just a
model", would it be enough to drag inside the world a .kmz file?
I have tried that, and also tried the longer path (insert --> model --
> load model --> save as module --> deploy to server --> ok) but the
startup line for that other module do not appear in console, and it
does not respond to the clicks.
Any idea about what I am missing?
Oh, by the way, I don't know if this is specific to mac, or 0.5-dev,
but i had to place the scripts into
.wonderland-server/0.5-xxx/run/content/users/{username}/scripts/{npc-
name}
so i had to add /users/{username} to it or it could not find them.
Cheers,
Jos
To unsubscribe from this group, send email to open-wonderland-scripting+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
I'm getting some exceptions now but I'll try to track them down
tomorrow, bed time over here already!
Will build the scripting module from the trunk and see if it's
anything related to using 0.5-dev and the module from the warehouse.
cheers!
Jos
On Mar 20, 11:10 pm, Morris Ford <morrishf...@gmail.com> wrote:
> You will need to change the name of the simple model you insert into the
> world and then create script paths for that name. You then have to add the
> scripting component to that model from the properties screen. That is done
> by clicking the + sign in the properties window and then selecting the
> ScriptingComponent. At that point you should see the logging showing that
> module's startup stuff.
>
> The paths you needed are due to using the trunk instead of preview3. That is
> ok since you figured out the difference.
>
> If you have other problems, let me know.
> Morris
>
ice.js
// intercell event script for NPC test
print("Enter ice.js script\r\n");
var v = new java.lang.Runnable()
{
run: function()
{
if(ICEEventMessage == '01')
{
print("ice start translate 1\r\n");
MyClass.executeAction("move", 1.0, 0.0, 1.0);
}
if(ICEEventMessage == '02')
{
print("ice start translate 2\r\n");
MyClass.executeAction("move", 10.0, 0.0, 10.0);
}
if(ICEEventMessage == '03')
{
print("ice start set avatar female\r\n");
MyClass.executeAction("selectAvatar", "assets/configurations/
FemaleD_AZ_00_bin.xml");
}
if(ICEEventMessage == '04')
{
print("ice start set avatar male\r\n");
MyClass.executeAction("selectAvatar", "assets/configurations/
MaleD_CA_01_bin.xml");
}
}
}
t = new java.lang.Thread(v);
t.start();
There were three problems. The last line should have been t.start();
Also the two long lines that are split here (the change avatar
commands) should not be split in the script itself.
Morris
http://java.sun.com/developer/technicalArticles/scripting/javafx/javafx_and_java/
This gives the description of JSR 223/fx. Is this the info that was required to integrate into your scripting module?