Ugh typos like this one  console.LogInfo("Hey great, I found " +
entityNameToFind +. Starting animation); shoud have " after the
entityNameToFind
+.

Having all those prints and the timer to retry are kind of extra, on a
clean production version you would know that the stuff is present and will
be found 100% so you could remove most of the code there to about 5 lines.
I added some error reporting for you just for fun.

Have fun, hope it works :)

Best regards,
Jonne Nauha
Adminotech developer


On Fri, Mar 23, 2012 at 4:00 PM, Jonne Nauha <[email protected]> wrote:

> I do one better from Ali. This script will find the entity from the scene,
> you can attach it to any entity or of course to the entity you want to
> animate.
>
> As Ali said
>
>    - Create EC_Script, open it up to edit the attributes.
>    - Run mode: Client
>    - Run on load: true
>    - script ref: local://startanimation.js
>
> Save the following text as statanimation.js to the folder where your scene
> is (or a subfolder there).
>
> You can also give --console param to the client so its easy to see syntax
> errors and all the prints. When the whole thing is running you can edit the
> script file live. Every time you hit save Tundra will reload and run the
> script!
>
> *Note: I did not run the script, it might have typo and what not. The
> idea is there. Also define your entity name and animation name to the
> variables on top!*
>
> var entityNameToFind = "VaibhavsAnimationEntity";
> var animationNameToStart = "Walk";
>
> funtion StartAnimation()
> {
>     var objectToAnimate = scene.GetEntityByName(entityNameToFind);
>     if (objectToAnimate != null && objectToAnimate.animationcontroller !=
> null)
>     {
>         // See usage from
> http://realxtend.org/doxygen/class_e_c___animation_controller.html
>         console.LogInfo("Hey great, I found " + entityNameToFind +.
> Starting animation);
>         var availableAnims =
> objectToAnimate.animationcontroller.GetAvailableAnimations();
>
>         var animFound = false;
>         for(var i=0; i<availableAnims.length; i++)
>         {
>             if (availableAnims[i] == animationNameToStart)
>             {
>                 animFound = true;
>                 break;
>             }
>         }
>         if (animFound)
>         {
>             //
> http://realxtend.org/doxygen/class_e_c___animation_controller.html#a91684343e20c92509c973327d820827b
>
> objectToAnimate.animationcontroller.EnableAnimation(animationNameToStart,
> true);
>         }
>         else
>             console.LogError("Entity was found but it has no animation
> named " + animationNameToStart + ", cannot proceed!");
>     }
>     else
>     {
>         console.LogWarning("Entity " + entityNameToFind + " was not found
> or animation controller component is not there! Trying again in 1 second.);
>         frame.DelayedExecute(1.0).Triggered.connect(StartAnimation);
>     }
> }
>
> // Only run on client. One time animation enabling.
> if (!server.IsRunning() && !framework.IsHeadless())
> {
>     StartAnimation();
> }
>
>
> Best regards,
> Jonne Nauha
> Adminotech developer
>
>
>
> On Fri, Mar 23, 2012 at 3:50 PM, Ali Kämäräinen <[email protected]>wrote:
>
>> Assuming you have an entity in the scene with Mesh, Placeable et al,
>> 1) Create the script. For example:
>> console.LogInfo("Hello, my name is " + me.name);
>> 2) Save as Test.js to the folder you're scene is.
>> 3) Add Script component to your entity, set "Run on load" true, set
>>  Test.js  to the "Script ref"
>> 4) Hit F1 to see the console, you should see the print there
>> 5) Continue from there, see avatar scripts for example
>>
>> Grey skies,
>> Ali Kämäräinen
>>
>> --
>> http://groups.google.com/group/realxtend
>> http://www.realxtend.org
>>
>
>

-- 
http://groups.google.com/group/realxtend
http://www.realxtend.org

Reply via email to