Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

"dumpster" script weirdness

Frequency Picnic
Registered User
Join date: 31 Oct 2006
Posts: 13
04-30-2009 08:13
You may have seen the freebie dumpsters that were all the rage inworld last year. It gives one item in its inventory after a user clicks or sits on it (and usually plays a "digging" animation first). A friend of mine made this script a while ago but neither of us can figure out what's wrong with it. I put it in an object, and the first time it's sat on, nothing happens, not even a sit animation. The second time, it works but I get the "broken script icon".
//Gives a random object from inventory when the scripted-object is touched. Does not charge money, items MUST be "objects" i.e. clothing needs to be boxed.

default
{
state_entry()
{
llAllowInventoryDrop(TRUE);
llSetSitText("Grab!";);
llSitTarget(<0,0,1>, <0,0,0,0>;);
}

changed(integer change)
{
if(change & CHANGED_LINK)
{
key avataronsittarget = llAvatarOnSitTarget();
if(avataronsittarget!=NULL_KEY)
{
if((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && llGetPermissionsKey() == avataronsittarget){
llStopAnimation("sit";);
llStartAnimation("dumpster";);
llSay(0, "You start exploring the contents of the dumpster...";);
state diving;
}
else
{
llRequestPermissions(avataronsittarget, PERMISSION_TRIGGER_ANIMATION);

}
}
}
}
run_time_permissions(integer perm)
{
if(perm)
{
llStopAnimation("sit";);
llStartAnimation("stand";);}


}
}
state diving
{
state_entry()
{
llSetTimerEvent(10.0);
}

timer()
{
llSay(0, "You find unexpected treasure!";);
integer content = llGetInventoryNumber(INVENTORY_OBJECT);
float rand = llFrand(content);
llGiveInventory(llAvatarOnSitTarget(), llGetInventoryName(INVENTORY_OBJECT, (integer)rand));
llStopAnimation("dumpster";);
llSetTimerEvent(0);
llUnSit(llAvatarOnSitTarget());
llResetScript();

}
}



anybody have advice? I'd love to make it work, since the dumpsters sold on SLX are no-mod.
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
04-30-2009 08:35
From: someone
the first time it's sat on, nothing happens, not even a sit animation.

I think that's because the script says,
CODE
changed(integer change)
{
if(change & CHANGED_LINK)
{
key avataronsittarget = llAvatarOnSitTarget();
if(avataronsittarget!=NULL_KEY)
{
if((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && llGetPermissionsKey() == avataronsittarget){
llStopAnimation("sit");
llStartAnimation("dumpster");
llSay(0, "You start exploring the contents of the dumpster...");
state diving;
}
else
{
llRequestPermissions(avataronsittarget, PERMISSION_TRIGGER_ANIMATION);

}
}
}
}
That is, if we've got animation permissions -- which we don't the first time you sit on it, of course -- do stuff, otherwise ask for the permissions.. which is fair enough.

But, when you ask for the permissions, you don't do much with them:
CODE
run_time_permissions(integer perm) 
{
if(perm)
{
llStopAnimation("sit");
llStartAnimation("stand");}


}
All you're doing there is turning off the default sit anim and turning on the default stand one. But nothing else is going to happen unless you tell it to.

Can you be more specific about the "broken script icon"? If you click it, you should get a little window open up to tell what's wrong....I can think of several things it might be complaining about, but knowing exactly what they are would help.
Frequency Picnic
Registered User
Join date: 31 Oct 2006
Posts: 13
04-30-2009 09:00
oh! I never knew you could click on those icons -- it says "animation 'dumpster' not found" which is no big deal, I'll put one in there and get back to you :)
Frequency Picnic
Registered User
Join date: 31 Oct 2006
Posts: 13
04-30-2009 09:05
ok, I'm not getting the error anymore, but it only works every other time it's sat on...
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
04-30-2009 09:50
move this code into the runtime permissions event
CODE

key avataronsittarget = llAvatarOnSitTarget();
if(avataronsittarget!=NULL_KEY)
{
// if((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && llGetPermissionsKey() == avataronsittarget){
llStopAnimation("sit");
llStartAnimation("dumpster");
llSay(0, "You start exploring the contents of the dumpster...");
state diving;
}
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -