Join us in Outworldz at www.outworldz.com:9000 or follow us:
This NPC Recorder and Controller script is a complete Non Player Character recorder and controller for OpenSim.
For example, you can transmogrify an avatar into a demon and back to human with just a few simple commands. You can easily interact with a NPC, and have the NPC interact with you, with extremely simple scripts and notecards.
Each script controls one NPC. Multiple scripts can be put into prims that are linked together and controlled by other scripts by Link Messages. I am absolutely certain it will be extremely useful with NPC storytelling. The Outworldz sims that Debbie Edwards and I built were made for what this script can do. It's been in the works for at least a year.
+Nara Malone gave me the idea for loading multiple notecards, which makes them into a library of useful NPC functions, which means you can trivially make a button or a sensor or a collision cause a set of actions to occur. For example, imagine three doors- any one which you click - that cause a NPC to open and walk thru that door. It would just be three copies of one of these very simple prims, and three simple notecards.
The system is very easy to use. You wear a prim on your screen, walk or fly around, and click the prim. There are many commands you can choose, such as walk, run, fly, chat, and wander. After recording the route, you click Save and then Start, and your NPC will appear and follow all your instructions.
Credits: I want to thank the fine folks at Wizardry and Steamworks for publishing the original scripts, which I've debugged and extensively modified to make this nifty NPC controller.
Building the NPC Recorder/Player
Building the NPC Recorder/Player is a separate article. Once you have built it, wear it and touch it.
You can wear the prim as a HUD, or leave it on the ground. The script will automatically compensate for the different heights of your avatar versus being on the ground. Wear it as a HUD when you are ready to record a long route and you have had some practice.
You should always end up with the prim on the ground, as this prim will need to be there to control the NPC.
Because this is your first time to use the NPC recorder, we will do a simple test to get you familiar with it.
For this demo, we will just move the prim around and make the NPC walk.
Leave the prim on the ground.
Touch the cube to bring up the menu:
First you should click. The script will record how you look and store it in a notecard named "!Appearance".
Because you have probably clicked a bunch of buttons before you read this, lets clear the memory to get started fresh.
This menu should appear:
Now edit the prim and move it somewhere several meters away - more than 2 meters. If you are wearing it as a HUD, walk somewhere else.
The main menu will appear.
Move the box to where you want your NPC to appear.
If you are wearing it as a HUD, the system will warn you when you save and refuse to save. Just drop the prim ( right-click, select Drop) and then click it again. Selectand it will work properly.
The system will ask for for the name of your new NPC:
Now Click, or . Both will work the same in this demo. The difference is that will always run the NPC, even when no one is near. will only run a NPC when someone is near, which saves on sim resources.
To get control of your NPC again, you can click. You can then click or to start it back up, or to change the route.
There are lots of Menu settings that you can use with your NPC. Inside the script are many more that are tunable.
Prompts you for the name of a NPC to stop. If located, it will be removed from the world.
If you have recorded an Appearance and a Path, this will look for an avatar to be nearby. If located, the script will rez a NPC and start the process that was recorded. If no one is near, any NPC will be deleted.
If you have recorded an Appearance and a Path, this will rez a NPC and start the process that was recorded.
If Owner Only is shown, only the owner of the prim can use it. If set to Group, any Group member in the same groups as the prim can use and control the NPC.
The button records all coordinates with the exact sim position. will record them as offsets from the position of the controller script. This will clear RAM.
Brings you to this web page.
Resets the script. No notecards are changed.
memory of the recorder so you can start over. It does not delete any note cards.Deletes the
This button records your appearance into an 'appearance' notecard. This card is used by the system to make the NPC appear exactly as you are. An NPC is not exactly the same as an Avatar. For example, if you are wearing a AO, the AO will be unable to use it animate the NPC. You must use the recorder to move the NPC and to animate it. You can save the '!Apperance' notecard to your inventory manually, and put a different notecard in.
Save will ask you to stand where you want the NPC to appear and will prompt you for a name of the NPC. The name can be anyone or two-word name. If the name is only one word, such as XX, the NPC will be called "XX Resident". The notecard "Path" will be created with all recordings saved in it. You can save Path notecards manually into your inventory, and combine and edit them.
Clickingbrings up a menu of NPC actions you can make.
The NPC will stand up. This is typically used after an @sit. If there is an animation named "Stand" in the objects inventory, the animation will play.
The system will ask for the name of an animation. You must put this animation in the NPC Object tab along with the script. You will be prompted for how many seconds the animation will play
The system will prompt you for a rotation in degrees. The NPC will then turn that amount. 90 is a quarter turn to the right. -90 is a quarter turn to the left.
Used to land an avatar at the current position of the prim after flying. @land records the current position of your avatar.
If there is an animation named "Fly" in the objects inventory, the animation will play when moving. The NPC will fly to this spot and play the Stand animation, if it exists, when the NPC reaches this position.
The NPC will wander around inside a given radius from the last position recorded for a number of cycles, at random positions. The system will prompt you for both numbers. The radius is specified in meters.
If there is an animation named "Walk " in the objects inventory, the animation will play when moving. There is a variable in the NPC script that can force this time to be fixed, or random. If random, the NPC will pause for a random time up to the fixed time constant in the script.
The NPC will ask for the name of a prim to sit on. If this is a pose ball that has a sit offset and rotation, then NPC will sit at that position and offfset. It will NOT play the pose ball animation. If you wish for the NPC to play a sit animation, follow this with a @animate command and save a sit animation in the NPC script Object tab where this script is located.
The NPC will run to the current position of the prim. @run records the current position of your avatar . If there is an animation named "Run" in the objects inventory, the animation will play when moving.
The NPC will walk to the current position of the prim. @walk records the current position of your avatar. If there is an animation named "Walk" in the objects inventory, the animation will play when moving.
The NPC will fly, in the air to the current position of the prim. If there is an animation named "Fly" in the objects inventory, the animation will play when moving. Repeated @fly will move the NPC without a Stand in-between moves. Use @land to land the avatar.
will prompt for a channel and a command. When this command is executed, the controller will Say the text on the specified channel. This is very useful for controlling other objects.
will prompt for a number of seconds. The NPC will play the Stand animation for that period of time.
will prompt for the name of a pre-recorded sound file that must be located in the Objects inventory. This sound will play when this command is executed.
will prompt for something for the NPC to say in chat. This chat will be seen in white text by anyone within a 20 meter radius.
will prompt for something for the NPC to say in chat. This chat will be seen in white text by anyone within a 10 meter radius.
will prompt for something for the NPC to say in chat. This chat will be seen in white text by anyone within a 100 meter radius.
will insert into the notecard any text that you type in. This text is ignored by the NPC controller.
will stop the NPC indefinitely. You will have to use a Link Message to start the NPC from an external script. This is useful as the external script con inject commands into the system while it is paused.
Even More ThingsMenu:
will prompt for a percentage walk and ruun speed. This is great for tines and giants and animals. The number 1 is 100, or normal speed, 0.50 is half as fast, and 2.0 is twice as fast.
will prompt you for the name of a prim. The NPC can only touch the root prim of the object.
The system will load a new notecard and play it from the start.
Load another Apperance notecard. The NPC will immediately switch. Very handy to make an avatar change into a monster, a bird that can fly off, or male/female changes.
There are some sample scripts for command injection in the zip file. All these scripts use a simple link message to communicate.
Any link message received by the NPC script will be processed immediately for
any @ commands. It will run the injected command the next timer tick,
which can be as short as right now, milliseconds, or as long as 0.5
seconds. If the command is not
You can issue an , then issue a series of commands, then send an and it picks up where it left off in the notecard. You can inject up to 64 link messages all at once and it will run them in order.
will remove the NPC, and any command received after that will auto re-rez it..
You can issue anvia a link message to cause some subroutine to run.
For example, this should loop the Dance animation every 5 seconds:
Injecting a link messageshould cause it to change dances to "AnotherDance" immediately.
Injecting a link messageshould cause it to change back to the original dance.
If you want to execute a new notecard, you use.
You may edit the notecard "!Path" at any time to change the commands.
All commands begin with an '@'. Lines that do not begin with an @ are ignored and can be used as comments or as destination labels for the @goto command
|Command||First Parameter||Second Parameter||Description|
|@spawn||Name of NPC||Location ( vector)||Spawn a NPC at this location|
|@walk||destination (vector)||NaN||Makes the NPC walk to destination.|
|@fly||destination (vector)||NaN||Makes the NPC fly to destination.|
|@land||destination (vector)||NaN||Makes the NPC land at a destination|
|@say||string||NaN||Makes the NPC speak a phrase 20 meters|
|@shout||string||NaN||Makes the NPC shout a phrase 100 meters|
|@whisper||string||NaN||Makes the NPC whisper a phrase 10 meters|
|@pause||seconds (float)||NaN||Makes the NPC wait for a multiple of seconds.|
|@wander||radius ( float)||Cycles (integer)||Makes the NPC wander in radius, for cycles seconds.|
|@stop||NaN||NaN||Halts the NPC script indefinitely. Can be started with a link message|
|@delete||NaN||NaN||Removes the NPC forever.|
|@animate||animation name (string)||time(float)||Makes the NPC trigger the animation animation for time seconds.|
|@goto||Label(string)||NaN||Jump to the label label in the script.|
|@rotate||degrees (float)||NaN||Rotate the NPC degrees around the Z axis.|
|@sit||Prim Name (string)||NaN||Sit on a primitive with a given name.|
|@stand||NaN||NaN||If sitting on a prim, stand up|
|@sound||Sound Name||NaN||Plays a sound file from inventory|
|@randsound||NaN||NaN||Plays a random sound picked from inventory|
|@cmd||channel (integer)||message (string)||Says message on channel, for controlling external gadgets|
|@notecard||string name||NaN||Load a new !Path notecard|
|@touch||string objectName||NaN||Touches an object on the root prim|
|@appearance||string NotecardName||NaN||Loads a new notecard|
|@speed||float NPCSpeed||NaN||Sets the speed of the avatar to normal (1.0) slower ( 0.l5 is half speed).|
|@teleport||vector DESTINATION||NaN||teleports the NPC to Destinationwithin the sim. NPCs cannot leave the sim.|
|@reset||NaN||NaN||Removes the NPC, reloads the !Path notecard and starts over at the beginning. Does not do an actual reset of the script.|
This script can accept additional commands from other scripts via link messages. Link Messages may be used to perform external control by injecting @commands directly into the stream of actions.
To chat something, such as with a chat robot in another script, execute this command:
If you send a stream of these Link Messages, the system will execute them in order. Ais a good way to run an uninterrupted sequence, followed by an .
There are a dozen tuneable settings in the script, in this section:
////////////////////////////////////////////////////////// // TUNABLE CONFIGURATION // ////////////////////////////////////////////////////////// float MAXDIST = 2.0; // how close a NPC has to get to a dest pos to continue to next state. Do not lower this too much, will also need a faster TIMER float TIMER = 0.5; // how often the system checks the distance traveled integer WANDERRAND = TRUE; // set to TRUE and they will pause during wanders a random number of seconds float WANDERTIME = 5.0; // how long they stand after each @wander,if WANDERRAND is FALSE. If WANDERRAND is TRUE, this is the max time integer WAIT = 60; // wait for this number of seconds for the NPC to reach a destination (for safety) float RANGE = 30.0; // 1 to 96.0 meters - anyone this close to the controller will start NPCS if Sensor button is clicked float REZTIME = 10.0; // wait this lng for NPC to rez in, then start the process string STAND = "Stand"; // the name of the default Stand animation string WALK = "Walk"; // the name of the default Walk animation string FLY = "Fly"; // the name of the default Fly animation string RUN = "Run"; // the name of the default Run animation float OffsetZ = 0.5; // appear 0.5 meter above ground, this is added to all destinations to keep them from sinking in.
Please support Open Source by crediting any authors of these scripts and sharing any improvements with the community.
Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3
Please see: http://www.gnu.org/licenses/gpl.html for legal details, rights of fair usage, the disclaimer and warranty conditions.
If you distribute copies of this program, whether gratis or for a fee, you must
pass on to the recipients the same freedoms that you received. You must make sure
that they, too, receive the source code by leaving this script MOD/COPY/TRANSFER.
And you must show them these terms so they know their rights.
Back to the Best Free Tools in Second Life and OpenSim.