Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IF YOU NEED SHOW MORE GO TO :https://gurl.pw/i2mq
- /* Edited to bejeezus from an existing free script, "Bailey Simple Poseball Script" by Alkarris Thirty.*/
- /* EDIT THESE, USER SCUM! */
- integer hideAndShowPrim = TRUE; //When set to TRUE, this hides the prim while being sat on, and unhides elsewise
- vector aniOffset = <0,0,-0.1>; //This is the physical offset. You will probably only want to edit the third number for up and down offset.
- vector aniRotation = <0,0,180>; //This is the rotation set to your body in relation to the prim.
- /* DON'T TOUCH STUFF PAST HERE UNLESS YOU HAVE A CERTIFICATION IN WIZARD SHIT */
- list aniList=[];
- string currentAnimation;
- integer currentPage=0;
- //populate our list with all of our animations, for a menu system
- CatalogAnimations()
- {
- aniList=[];//reset the list to empty
- integer i = 0;
- integer aniCount = llGetInventoryNumber(INVENTORY_ANIMATION);
- for(i=0;i<aniCount;i++)
- {
- string foundAni=llGetInventoryName(INVENTORY_ANIMATION, i);
- //if the string is more than 24 characters we have to cut it down for the buttons of the menu
- if(llStringLength(foundAni)>24) aniList+=llGetSubString(foundAni,0,10)+"…"+llGetSubString(foundAni,-10,-1);
- else aniList += foundAni;
- }//for loop
- llOwnerSay("Found " + (string)aniCount + " animations.");
- }//catalog()
- /* Create a list, with the page argument deciding how to display it:
- 1,2,3,etc. - If there are more than 11 poses total, position 0 will always show [PREV PAGE] and [NEXT PAGE] will be position 2 (lower left and lower right, respectively).
- Negative (-1, -2, etc.) - Pop an error. Shouldn't happen, but good to debug */
- ShowList(integer page)
- {
- if(page < 0) llDialog(llAvatarOnSitTarget(),"ERROR: Requested negative page. Contact Alkarris Thirty to report a bug in his stupid script, please.",["OK"],-1);//get our negative error catcher out of the way...
- else llDialog(llAvatarOnSitTarget(),
- "Pick an animation from the list. \nPage: "+(string)currentPage +" \nPlaying: "+ currentAnimation,
- DialogSortList(llList2List(aniList,0+(10*(page-1)),9+(10*(page-1)))),-11);
- }
- //This function just rearranges a given list to be Left-to-Right, Top-to-Bottom alpha sorted, taking the Next and Prev buttons in the corners into consideration.
- list DialogSortList(list iList){
- list oList;
- integer buttons=llGetListLength(aniList)>12;
- if(llGetListLength(iList)>12&&!buttons||llGetListLength(iList)>10&&buttons) return ["LIST2LONG"];
- else {
- if(buttons){
- oList+=Last3(llList2List(iList,0,-2));
- oList=["PREV PAGE"]+llList2List(iList,-1,-1)+["NEXT PAGE"]+oList;
- }
- else oList = Last3(iList);
- }
- return oList;
- }
- list Last3(list iList){ //this is a supplement to the DialogSortList function. I been chuggin brain hurt juice.
- if(llGetListLength(iList)<=3) return iList;
- else return llList2List(iList, -3, -1) + Last3(llList2List(iList,0,-4));
- }
- string ParseEllipsis(string msg){// match the ellipsis-ized button text to the inventory animation it came from.
- list chunks=llParseString2List(msg,["…"],[]);
- if(llGetListLength(chunks)>1){
- integer i;
- for(i=0;i<llGetInventoryNumber(INVENTORY_ANIMATION);++i){
- string iName=llGetInventoryName(INVENTORY_ANIMATION,i);
- if(llSubStringIndex(iName,llList2String(chunks,0))!=-1&&llSubStringIndex(iName,llList2String(chunks,1))!=-1) return iName;//match found
- }
- return msg;//no match found
- }
- else return msg;
- }
- default
- {
- //Initialize
- state_entry()
- {
- if(aniOffset==<0,0,0>) aniOffset=<0,0,0.1>; //Safeguard to make sure offset isn't 0,0,0 because that will cause llAvatarOnSitTarget to fail.
- if(aniRotation==<0,0,0>) aniRotation=<0,0,0.1>;//Rotation safeguard.
- llSitTarget(aniOffset, llEuler2Rot(aniRotation*DEG_TO_RAD)); // Set's the sit target position and rotation.
- if(hideAndShowPrim==TRUE)llSetAlpha(1.0, ALL_SIDES); // Initialize the object's alpha to visible
- CatalogAnimations();
- currentPage=1;
- llListen(-11,"",llAvatarOnSitTarget(),"");//only listen to the menu choices of whoever's sitting
- }
- listen(integer channel, string name, key id, string msg)
- {
- if(msg=="NEXT PAGE")
- {
- //The user pressed NEXT PAGE, so we increment our page count, then check to make sure there'll be animations on the next page, otherwise, we reset the counter back to page 1.
- if ((currentPage*10+1) > llGetListLength(aniList)) currentPage=1;
- else currentPage++;
- ShowList(currentPage);
- }
- else if(msg=="PREV PAGE")
- {
- //similar logic, but in decrements
- if(currentPage==1) currentPage=llCeil((float)llGetListLength(aniList)/10);
- else currentPage--;
- ShowList(currentPage);
- }
- else if(llGetInventoryType(ParseEllipsis(msg))==INVENTORY_ANIMATION)
- {
- llStopAnimation(currentAnimation);
- currentAnimation=ParseEllipsis(msg);
- llStartAnimation(currentAnimation);
- ShowList(currentPage);
- }
- else
- {
- //Okay, the button may have been truncated, now lets waste time and see if it matches up with any inventory item.
- integer i=0;
- integer aniCount = llGetInventoryNumber(INVENTORY_ANIMATION);
- for(i=0;i<aniCount;i++)
- {
- string foundAni=llGetInventoryName(INVENTORY_ANIMATION, i);
- if(llStringLength(foundAni)>24)
- {
- string inventorySubstring=llGetSubString(foundAni,0,23);
- if(msg==inventorySubstring)
- {
- llStopAnimation(currentAnimation);
- currentAnimation=llGetInventoryName(INVENTORY_ANIMATION, i);
- llStartAnimation(currentAnimation);
- ShowList(currentPage);
- }//if inventory substring matches button message
- }//if big inventory name
- }//for loop
- }//else
- }
- touch_start(integer num_detected)
- {
- //if the sitter clicks the object, reset the page count and display page 1 (or zero)
- if(llDetectedKey(0)==llAvatarOnSitTarget())
- {
- currentPage=1;
- ShowList(currentPage);
- }
- }
- // Called when an agent sits or unsits
- changed(integer change)
- {
- if(change & CHANGED_LINK)
- {
- currentPage=1;//reset our page bookmark on sit change
- if(llAvatarOnSitTarget() != NULL_KEY) // Makes sure there is a key from the avatar
- {
- llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION); // If so, request perms to play anim.
- }
- else //If not (Key is null) then agent unsat. Stop animation, make object visible, make float text visible
- {
- integer perm=llGetPermissions();
- if(llGetInventoryNumber(INVENTORY_ANIMATION)>0) llStopAnimation(currentAnimation);
- if(hideAndShowPrim==TRUE)llSetAlpha(1.0, ALL_SIDES);
- }
- }//if changed_link
- if(change & CHANGED_INVENTORY)
- {
- llOwnerSay("Inventory changed, re-cataloguing animations");
- CatalogAnimations();
- }//if changed_inventory
- if(change & CHANGED_OWNER) llResetScript();
- }//changed()
- // Called when permission to play anim are requested
- run_time_permissions(integer perm)
- {
- if (perm & PERMISSION_TRIGGER_ANIMATION)
- {
- if(llGetInventoryNumber(INVENTORY_ANIMATION)>0)
- {
- llStopAnimation("sit"); // Stop the default sit animation
- currentAnimation=llGetInventoryName(INVENTORY_ANIMATION,0); // Get the name of an animation in the object inventory
- llStartAnimation(currentAnimation); // Start the found animation
- currentPage=1;
- ShowList(currentPage);
- }
- else
- {
- llDialog(llAvatarOnSitTarget(),"No animations loaded into prim. Nothing to animate.",["OK"],-1);
- }
- if(hideAndShowPrim==TRUE)llSetAlpha(0.0, ALL_SIDES); // Make oject tranparent
- }
- }//r_t_p()
- }
- /* If you paid for this script, you were ripped off. Sincerely, Alkarris Thirty */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement