User:Dz/AO

Animation Override scripts
These are AO scripts I have used or developed over time. Many of them are assembled from bits and pieces of code I have read/seen/fixed/admired. Some of the code snippets appear with permissions, Please do not remove the attributions where they can be found in the comments. The code has been shared, only asking simple consideration. Please respect the wishes of the original authors as I have attempted to do.

These AO designs are NOT compatible with NPCs, as they require a user to touch them to activate.

If you have feedback on script errors, please post it to the page discussion User_talk:Dz/AO

Simple Click on/off Variable speed AO demo
This is an example of an AO script designed for use in OpenSimulator. These instructions describe how to make your own AO from scratch.

For this example, I use animations found in the Linda Kelly RUGGED male AO. They should be widely available, and you are free to modify the script to use your own.

The variable speed option requires that OS functions be enabled and the threat level set appropriately in the region you want to use this in. This script selects a random walk animation from the 3 provided and changes the walk speed to more closely match the animation selected.

Step 1. Generate a small cube (0.15, 0.15, 0.15)

Step 2. Drag copies of the AO animations you want to use into the contents of the cube.

Step 3. Drop this script in the cube.

Step 5. Edit the script to make sure the animation names in the top section match the animation names you added to the cube.

Step 6. Adjust the speed values in the walk animation list and below in the section of code that looks like this... ( 1.0 is the default Opensim speed, this is a multiplier)

Step 7. Rename the cube "MYAO" (something you can find in your inventory) and pick it up.

Step 8. Attach it to one of your HUD positions ... Step 9. Resize and position.

Touch to toggle between on and off. Re-attach or edit and "script reset" to reset.

Why you should (probably) NEVER use a Second Life AO script in OpenSimulator
Chances are, if you are using a Second Life AO script in OpenSim, you are abusing the region server resources, and perpetuating the myth that all AO's are good for is generating lag. There are fundamental differences between the animation events in SecondLife and Opensim that make Second Life AO script overhead unnecessary.

When the GPL'd ZHAO code was written for SL, it was designed to ask the region "what is my current animation state?" multiple times a second. It then compares the returned state to the last one to see if anything has changed, and if it has, it looks up the new animation it needs and starts to play it. Depending on the timer settings it can ask the same question 4 or 5 times a second (which doesn't work well in OpenSim).

Lets look at what happens when you enter a sim and stand, with your AO set for 1/3 second checks, and your stand changing every 20 seconds...

''Enter sim, Script loads into memory and starts.

''Script encounters Stand state, activates stand animation,

''sets stand timer to 20 seconds

''in the next 20 seconds the script will ask the sim 60 times "are we still standing?"

''timer elapsed and a new stand animation is triggered

''in the next 20 seconds the script will ask the sim 60 times "are we still standing?"

''timer elapses and the stand animation changes...

''in the next 20 seconds the script will ask the sim 60 times "are we still standing?"

...That's the first minute.

180 "extra" sim interruptions to make sure you haven't stopped standing still. Say 20 of you in the sim with the same AO... That's 3600 "extra" sim interruptions (per minute) to answer your scripts. In the example below, setting the timer event to 0.25 seconds would generate 14000 interruptions per hour for each AO.. For our mythical group of 20, 280,000 "are we still standing" questions per hour versus 6000 events using the modified script...

In OpenSimulator, the design can be much more efficient. The developers have added a CHANGED_ANIMATION parameter to the CHANGED event in OpenSim, so our scripts don't have to ask what the current animation state is,  it just needs to handle the changed event when it is notified. These lines of code replace the timer loop that asks the repetitive question by sending a notice to the script when a new animation state is triggered.. Our script is basically these lines..

Yes, there is still overhead to loading and running the AO script, but with this interrupt driven design we eliminate a vast majority of the overhead and wasted processing time.

Converting ZHAO scripts to work in OpenSim efficiently
If you LOVE your ZHAO based AO  and HAVE TO HAVE IT in OpenSim,  Do us all a favor.. follow these instructions and modify your script.

Step 1. Make sure you have a ZHAO based AO. Put the AO on the ground and Edit it. Look in the CONTENTS tab. If you find the scripts ZHAO II CORE, ZHAO II INTERFACE, and notecard named something like ZHAO READ ME, and a notecard named "default",  proceed to step 2. If you did NOT find any of those files, there is a 100% chance that I take no responsibility for you proceeding to step 2.

Step 2. Make a backup copy of the ZHAO II CORE script by dragging it into your scripts folder in your inventory.

Step 3. Edit your ZHAO CORE script and locate the following lines....

REPLACE WHATEVER NUMBER IS AFTER THE = with 0.0.....  so the line looks like this....

( If you are interested in calculating the amount of processing you might save... this value of .25 means that your AO checks 4x a second to see what you are up to. That can mean more than 14,000 "are we still standing" events an hour.  In contrast, changing the stand every 12 seconds for an hour, this modified AO script only requires 300 events. )

Step 4. Local the section of code that handles the CHANGE event....   It should look something like this.....

Add the 2 new lines of code....

if (change & CHANGED_ANIMATION) checkAndOverride;

So it looks like this...

Step 5. Save your changes to the script, put the AO in your inventory and then attach/wear it again. If you have problems, replace your modified version of the script with the one you saved in step 2 above.