Jump to content

Best event for llRequestPermissions on attachment


FlaviaAlmeidah
 Share

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

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

Recommended Posts

attach is triggered:
attach from ground, attach from inventory, login, detach

on_rez is triggered:
attach from inventory, login

So both are good in this case.

One detail:

integer perm = llGetPermissions();
if (perm & PERMISSION_TRIGGER_ANIMATION) <you already have that permission>

 

Edited by Nova Convair
  • Like 2
Link to comment
Share on other sites

1 hour ago, Nova Convair said:

attach is triggered:
attach from ground, attach from inventory, login, detach

on_rez is triggered:
attach from inventory, login

So both are good in this case.

on_rez is triggered whenever the object is rezzed in any way. While this includes attachment and "login", it also happens whenever the object is rezzed onto the ground.

You should use the event that makes the most logical sense, so on_rez may not be needed unless you want the object to do something regardless of whether it's attached or not. Scripts don't lose permissions when detached anyway, so you should not need to request permission at every opportunity (in theory).

45 minutes ago, Xiija said:

on_rez, if triggered might eat the attach event, so you won't get when the object is attached, just it's detach.

This will never happen. Both events -- on_rez and attach -- will trigger when the object is attached. If it were any other way, the attach event would be useless and most content would not work the way they do right now.

Edited by Wulfie Reanimator
  • Like 2
Link to comment
Share on other sites

Use the attach event.  If the key returned by the event isn't null key, it's freshly attached, and null key means it's detached.  I know of no instances where on_rez prevents the attach event from being triggered.

Using on_rez for the purposes you've stated above is a waste of events being triggered and more of a burden on the region than doing it properly with just attach

 

    attach(key av) {
		if (av) {
			//	Something is attached
		} else {
			//	Something was detached
		}
	}

 

  • Like 1
Link to comment
Share on other sites

Using the attach event is usually the way to go, but not always. It depends.

If I need an on_rez for other things in the script, I might as well include an if(llGetAttached())llRequestPermissions in there. That'll save me an extra and unnecessary attach event. But then you have to be mindful that attaching from the ground is not triggered. Then again, attaching from the ground is pretty rare. Most people aren't even aware they can do that.

Edited by Arduenn Schwartzman
Link to comment
Share on other sites

1 hour ago, Arduenn Schwartzman said:

But then you have to be mindful that attaching from the ground is not triggered.

What isn't triggered?

I see attach() triggered with attaches from ground, attaches from user inventory, detaches to user inventory and drops to ground.

Edited by Lucia Nightfire
Link to comment
Share on other sites

I took Arduenn to be discussing using on_rez() in place of attach(), and in that case ("But then...") there wouldn't be an on_rez() event triggered when attaching an item that's already rezzed out on the ground.

It's an open question in my mind whether it saves to add attachment-detection logic to a pre-existing on_rez() handler, compared to adding an attach() event handler. A theory I'm too lazy to test is that there's a bit more memory used by the separate handler -- either way needs the llGetAttached() conditional -- but there may be a tiny speed advantage for those on_rez events that do not accompany attachment and therefore didn't need to evaluate that conditional.

(Separately, the idea that on_rez might "eat" the attach event is new to me.)

Link to comment
Share on other sites

2 hours ago, Qie Niangao said:

whether it saves to add attachment-detection logic to a pre-existing on_rez() handler

I vaguely remember every extra event costs relatively more memory than a conditional thingy inside an event. Memory usage has been my biggest obstacle over the past years, so I've always been looking for ways to reduce them. States are another memory hog.

Edited by Arduenn Schwartzman
Link to comment
Share on other sites

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