Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Basic scripting help - retrieving inventory items

Ursula Geiger
Registered User
Join date: 13 Oct 2006
Posts: 4
05-18-2007 15:29
Hi
I am new to Scripting so I am guessing what I am doing wrong is probably obvious. I have a couple of scripts to get an animation from the inventory to add to an object - ie I am trying to make a pose ball but my script cant retrieve the animation. Where am I going wrong? The function llGetInventoryType returns false even though I know the animation is there. I am thinking that I dont have to specify the pathway to the animation - that just the name should be enough...


string ANIMATION = "nameOfAnimation";

init()
{
if(llGetInventoryType(ANIMATION) != INVENTORY_ANIMATION)
{
if(llGetInventoryNumber(INVENTORY_ANIMATION) == 0) // Make sure we actually got something to pose with.
{
llWhisper(0,"Error: No animation found. Cannot pose.";);
animation = "sit";
}
else
animation = llGetInventoryName(INVENTORY_ANIMATION, 0);
}
else
animation = ANIMATION;
}
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
05-18-2007 15:49
If I do this:

CODE

string ANIMATION = "nameOfAnimation";
string animation;

init()
{
if(llGetInventoryType(ANIMATION) != INVENTORY_ANIMATION)
{
if(llGetInventoryNumber(INVENTORY_ANIMATION) == 0) // Make sure we actually got something to pose with.
{
llWhisper(0,"Error: No animation found. Cannot pose.");
animation = "sit";
}
else
animation = llGetInventoryName(INVENTORY_ANIMATION, 0);
}
else
animation = ANIMATION;
}


default
{
state_entry()
{
init();
llOwnerSay("Animation = " + animation);
}
}



And I put an animation in the object named: nameOfAnimation

This result prints: Object: Animation = nameOfAnimation

Which seems to be correct.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-18-2007 15:50
The Inventory functions refer to the object's inventory not yours.
_____________________
I'm back......
Ursula Geiger
Registered User
Join date: 13 Oct 2006
Posts: 4
still an issue
05-18-2007 16:15
thanks for such a quick reply - I tried this but I still have the same problem - it compiles but fails to find the animation ie spits out "Error: No animation found. Cannot pose";);
Ursula Geiger
Registered User
Join date: 13 Oct 2006
Posts: 4
05-18-2007 16:17
thanks Newgate that makes more sense then - and begs the next obvious question how do i put the animation into my objects inventory - perhaps this is where I need to go and do some more reading first!
Ursula Geiger
Registered User
Join date: 13 Oct 2006
Posts: 4
05-18-2007 16:30
From: Ursula Geiger
thanks Newgate that makes more sense then - and begs the next obvious question how do i put the animation into my objects inventory - perhaps this is where I need to go and do some more reading first!



OK GOT IT WORKED OUT!