help with script please
|
|
Boris Eebus
Registered User
Join date: 8 Feb 2008
Posts: 45
|
05-17-2008 10:26
I found this script but I want to amend it so that when the object is rezzed it attaches to the avatars LHAND, how do I amend it to do this? I've tried altering the llGetOwner but it is used later - and its given me a headache after staring at it for the last few hours! default { state_entry() { llSetTimerEvent(.1); //llRequestPermissions( llGetOwner(), PERMISSION_ATTACH ); } timer() { llSetText ((string)llGetPos(), <1.0, 1.0, 1.0>, 1.0); llAttachToAvatar( ATTACH_LHAND ); } on_rez(integer rez) { if(!llGetAttached()) { //reset the script if it's not attached. llResetScript(); } } attach(key AvatarKey) { if(AvatarKey) {//event is called on both attach and detach, but Key is only valid on attach integer test = llGetAttached(); if (test) { llOwnerSay( "The object is attached" ); } else { llOwnerSay( "The object is not attached"  ; //llDie(); } } } }
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-17-2008 10:48
You've commented out where you request attach permissions. You MUST have the PERMISSION_ATTACH permissions to use llAttachToAvatar() and llDetachFromAvatar(). It would also be good form to wait for the permission to be granted instead of using a timer. You might well get a bunch of script errors if you try to attach without the permission. Try something more like: default { state_entry() { llRequestPermissions(llGetOwner(), PERMISSION_ATTACH); }
changed(integer changes) { if (changes & CHANGED_OWNER) { llRequestPermissions(llGetOwner(), PERMISSION_ATTACH); } }
on_rez(integer startParam) { if ((llGetPermissionsKey() != llGetOwner()) || !(llGetPermissions() & PERMISSION_ATTACH)) { llRequestPermissions(llGetOwner(), PERMISSION_ATTACH); return; }
if (!llGetAttached()) { llAttachToAvatar(ATTACH_LHAND); } }
run_time_permissions(integer perms) { if (!llGetAttached() && (perms & PERMISSION_ATTACH)) { llAttachToAvatar(ATTACH_LHAND); } } }
|
|
Boris Eebus
Registered User
Join date: 8 Feb 2008
Posts: 45
|
05-17-2008 11:20
That works with the avatar who created it but not anyone else
It comes up with this error
prism_measure22: Unable to find specified agent to request permissions.
how do i make it that any avatar can use it - so that when it is rezzed it asks the avatar which touched it weather or not to attach
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-17-2008 12:52
You cannot attach to the avatar of a resident who does not own the object. You'll have to give them a copy.
|
|
Boris Eebus
Registered User
Join date: 8 Feb 2008
Posts: 45
|
05-17-2008 13:35
ah ok, so how would I give this object to the visitor and then ask them if they want to attach the object?
Thank you I really appreciate your help
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-17-2008 17:20
llGiveInventory() and maybe llInstantMessage()
|
|
Boris Eebus
Registered User
Join date: 8 Feb 2008
Posts: 45
|
05-19-2008 11:13
ok so i've got this script, how do i amend this to giv an object name prism???
default { touch_start(integer n) { //Gives this script to whoever touches the object. llGiveInventory(llDetectedKey(0), llGetScriptName()); } }
|
|
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
|
05-19-2008 11:39
I'll let Hewee answer your question but I do have a slightly off-topic comment.. state_entry { llSetTimerEvent(.1); } timer() { llSetText ((string)llGetPos(), <1.0, 1.0, 1.0>, 1.0); }
Please, please, please don't do this. There's really no reason to pound on llSetText like this. Setting the text used to (and may still) cause a full object update, which is expensive. At the _very_ least, remember the last position you set the text to and only change it if the position has actually changed.
[/quote]
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!! - Go here: http://jira.secondlife.com/browse/SVC-1224- 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
|
|
Keira Wells
Blender Sculptor
Join date: 16 Mar 2008
Posts: 2,371
|
05-19-2008 11:43
From: Meade Paravane Please, please, please don't do this. There's really no reason to pound on llSetText like this. Setting the text used to (and may still) cause a full object update, which is expensive. At the _very_ least, remember the last position you set the text to and only change it if the position has actually changed.
If you want it to auto-update the llSetText to reflect it's new position, take a look at the moving_start and moving_end events. That way you're not constantly pinging an object update, and should be able to keep it down to just when it's moving.
_____________________
Tutorials for Sculpties using Blender! Http://www.youtube.com/user/BlenderSL
|
|
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
|
05-19-2008 11:58
in H4, moving_start and moving_end are no longer reliable event triggers.
However, a llSetTimerEvent(.5) is probably more than adequate (twice per second) and is 1/5 as hard on the sim/people. Most radar huds I've seem, have a _5_ second ping timer...
and a quick:
if (llGetPos() != lastPos) {lastPos = llGetPos(); llSetText((string)lastPos, <1.0, 1.0, 1.0>, 1.0); }
WILL save everyone a little bit of strain.
_____________________
 ● Inworld Store: http://slurl.eclectic-randomness.com ● Website: http://www.eclectic-randomness.com ● Twitter: @WinterVentura
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-19-2008 12:07
From: Boris Eebus ok so i've got this script, how do i amend this to giv an object name prism??? Oh, and since this has not been answered yet, you'd simply replace the call to llGetScriptName() with the name of the object to give. Assuming you literally meant that the object's name is "prism" in your giver object's inventory: default { touch_start(integer n) { // Gives object named "prism" from this prim's inventory to one person at a time who touches the object. llGiveInventory(llDetectedKey(0), "prism"); } }
|