LissomePrey Posted April 7, 2022 Share Posted April 7, 2022 (edited) I help run a group/sim where we have chairs set up in an open area for people to sit and chat. Ideally we would let people move the chairs about into circles, groups etc but the admins think the work of tidying up and getting the chairs back in place is too onerous. I am trying to develop a script that will return the chairs to their correct place, either if they are moved too far or at midnight each day. Basically it is a simple flat surface that remembers its co-ordinates and rotation when I say 'FIX' in local (it then kills the listener so that location is permanently fixed). I then need to link it with the chair, which is bought off marketplace and so non-modifiable. The chair will have a menu on touch which seems to mean that the chair must be the root prim, with my surface as a child prim. It works perfectly for resetting the co-ordinates of the chair but it doesn't get the correct rotation for the chair itself. The child prim is rotated correctly by llSetRot but not the chair. Is there a way to force rotation of the root prim to match that of the child prim, given that I can't do any scripting for the root prim? It isn't a vital element but I'd love to be able to do it perfectly. Edited April 7, 2022 by LissomePrey incorrect function quoted Link to comment Share on other sites More sharing options...
Jenna Huntsman Posted April 7, 2022 Share Posted April 7, 2022 21 minutes ago, LissomePrey said: non-modifiable Any idea is DOA because of this. You'd be better off contacting the creator of the chair, or replacing them with mod-enabled furniture. 1 Link to comment Share on other sites More sharing options...
LissomePrey Posted April 7, 2022 Author Share Posted April 7, 2022 It actually does work fine apart from the rotation but maybe my explanation is poor. I fix the correct location in my prim before linking with the chair as the root prim. If the chair was the child prim returning it to the correct position and rotation worked perfectly but I couldn't get at the chair menu. So I make the chair the root prim. My prim then has this timer event timer() { float newClock = llGetWallclock(); if (newClock < savedClock) { savedClock = newClock+50.0; llSetRegionPos(position); llSetRot(rot); } else { current_position = llGetPos(); float distance = llSqrt(llPow((position.x-current_position.x),2.0)+llPow((position.y-current_position.y),2.0)+llPow((position.z-current_position.z),2.0)); if (distance > 20.0) { llSetRegionPos(position); llSetRot(rot); } } } The llSetRegionPos works fine, moving my prim and the chair to the correct co-ordinates. The llSetRot only rotates the child prom not the chair. That can be lived with (I'll just remove the llSetRot entirely) but I'd love to get it to work perfectly if there is a way to rotate both prims. Link to comment Share on other sites More sharing options...
Jenna Huntsman Posted April 7, 2022 Share Posted April 7, 2022 (edited) You might be able to use llSetLinkPrimitiveParamsFast with LINK_ROOT to set the root prim's rotation (and position for that matter). Also: You may want to consider using llVecDist for getting the distance the chair has moved, just so clean up the code a bit. Example: llSetLinkPrimitiveParamsFast(LINK_ROOT,[PRIM_POSITION,position,PRIM_ROTATION,rot]); Edited April 7, 2022 by Jenna Huntsman Link to comment Share on other sites More sharing options...
Emma Krokus Posted April 7, 2022 Share Posted April 7, 2022 It looks as though the chair is modifiable... as you are able to link it with the root prim?? Maybe I am missing something. If they are mod, then I would just have them delete themselves at midnight each day and rez a fresh set? 1 Link to comment Share on other sites More sharing options...
Rolig Loon Posted April 7, 2022 Share Posted April 7, 2022 1 hour ago, Emma Krokus said: It looks as though the chair is modifiable... as you are able to link it with the root prim?? Maybe I am missing something. If they are mod, then I would just have them delete themselves at midnight each day and rez a fresh set? That would certainly be the simplest solution. It beats going to all the trouble of moving and rotating all the chairs. Link to comment Share on other sites More sharing options...
Quistess Alpha Posted April 7, 2022 Share Posted April 7, 2022 (edited) many items which are "no-mod" as shown in your inventory are actually modifiable, but show as no-mod because only a part of them (a specific script in its inventory for example) is no-mod. 7 hours ago, LissomePrey said: llSetRot only rotates the child prom not the chair. use llSetLinkPrimitiveParams(1,[PRIM_ROTATION,rot]); instead. 7 hours ago, LissomePrey said: float distance = llSqrt(llPow((position.x-current_position.x),2.0)+llPow((position.y-current_position.y),2.0)+llPow((position.z-current_position.z),2.0)); if (distance > 20.0) use diff = position.x-current_position.x; float distance_squared = diff*diff; if(distance_squared>400.0) { // ... } instead. Edited April 7, 2022 by Quistess Alpha minor correction and made variable names more consistant with OP. 1 Link to comment Share on other sites More sharing options...
LissomePrey Posted April 7, 2022 Author Share Posted April 7, 2022 Thanks to all It seems one particular chair doesn't react when I drop the script (I'll investigate further) in but I've now tried with another model and it works so I can scrap the child prim in that case. I think I will still keep the child prim handy incorporating the suggested mods. Link to comment Share on other sites More sharing options...
Mollymews Posted April 7, 2022 Share Posted April 7, 2022 when the chairs are mod then another way is to drop our script into the root prim of the chair(s) script listens for two commands: SAVE and RESTORE SAVE - the current position and rotation of the chair RESTORE - place the chair at the saved position and rotation owner can shout these commands on a channel. Chair script(s) obeys automagically can be, a independent controller shouts (region say) RESTORE, when none of the chairs in the controller group are being sat on Link to comment Share on other sites More sharing options...
LissomePrey Posted April 8, 2022 Author Share Posted April 8, 2022 One additional comment: llSetLinkPrimitiveParamsFast(LINK_SET,[PRIM_POSITION,position,PRIM_ROTATION,rot]); seems to be the same as llSetPos and restricted to how far it can move the object so I have to go back to llRegionPos. Link to comment Share on other sites More sharing options...
Recommended Posts
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