Got a script for a chair that will make the "sitter" choose different poses as she sits down.
The script works well exept for 1 small thing... It doesnt reas the NC correct, and leaves out the first line... i think...
Here it goes:
MY NOTECARD:
------------------------------------------
Female,female
Male1,sitting chair m04
Male2,sitting chair m07
------------------------------------------
MY SCRIPT:
------------------------------------------
// Animation Player v1.0 - Newgate Ludd
// ------------------------------------
// Written in responce to a posting on the Forums by Artemis Winthorpe
//
string notecardName = "Contents List"; // Notecard containing list of animations
integer lineCounter; // Line number within the notecard
key dataRequestID; // Data request ID
integer CHANNEL = 42; // Channel on which Dialog listens
list MENU; // Menu text for each Anim
list ANIMS; // Actual Animation name
integer maxAnims; // Number of Animations laoded
integer first; // First entry to be displayed on Dialog
integer pagesize = 8; // Number of Items per Dialog
list choices; // Current Dialog Choices
integer Listening = 0; // Listen handle
string animation_name; // Name of current animation
string new_animation_name; // Name of next animation.
key avatar; // Key of the avatar who's sitting on me
vector placement = <0.0,0.0,0.2>;
integer i; // General Purpose
// --------------------------
UpdateListen(key id)
{
CancelListen();
Listening = llListen(CHANNEL,"",id,""
;llSetTimerEvent(20);
}
// --------------------------
CancelListen()
{
if(Listening > 0) llListenRemove(Listening);
Listening = 0;
llSetTimerEvent(0);
}
// --------------------------
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 anim would you like to play?", choices, CHANNEL);
UpdateListen(avatar);
}
// --------------------------
// Set the next animation available as the active one
PlayAnimation(integer number)
{
// Get the name of the animation
new_animation_name = llList2String(ANIMS,number);
// Get the key of the avatar on the stand (or if none is present)
avatar = llAvatarOnSitTarget();
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;
}
// --------------------------
default
{
state_entry() { state ReadNoteCard; }
on_rez(integer num) { llResetScript(); }
}
// --------------------------
state Running
{
state_entry()
{
llSitTarget(placement,<0,0,0,90>
;animation_name = "sit";
maxAnims = llGetListLength(MENU);
llSay(0,llGetScriptName() + " Loaded - " + (string)maxAnims + " Avaliable."
;}
on_rez(integer num) { llResetScript(); }
touch_start(integer total_number)
{
key id = llDetectedKey(0);
// We only want the Avatar currently sat to be able to change pose
if(avatar == id) ShowMenu();
}
listen(integer channel, string name, key id, string message)
{
CancelListen();
// verify dialog choice
// present main menu on request to go back
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);
}
}
}
timer()
{
CancelListen();
}
changed(integer change)
{
// Test for a changed inventory
if (change & CHANGED_INVENTORY)
{
llResetScript();
}
// The object's sit target has been triggered
if (change & CHANGED_LINK) // Test for a changed link
{
avatar = llAvatarOnSitTarget();
if(avatar != NULL_KEY) // Is that changed link an avatar?
{
llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
}
else
{
if (llGetPermissionsKey() != NULL_KEY)
{
llStopAnimation(animation_name);
}
}
}
}
run_time_permissions(integer perm)
{
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation("sit"
;llStartAnimation(animation_name);
first = 0;
ShowMenu();
}
}
}
// --------------------------
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)
{
llSetTimerEvent(0);
//If we haven't reached the end of the file
if (data != EOF)
{
dataRequestID = llGetNotecardLine(notecardName, lineCounter);
llSetTimerEvent(10);
lineCounter += 1;
// Each line is of the form
// Name,Animation
if(llGetSubString(data, 0,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;
}
else
{
llOwnerSay("Error - " + name + " (" + anim + "
Not an Animation."
;}
}
}
else
{
llSetTimerEvent(0);
state Running;
}
}
}
timer()
{
// The notecard read failed so abort
llSetTimerEvent(0);
llOwnerSay("Error reading Data.Aborting."
;state Running;
}
}
------------------------------------------
Can someone help, please

/Jonesey
