~Fiona's Script Library~

← Voltar para a Biblioteca

bouquet-thrower.lsl | 1.26 KB
Baixar
// Copyright 2025 Fiona Sweet - free to use for any purpose
// Bouquet-Thrower.lsl (in an attachment)

string BOUQUET = "Bouquet";
float POWER = 7.0;
float LIFT  = 12.0;

default
{
    state_entry()
    {
    //boo
    }

    attach(key id)
    {
	llStopAnimation(llGetInventoryName(INVENTORY_ANIMATION, 0));
        llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION);

    }

    touch_start(integer n)
    {
        // rez point a little ahead of your hand/attachment
        rotation R = llGetRot();                 // attachment’s rotation
        vector fwd = llRot2Fwd(R);
        vector up  = llRot2Up(R);

        vector rezPos = llGetPos() + fwd * 0.5 + up * 0.2;
        vector vel    = fwd * POWER + up * LIFT;

        // Rez a temporary, physical bouquet
        llRezObject(
            BOUQUET,
            rezPos,
            vel,                                 // initial velocity
            R,                                   // start with same facing
            0
        );
    }
    
    run_time_permissions(integer p)
    {
        if (p & PERMISSION_TRIGGER_ANIMATION)
        {
            llStartAnimation("express_afraid"); // ??? maybe this exists
            llSleep(2.0);
            llStopAnimation("express_afraid");
        }
    }
}