|
TennesseeJed Leafblower
Registered User
Join date: 25 Jul 2006
Posts: 5
|
10-08-2006 13:18
I built some instruments I've made some animations to play the instruments. I would like to wear the instruments and click to start animation, again to stop later, I would like to be able to click to choose from menu of several animations.
I'm slowly becoming more sure with looking into scripts to change a thing or two, but am not sufficient in writing. In time.
Thanks for your help! TNJED
|
|
Mod Faulkner
Registered User
Join date: 11 Oct 2005
Posts: 187
|
It can be done.
10-08-2006 15:29
What you want is relatively straight forward to do using a menu, but is would take sometime to write up up a clear outline for you. If you don't get a responce here or figure it out yourself, IM me in world and we can talk.
Mod
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
10-09-2006 06:11
I've done something similar using the following script. note that it IS NOT touch driven as it stands, rather you type /9MENU to display the menu. // Attachment Animation Player v1.0 - Newgate Ludd // ----------------------------------------------- // string notecardName = "Anims"; // Notecard containing list of animations integer lineCounter; // Line number within the notecard key dataRequestID; // Data request ID list MENU; // Menu text for each Anim list ANIMS; // Actual Animation name integer maxAnims; // Number of Animations loaded integer first; // First entry to be displayed on Dialog integer pagesize = 8; // Number of Items per Dialog list choices; // Current Dialog Choices string animation_name; // Name of current animation string new_animation_name; // Name of next animation. string default_anim = ""; // Default animation to play key avatar; // Key of the avatar who's using me (will always be owner?) integer ListenChannel = 9; // Default Chat Channel integer i; // General Purpose
// -------------------------- ShowMenu() { choices = []; if(avatar == llGetOwner()) choices += ["*RELOAD*"]; // Now add the items //len = llGetListLength( MENU ); if(first > 0) choices += "Prev"; if(maxAnims > (first + pagesize)) { choices += "Next"; } for(i = 0;i < pagesize;i++) { string strname = llList2String(MENU,(i+first)); if( llStringLength(strname) > 0) { choices += strname; } } // finally show the dialog llDialog(avatar, "Which pose would you like to do?", choices, ListenChannel); } // -------------------------- // Set the next animation available as the active one PlayAnimation(integer number) { // Get the name of the animation new_animation_name = llList2String(ANIMS,number); //llOwnerSay("Playing [" +new_animation_name + "] " + (string)number);
if (avatar != NULL_KEY) // Is avatar is still posing, if so then.. { llStopAnimation(animation_name); // Stop current animation llStartAnimation(new_animation_name); // Start next animation } // Set the new animation name as the current animation_name = new_animation_name; } // -------------------------- Help() { string text = "Help\nType /"+(string)ListenChannel+"MENU to show Menu\nType /"+(string)ListenChannel+"Anim name to activate\n"; llDialog(avatar, text, [], ListenChannel); } // -------------------------- default { state_entry() { state ReadNoteCard; } on_rez(integer num) { llResetScript(); } } // -------------------------- state Running { state_entry() { avatar = llGetOwner(); maxAnims = llGetListLength(MENU); llSay(0,llGetScriptName() + " Loaded - " + (string)maxAnims + " Available."); default_anim = llList2String(ANIMS,0); animation_name = default_anim; llListen(ListenChannel,"",avatar,""); integer perm = llGetPermissions(); if (! (perm & PERMISSION_TRIGGER_ANIMATION)) { key id = llGetOwner(); llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION); } } listen(integer channel, string name, key id, string message) { //llOwnerSay("Heard [" +message + "] on channel " + (string)ListenChannel); if("MENU" == message) { avatar = id; ShowMenu(); } else if("*RELOAD*" == message) { llResetScript(); } else if("Prev" == message) { first -= pagesize; ShowMenu(); } else if("Next" == message) { first += pagesize; ShowMenu(); } else { integer index = llListFindList(MENU, [message]); if(index != -1) { PlayAnimation(index); } } } changed(integer change) { // Test for a changed inventory if (change & CHANGED_INVENTORY) { llResetScript(); } else if (change & CHANGED_OWNER) { llResetScript(); } } on_rez(integer num) { integer perm = llGetPermissions(); if (! (perm & PERMISSION_TRIGGER_ANIMATION)) { avatar = llGetOwner(); llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION); } } attach(key id) { integer perm = llGetPermissions(); avatar = id; if (id != NULL_KEY) { if (! (perm & PERMISSION_TRIGGER_ANIMATION)) { llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION); } } else { if (perm & PERMISSION_TRIGGER_ANIMATION) { llStopAnimation(animation_name); } } }
run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) { animation_name = default_anim; //llStopAnimation("sit"); llStartAnimation(animation_name); first = 0; //ShowMenu(); Help(); } }
} // -------------------------- state ReadNoteCard { on_rez(integer num) { llResetScript(); } state_entry() { MENU = []; ANIMS = []; lineCounter = 0; integer itemtype = llGetInventoryType(notecardName); if(INVENTORY_NOTECARD == itemtype) { dataRequestID = llGetNotecardLine(notecardName, lineCounter); llSetTimerEvent(10); } else { llOwnerSay("Error - Contents list notecard missing!"); state Running; }
} dataserver(key queryid, string data) { //Check to make sure this is the request we are making. //Remember that when data comes back from the dataserver, //it goes to *all* scripts in your prim. //So you have to make sure this is the data you want, and //not data coming from some other script. if (dataRequestID == queryid) { llSetTimerEvent(0); //If we haven't reached the end of the file if (data != EOF) {
// Each line is of the form // Name,Animation if(llGetSubString(data, 0,0) != ";") { if(llStringLength(data) > 0) { list ldata = llParseString2List(data, [",","="], [""]); string name = llList2String(ldata, 0); string anim = llList2String(ldata, 1); integer itemtype = llGetInventoryType(anim); if(INVENTORY_ANIMATION == itemtype) { MENU = (MENU = []) + MENU + name; ANIMS = (ANIMS = []) + ANIMS + anim; llOwnerSay("Adding \""+name+"\" ("+anim+")"); } else if("CHANNEL" == name) { ListenChannel = (integer)anim; llOwnerSay("Type /"+(string)ListenChannel+"MENU to activate menu"); } else { llOwnerSay("Error - " + name + " (" + anim + ") Not an Animation."); } } } lineCounter += 1; dataRequestID = llGetNotecardLine(notecardName, lineCounter); llSetTimerEvent(10); } else { llSetTimerEvent(0); state Running; } } } timer() { // The notecard read failed so abort llSetTimerEvent(0); llOwnerSay("Error reading Data.Aborting."); state Running; } }
The object needs to contain a notecard, called "Anims" by default, which should contain a list of menu items and animations to play i.e. Strum=strum_anim Chord=play_chord_anim
Enjoy
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
10-09-2006 11:42
I have an animation stand (similar to a pose stand) that cycles through all the built-in SL animations ('sit', 'stand', 'hold_r_handgun', etc.). It has a nice UI including menus and control keys. Sometime when I can actually log in I will try to remember to post the code here.
|