Jump to content

give prims equal position coordinates through dialog


testgenord1
 Share

You are about to reply to a thread that has been inactive for 1554 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi!
I've got a script from somebody else which arranges linked prims in one line by the same distance to each other
(for example for linking letters to a word in one regular line).

I would like the script to be more automatic by adding a dialog offering a "+" and "-" choice.
"+" would mean that the distance between the linked prims should increase by a given value,
"-" should make the distance decrease.
(You could also add "++" and "--" for double-steps etc.)

The dialog menu should stay open until the user deliberately closes it,
so that the user can add as many plus and/or minus can be added as he/she wishes.

Unfortunately, this seems to be beyond my scripting skills.
Does any of you maybe have an idea of how to do this?

You can find the scripts below.

//by djphil, 01/14/2020

default
{
    state_entry()
    {
        vector size = llGetScale();
        float distance = 1.0;
        integer i;
        integer n = llGetNumberOfPrims();
        for (i = 1; i < n; ++i)
            llSetLinkPrimitiveParamsFast(i + 1, [PRIM_POS_LOCAL, <0.0, i * (size.y + distance), 0.0>]);
    }
}

The dialog could start like this:

key user;

default
{
touch_start(integer num)
{
user = llDetectedKey(0);
llDialog(user , "Add as much distance between the prims as you like:" , ["+" , "-" ] , 0);
llListen(0, "", user, "");
}
    listen(integer chan, string name, key id, string msg)
    {
        if (msg == "+")
		...

	if (msg == "-")
		...
}

Thank you very much in advance.

Link to comment
Share on other sites

hi hi Test,

please give this script a try



float default_distance = 0.5;


key user;
float distance;
integer listenhandle;
setdistance()
{
    llOwnerSay("disctance set to: "+(string)distance);
    vector size = llGetScale();
    integer i;
    integer n = llGetNumberOfPrims();
    for (i = 1; i < n; ++i)
    {
        llSetLinkPrimitiveParamsFast(i + 1, [PRIM_POS_LOCAL, <0.0, i * (size.y + distance), 0.0>]);
    }
}

dialog(key us)
{
    llDialog(user , "Add as much distance between the prims as you like:" , ["- 0.1","- 0.5","- 1.0","+ 0.1" ,"+ 0.5","+ 1.0","Reset","Cancel"] , -12345);
}

default
{
    state_entry()
    {
        distance = default_distance;
    }
    touch_start(integer num)
    {
        user = llDetectedKey(0);
        dialog(user);
        listenhandle = llListen(-12345, "", user, "");
        llSetTimerEvent(30);
    }
    listen(integer chan, string name, key id, string msg)
    {
        llSetTimerEvent(30);
        if(llGetSubString(msg,0,0)=="-")
        {
            distance = distance - (float)llGetSubString(msg,2,4);
            setdistance();
            dialog(user);
        }
        else if(llGetSubString(msg,0,0)=="+")
        {
            distance = distance + (float)llGetSubString(msg,2,4);
            setdistance();
            dialog(user);
        }
        if (msg == "Reset")
        {
            distance = default_distance;
            setdistance();
        }
    }
    timer()
    {
        llListenRemove(listenhandle);
    }
}

enjoy and regards

Dargo

  • Like 2
Link to comment
Share on other sites

That's great! Thank you, Dargo.

I've experimented a bit, and what I think I need to change to make an even smaller gap possible is ... say 0.01, is to change (float)llGetSubString(msg,2,4); to

(float)llGetSubString(msg,2,5);

Is that right?

Emma :) 

 

 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1554 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...