CODE
vector velocity;
float DELAY = 0.2;
float hitpower = 10;
float alpha = 1.00;
integer have_permissions = FALSE;
integer armed = TRUE;
swing()
{
if (armed)
{
armed = FALSE;
llStartAnimation("throw_r");
llSetTimerEvent(DELAY);
}
}
hit()
{
vector vel = llGetVel() * hitpower;
llPushObject(llDetectedKey(0), vel, ZERO_VECTOR, FALSE);
llSetForce(<0,0,0>, TRUE);
llSetForce(<0,0,0>, TRUE);
}
default
{
state_entry()
{
llCollisionFilter("", NULL_KEY, TRUE);
}
attach(key attached)
{
if (!have_permissions)
{
llRequestPermissions(llGetOwner(),
PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS);
}
else
{
}
}
run_time_permissions(integer permissions)
{
if (permissions == PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS)
{
llTakeControls(CONTROL_ML_LBUTTON, TRUE, FALSE);
llStartAnimation("hold_throw_R");
have_permissions = TRUE;
}
}
attach(key attachedAgent)
{
if (attachedAgent != NULL_KEY)
{
llRequestPermissions(llGetOwner(),
PERMISSION_TRIGGER_ANIMATION| PERMISSION_TAKE_CONTROLS);
}
else
{
if (have_permissions)
{
llStopAnimation("hold_throw_R");
llStopAnimation("throw_R");
llReleaseControls();
have_permissions = FALSE;
}
}
}
control(key name, integer levels, integer edges)
{
if ( ((edges & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON)
&&((levels & CONTROL_ML_LBUTTON) == CONTROL_ML_LBUTTON) )
{
swing();
}
}
collision_start(integer total_number)
{
hit();
}
touch_start(integer total_number)
{
hit();
}
timer()
{
llSetTimerEvent(0.0);
armed = TRUE;
}
}
I've got a baseball bat that isn't working. You fix it, you get a free copy and five for your friends.(Seeing as I'm broke as Hell.) And. . .I guess anyone else who reads this now would have working code for one, too. But I digress.
Thanks in advance for anything you might do. And set, the "Physical" checkbox is checked.