Change font size
It is currently Mon Feb 18, 2019 11:49 am

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 8 posts ]
Author Message
 Post subject: No Dice
PostPosted: Mon Jul 30, 2012 2:56 pm 
Furious Typer
User avatar

Joined: Mon Oct 25, 2010 7:42 pm
Posts: 234
Location: Canada
I thought I had one of these that was ready to go in a die I once found on Sandbox Plaza. However, when I rezzed it it became apparent that the script didn't function as I remembered it had. It hovers upon rez and then lands on a point when touched. It's also no mod (le sigh). I'm just looking to make a die that rolls as if die would and land flat (if possible). I don't want any fancy HUDs that tell you you've rolled a 4 in local or anything. Does anyone have a script of this type they'd be willing to share?


Top
 Profile  
 
 Post subject: Re: No Dice
PostPosted: Mon Jul 30, 2012 5:44 pm 
Furious Typer

Joined: Tue Aug 18, 2009 2:42 am
Posts: 233
Jamie, IM me inworld please.


Top
 Profile  
 
 Post subject: Re: No Dice
PostPosted: Tue Jul 31, 2012 1:32 am 
It's a great pity this can't be shared...sounds like a useful script for game creation.


Top
  
 
 Post subject: Re: No Dice
PostPosted: Tue Jul 31, 2012 9:06 am 
Furious Typer
User avatar

Joined: Mon Oct 25, 2010 7:42 pm
Posts: 234
Location: Canada
I've recruited my hubby to work on one with me. If we come up with something that works, I'll post it. I just thought I'd check before reinventing the wheel. I saw a few for SL but it looked like they were meant to pair with a HUD.


Top
 Profile  
 
 Post subject: Re: No Dice
PostPosted: Tue Jul 31, 2012 9:29 pm 
Furious Typer

Joined: Tue Aug 18, 2009 2:42 am
Posts: 233
{L_QUOTE}:
It's a great pity this can't be shared...

It's not a huge secret. I simply used the free Linden Dice, tweaked the variables so they work better with our physics engine and "upgraded" it with the part that actually says (on a predefined channel) which pips land on top - this is useful with boards etc. I just thought Jamie wanted a working dice inworld.
I have put the working dice in my shop now, since there seems to be a need ;)

Here is the script:
{L_CODE}:
// physical Dice
// made from the freely available Linden Dice script
// tweaked and improved for OSgrid by Eryn Galen
// gives the shown pips for use with a master script
// and flips when you click on it.
//
// Script freely given as long as this header is left in the script!
// Please don't forget to credit.
// If you make improvements, please share back!
//

// Variables - you can tweak these to individualize.
float HOP_SCALE = 1.25;
float TORQUE_SCALE = 2.0;
integer CHANNEL = 3423;
vector HELD_COLOR = <1, 0.75, 0.75>;
string dice-drop = "";
float svolume = 0.5;

// Variables needed for operation - please leave alone!
integer HELD = FALSE;
vector last_color;
vector impulse;
vector torque;
vector poscurr;

// Script starts here
// Do NOT change anything unless you know what you are doing.

integer pips_up(rotation rot)
{
    vector vee = llRot2Up(rot);
    integer k = llRound(vee.z);
    if (k == 1)
    {
        return 6;
    } else if (k == -1)
    {
        return 5;
    }
    vee = llRot2Fwd(rot);
    k = llRound(vee.z);
    if (k == 1)
    {
        return 3;
    } else if (k == -1)
    {
        return 2;
    }
    vee = llRot2Left(rot);
    k = llRound(vee.z);
    if (k == 1)
    {
        return 1;
    } else if (k == -1)
    {
        return 4;
    }
    return -1; // So that the compiler doesn't complain.
}

default
{
    state_entry()
    {
        llCollisionSound(dice-drop, svolume);      //  Override normal collision sounds
    }

    touch_start(integer total_number)
    {
        HELD = TRUE;
        last_color = llGetColor(0);
        llSetColor(HELD_COLOR, ALL_SIDES);
        llSay(CHANNEL, "die");
    }
   
    attach(key avatar)
    {
        //
        //  If this gets called it means someone has attached this
        //  object to their body rather than creating in-world.
        //  Ask for permission to detach, then do so with a message
        //
        if (avatar != NULL_KEY)
        {
            llRequestPermissions(llGetOwner(), PERMISSION_ATTACH);
        }
    }
   
    run_time_permissions(integer perm)
    {
        //
        //  This means we are now OK to detach from avatar, so send message and do so
        //
        llWhisper(0, "Drop me on the ground, don't attach me to your body.");
        llDetachFromAvatar();
    }
   
    touch_end(integer total_number)
    {
        HELD = FALSE;
        llTargetOmega(<1,1,1>, 0.0, 0.0);
        llTriggerSound(dice-drop, svolume);
        llSetColor(last_color, ALL_SIDES);
        impulse = < 0,
                    0,
                    HOP_SCALE>;
        llApplyImpulse(impulse, FALSE);
        torque = <  llFrand(TORQUE_SCALE),
                    llFrand(TORQUE_SCALE),
                    llFrand(TORQUE_SCALE)>;
        llApplyRotationalImpulse(torque, TRUE);
        vector pos = llGetPos();
        pos.z += 0.250;
        pos.x += 0.250;
        poscurr = llGetPos();
        llSetTimerEvent(1.0);
    }
   
    timer()
    {
        if( poscurr == llGetPos() )
        {         
            llSetTimerEvent(0.0);
            llSay(CHANNEL,(string)pips_up(llGetRot()));
        } else
        {
            poscurr = llGetPos();
        }
    }
}


Top
 Profile  
 
 Post subject: Re: No Dice
PostPosted: Tue Jul 31, 2012 11:03 pm 
Furious Typer
User avatar

Joined: Mon Oct 25, 2010 7:42 pm
Posts: 234
Location: Canada
Thanks Eryn:)


Top
 Profile  
 
 Post subject: Re: No Dice
PostPosted: Wed Aug 01, 2012 8:44 am 
Thanks Eryn :-)


Top
  
 
 Post subject: Re: No Dice
PostPosted: Sat Apr 11, 2015 6:48 pm 
User avatar

Joined: Sat Apr 11, 2015 4:05 pm
Posts: 15
hello everyone I'm new here, i love your website , I search a simple little script Dice picture. 6 simple script picture 1, 2, 3, 4, 5, 6, and when you click the image, the numbers is mixing and a random number appears, I would use this little script to a game on my sim, somebody a there a script like this they would be willing to share? thank you, 8-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 8 posts ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net