Jump to content

there any way to insert a variable inside a vector ?


LeoNaRdO31231
 Share

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

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

Recommended Posts

So i need to set two number of a vector using two float variables 

the problem if i just put the variable the vector will not just accept i need a way to set them as the variable as i will need to change it later on the code so i cant just put the number inside 

Ex. Code with the error:

float x1 = 0.075;
float y1 = 0.95;

vector cut = <0.0, 0.0, 0.0>;

// after that i try two things but no one of them work

cut.x = x1;

cut.y = y1;

cut = <x1, y1, 0.0>;

// none of them work, as far i know can be a simple mistake i made but i need help, and if anyone can give me a tip or a fix i will be more than glad to receive it

Link to comment
Share on other sites

 default
{
    state_entry()
    {
        float x1 = 0.075;
        float y1 = 0.95;
        vector cut = <0.0, 0.0, 0.0>;

        
        cut.x = x1;
        
        cut.y = y1;
        
        llOwnerSay((string)cut);
        
        //swapped around so output changes
        cut = <y1, x1, 0.0>;
        
        llOwnerSay((string)cut);
        
    }
}

Produces

[12:34] Object: <0.07500, 0.95000, 0.00000>
[12:34] Object: <0.95000, 0.07500, 0.00000>

I suspect you have a different bug / typo !

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

3 hours ago, Coffee Pancake said:
 default
{
    state_entry()
    {
        float x1 = 0.075;
        float y1 = 0.95;
        vector cut = <0.0, 0.0, 0.0>;

        
        cut.x = x1;
        
        cut.y = y1;
        
        llOwnerSay((string)cut);
        
        //swapped around so output changes
        cut = <y1, x1, 0.0>;
        
        llOwnerSay((string)cut);
        
    }
}

Produces

[12:34] Object: <0.07500, 0.95000, 0.00000>
[12:34] Object: <0.95000, 0.07500, 0.00000>

I suspect you have a different bug / typo !

 so i try that and idk why but on my firestorm viewer he aways says its a error on the first line i try to put a variable on any of the vector numbers i will try to update or something idk what is wrong with my viewer 

Link to comment
Share on other sites

27 minutes ago, LeoNaRdO31231 said:

 so i try that and idk why but on my firestorm viewer he aways says its a error on the first line i try to put a variable on any of the vector numbers i will try to update or something idk what is wrong with my viewer 

Could you post your full script here? Scripts aren't compiled by the viewer.

  • Like 1
Link to comment
Share on other sites

 

oh ***** i solve the problem just to get in other 

 

float x = 0.0;
float y = 0.0;
float change = 1.0;

default
{
    state_entry()
    {

        integer i;
        for(i = 0; i <= 500; i++)
        {
            x + change;
            y - change;

            llOwnerSay((string)x);
            llOwnerSay((string)y);
            llSleep(1.0);
        }
        
    }
}

so now i can put a variable on a vector but i cant change the float he just dont change 

Link to comment
Share on other sites

3 hours ago, Wulfie Reanimator said:

Could you post your full script here? Scripts aren't compiled by the viewer.

so fine i will put for you 

default
{
    state_entry()
    {
        
        integer i;
        float change = 0.01;
        float x1 = 0.075;
        float y1 = 0.925;
        vector cut = <0.0, 0.0, 0.0>;
        vector base = <0.0, 0.1, 0.0>;

//      Useless stuff:
        float hollow = 0.0;                
        vector twist = <0.0, 0.0, 0.0>;    
        vector dimple = <0.0, 1.0, 0.0>;  
        
//      Loop for closing the eye
        for(i = 0; i <= 500; i++)
        {


//          string name = llList2String(llGetLinkPrimitiveParams(i, [PRIM_NAME]), 0);
//          Object Show
//          llOwnerSay((string)name);
//          llOwnerSay((string)i);


            cut.x = x1;
            cut.y = y1;
            llSetPrimitiveParams([PRIM_LINK_TARGET, 7, PRIM_TYPE, PRIM_TYPE_SPHERE, PRIM_HOLE_DEFAULT, cut, hollow, twist, dimple ]);
            x1 - change;
            y1 + change;
            llSleep(0.8);
            if (cut == base)
            {
                i = 500;
            }
            llOwnerSay((string)x1);
            llOwnerSay((string)y1);
            llOwnerSay((string)cut);
        }
    }
}

i m making this script for some prim eyes a friend want was to be a simple and easy but it turns into a nightmare 

most of the code is made for test and trying to make  piece by piece work until i have the full code working 

the first problem (already solved) was i cant put a variable inside of a vector 

the second now its i cant change the float so the "for" can make ir close slowly not just by close and open 

 
Link to comment
Share on other sites

3 minutes ago, Mollymews said:

x1 - change;

y1 + change;

probably should be:

x1 -= change;

y1 += change;

 

uff i was thinking about the "=" i m normaly use other languagess and they dont need the = sorry it was like a little thing i dont find on the LSL thanks alot people <3 

  • Like 2
Link to comment
Share on other sites

9 minutes ago, LeoNaRdO31231 said:

uff i was thinking about the "=" i m normaly use other languagess and they dont need the = sorry it was like a little thing i dont find on the LSL thanks alot people ❤️

is all good. Those of us who work with multiple languages have all been down this path. Have done the same myself sometimes

like type up a whole bunch of lines into the LSL code editor then realise is 'integer' not 'int'. LSL doesn't know about for(integer i, ...). Nor does it know that 'begin' 'end' mean open and close braces.  And it goes wut! when type in: try except. That i can't type myHud.ButtonA.Color = clButton.  and on and on

Link to comment
Share on other sites

10 minutes ago, Mollymews said:

is all good. Those of us who work with multiple languages have all been down this path. Have done the same myself sometimes

like type up a whole bunch of lines into the LSL code editor then realise is 'integer' not 'int'. LSL doesn't know about for(integer i, ...). Nor does it know that 'begin' 'end' mean open and close braces.  And it goes wut! when type in: try except. That i can't type myHud.ButtonA.Color = clButton.  and on and on

i feel bad because like i m creating a game on unreal 4 and the difference is like giant

Link to comment
Share on other sites

27 minutes ago, LeoNaRdO31231 said:

i feel bad because like i m creating a game on unreal 4 and the difference is like giant

LSL belongs to the general C language syntax family. There are a few differences from pure C, but belongs in the general family in the same way the Java and javascript do

the more we use a language the easier it becomes. So don't worry too much and keep on as you are doing

Link to comment
Share on other sites

8 minutes ago, Mollymews said:

LSL belongs to the general C language syntax family. There are a few differences from pure C, but belongs in the general family in the same way the Java and javascript do

the more we use a language the easier it becomes. So don't worry too much and keep on as you are doing

thanks and i will 

  • Like 1
Link to comment
Share on other sites

A few points:

  • That loop will take 400 seconds to execute. 0.8 second times 500 iterations.
  • The shortest wait you can do is 1/45 second. That doesn't mean you'll always get control back after the timer runs out. Scripts share a rather limited amount of CPU time server side, and the scheduler will not let you hog that resource.
  • While you can change the parameters of a prim over time, it's slow and high overhead. Each step of the loop transmits an update message across the network.
  • Most eyeblinks in Second Life are done using animations on the eyelid "bones". This is a standard feature of most newer avatars. See https://wiki.secondlife.com/wiki/Project_Bento_Skeleton_Guide. If this is for an existing modern head, there are standard eyeblink animations available. Works great, low overhead, but setting up a new head for it is a big job.
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 839 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...