Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Possible? Script activity based on attachment?

Cheewha Palen
Registered User
Join date: 27 Nov 2007
Posts: 78
05-10-2009 19:55
Is it possible to have a script in an attachment that is off when worn but becomes active when dettached( and of course vis versa)?
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
05-10-2009 19:59
Detached as it just sitting in your inventory and not in-world? Nope - if it ain't in-world, it ain't running.
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!!
- Go here: https://jira.secondlife.com/browse/SVC-3895
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Cheewha Palen
Registered User
Join date: 27 Nov 2007
Posts: 78
05-10-2009 20:09
sorry not dettached in inventory...but dropped in world...that kind of unattached : )
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
05-10-2009 20:42
Sure, assuming it's not on no-script land and all that, as long as it's in-world, it can run.

But it's not really 'running' vs not. A script can tell if it's attached (or not) then do things (or not) based on that.
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!!
- Go here: https://jira.secondlife.com/browse/SVC-3895
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Cheewha Palen
Registered User
Join date: 27 Nov 2007
Posts: 78
05-10-2009 21:18
TY Sindy,

I was looking at the wiki on attachments. I am not sure how that could implemented, any advice?
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
05-10-2009 21:48
I think this is the one you want: http://wiki.secondlife.com/wiki/Attach
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!!
- Go here: https://jira.secondlife.com/browse/SVC-3895
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-10-2009 22:45
CODE

default{
attach( key vKeyWorn ){
if (vKeyWorn){
state sRunning;
}
}
}

state sRunning{
attach( key vKeyWorn ){
if (!(vKeyWorn)){
state default;
}
}
}

I think that'll work...
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Cheewha Palen
Registered User
Join date: 27 Nov 2007
Posts: 78
05-11-2009 01:13
Wow thank you, Sindy.

And thank you as well Void. Thats twice you have pointed me in a good direction. I don't know if you guys ever get any praise for help but I am very grateful!
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-11-2009 02:24
Yw =)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
05-11-2009 05:46
Yer welcome, Cheewha.

Nice snippet, Void. /me nominates it as a wiki sample.
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!!
- Go here: https://jira.secondlife.com/browse/SVC-3895
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-11-2009 09:49
but does it actually work? I haven't tested it yet, and I'm not sure the second half will parse correctly.... it may not obey the conditional rules in that format although you could state it as a basif if with an empty case, then use the else to work around it... kinda hacky, but if the NOT logic fails to parse, it's an option.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
05-11-2009 10:09
Why don't you just call llGetAttached() in the on_rez event?

integer llGetAttached( );

Returns an integer that is the attachment point the object is attached to or zero if not attached.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
05-11-2009 11:50
From: Argent Stonecutter
Why don't you just call llGetAttached() in the on_rez event?

integer llGetAttached( );

Returns an integer that is the attachment point the object is attached to or zero if not attached.


If the owner chooses "Drop" from the pie menu, the object will be detached, but will be sitting in-world without another 'on_rez' event. So merely checking in the 'on_rez' event is not quite sufficient. Also, when the resident attaches the object from inventory OR in-world, 'on_rez' will fire before 'attach' (and I BELIEVE llGetAttached() might return false during that 'on_rez' even if it was from inventory--maybe not or might be a race condition in that case though).

Definitely more correct to put logic in the 'attach' handler for this situation, though it might also be a good idea to set a (short) timer or something on detach ('attach' event with the key parameter being NULL_KEY) and see whether the timer or the 'on_rez' event comes first, which SHOULD be the difference between detach to inventory and drop in-world.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-11-2009 13:00
assuming my above seample fails in the second half (I don't have time to check) th following WILL work...

if (vKeyWorn != llGetOwner()){

reason being is that the key returned by the attach event can only be either the owners key (becuase you must be the owner to attach) or null key...
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Cheewha Palen
Registered User
Join date: 27 Nov 2007
Posts: 78
05-12-2009 20:43
Hi

Sorry for response time, but yes the script works perfect with the last snip void posted. Ty for that! When I drop the build it realigns to the parent prim perfectly. but if I reattach the build it goes back on kinda screwy? I made a sit animation with qavimator so that its lined up forward and straight and I am sitting on the parent prim. Is this just an sl thing?

ty again

cheewha
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-12-2009 21:28
pretty sure if you rotate a dropped attachment that rotation will apply if it's reworn
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -