Jump to content

Link position


arisaie
 Share

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

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

Recommended Posts

I have some issues trying to figure out how to use llSetLinkPrimitiveParamsFast([PRIM_POSITION]) with an attachment linkset.

I want to be able to move opposing objects(links) in opposing directions with a HUD. -> <- Button makes the links come together, <- -> button separates the link objects. 

I have been testing it on cubes (2 - 1 - 3 link numbers --1 being the root prim).  With 1 instead 0.01 so I can see it better.

I have managed to make it change position, but it only happens once with each command.

 

integer dChannel = 0;

default
{
    state_entry()
    {
        
        integer lHandle = llListen(0, "", "", "");
    }
    
    listen(integer channel, string name, key id, string message)
    
    {
        vector offset = <0.0, 1, 0.0>;
        vector localpos = llGetLocalPos();
        vector moved = llGetPos() - offset;
        vector movedc = localpos + offset;
        
    if (message == "l")
    
    {
        llSetLinkPrimitiveParamsFast(2, [PRIM_POSITION, offset]);
    }
    
     if (message == "c")
    
    {
        llSetLinkPrimitiveParamsFast(2, [PRIM_POSITION, - offset]);
    }
}
}
 

If I  type "l" it does move, but only once.  For my attachment link set, i want to be able to adjust the position multiple times. So if I press <- -> 3 times on my HUD, the links 2 and 3 will go into separate directions 3 times by 0.01 (in script it is 1 so I can see it better)

if I type "l" it moves on Y axis, but only once, any subsequent "l" command wont move it. Only typing "c" it will move it back.

I have tried llGetLocalPos(), llGetPos(), PRIM_POS_LOCAL, PRIM_POSITION, some of which do not move the prims at all,  but I can not figure it out.

If i set the link number to 1, it moves repeatedly by each command.

Any idea what I am missing?

 

Thank you!

Link to comment
Share on other sites

2 hours ago, Love Zhaoying said:

This is because you're never changing "offset"; its not a position relative to the current link position. It's an position relative to the root (?) or something. So, you'd have to change the value each call.

Changing. Value each call? 

 

 

Shouldn't the  llGetLocalPos() + my offset fix that? 

You moved it once, the local position changaed, so the next command should move it again?   But it doesn't.

 

If I use ..primparmasfast on link 1 (root) it works intended as I want it to. Each click makgea the whole linkset move in desired location

So I'm at loss why it doesn't work the same on links above 1

 

 

,

 

 

 

 

 

 

 

 

Link to comment
Share on other sites

Nope! I'm bad at explaining this one, so hopefully someone else will chime in with a better, more clear answer for you.

Hint: You're calling it "offset", but you're not adding it or subtracting it from a position. You're just "setting" the value.

Edited by Love Zhaoying
Link to comment
Share on other sites

21 minutes ago, arisaie said:

Shouldn't the  llGetLocalPos() + my offset fix that? 

It would only have an influence if you actually plugged that into the llSetLinkPrimitiveParamsFast command. In the code above, only your unmodified offset is passed as an argument.

Also, you need the local position of the actual prim you're moving, not the local position of the prim the script is running in.

ETA: because I was bored:

open(float amount)
{   vector posA = llList2Vector(llGetLinkPrimitiveParams(2,[PRIM_POS_LOCAL]),0); // local posiiton of prim A.
    vector posB = llList2Vector(llGetLinkPrimitiveParams(3,[PRIM_POS_LOCAL]),0); // local position of prim B.
    posA.y+=amount;
    posB.y-=amount;
    llSetLinkPrimitiveParamsFast(2,[PRIM_POS_LOCAL,posA,PRIM_LINK_TARGET,3,PRIM_POS_LOCAL,posB]);
}

or so works.

Edited by Quistess Alpha
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

31 minutes ago, arisaie said:

TIL about PRIM_LINK_TARGET.

Thinking about it in the abstract made me wonder if it works in llGetLinkPrimitiveParams, and apparently it does!

    list l = llGetLinkPrimitiveParams(2,[PRIM_POS_LOCAL,PRIM_LINK_TARGET,3,PRIM_POS_LOCAL]);
    vector posA = llList2Vector(l,0); // local posiiton of link 2.
    vector posB = llList2Vector(l,1); // local position of link 3.
  • Like 2
Link to comment
Share on other sites

From my noob testing I noticed that if I replace multiple singular lines of llSetLinkParams Into 1 with Prim link target, it's increases the remaining free memory.

I have one more question regarding scripts in general if you don't mind.

Should I aim to compile my scrips with lsl2 I stead of mono if possible? I tried switching script from Mono to lsl2 and the difference was that lsl2 cript used

 0.0005something of memory. Mono used 0.007 something. I'd guess that less is better regarding SIM resources.

 

1 more question..should I generally use llSetMemoryLimit  if my script is done? And set it to a value around my current memory usage? Does a ascript with no memory limit use all its available resources?

 

 

Link to comment
Share on other sites

59 minutes ago, arisaie said:

Should I aim to compile my scrips with lsl2 I stead of mono if possible? I tried switching script from Mono to lsl2 and the difference was that lsl2 cript used

 0.0005something of memory. Mono used 0.007 something. I'd guess that less is better regarding SIM resources.

 

1 more question..should I generally use llSetMemoryLimit  if my script is done? And set it to a value around my current memory usage? Does a ascript with no memory limit use all its available resources?

Use mono, always, for everything. lsl2 is old and bad and LL are considering discontinuing it eventually(^tm).

llSetMemoryLimit makes your script look better to certain script detectors, but does nothing to actually decrease resource usage, except crash your script if it does use more than the limit you set of memory. If your system has more than one script, llSetScriptState("Other_script",FALSE); can potentially be nice though.

  • Like 2
Link to comment
Share on other sites

8 hours ago, arisaie said:

Does a ascript with no memory limit use all its available resources?

Just to amplify what @Quistess Alpha already said: An old LSL2 script will always use 16 KB of memory, whether it needs it or not. In contrast, a Mono script will only use the amount of memory it needs (which may be substantially less than 16K for a simple script), which the script itself can measure internally (llGetUsedMemory) but will appear externally to be 64K unless it uses llSetMemoryLimit on itself—which may actually increase the amount of memory the script uses by enough to execute that function call.

  • Like 2
Link to comment
Share on other sites

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