SL - Forum scripts

Sit on a certain distange /range

Répondre
Partager Rechercher
Hi!

Dutchie here again ^^ i followed some lsl sites to (trying) accomplish let an avatar sit on a object
on an certain range / distance only, all i could find is by 'touch' event and combined this:

default
{
on_rez (integer param)
{
llResetScript ();
}
state_entry ()
{
// nothing
}
touch_start (integer total_number)

{
vector mypos = llGetPos ();
vector yourpos = llList2Vector (llGetObjectDetails (llDetectedKey (0), [OBJECT_POS]), 0);
if ((llAbs ((integer) (yourpos.x-mypos.x))> limit) || (llAbs ((integer) (yourpos.y-mypos.y))> limit) || (llAbs ((integer) (yourpos.z-mypos.z))> limit))
{
// avatar is too far away
llInstantMessage (llDetectedKey (0), "You are too far away. Move closer and touch again.");
}
else
{
// avatar is close enough
llInstantMessage (llDetectedKey (0), "You're close enough, thanks!");
}
}
}

Would be VERY happy if this can be converted to allow an avatar to 'sit' on 10m distance ^
try that one.....


integer limit = 10;
integer autorized;

key id;

default
{
on_rez (integer param)
{
llResetScript();
}

state_entry ()
{
llSetClickAction(CLICK_ACTION_TOUCH);
llSitTarget(<0.0, 0.0, 1.0>, ZERO_ROTATION);
}
touch_start (integer total_number)
{
id = llDetectedKey(0);
vector mypos = llGetPos ();
vector yourpos = llList2Vector (llGetObjectDetails (llDetectedKey (0), [OBJECT_POS]), 0);

if ((llAbs ((integer) (yourpos.x-mypos.x))> limit) || (llAbs ((integer) (yourpos.y-mypos.y))> limit) || (llAbs ((integer) (yourpos.z-mypos.z))> limit))
{
autorized = 0;
llSetClickAction(CLICK_ACTION_TOUCH);
llInstantMessage (id, "You are too far away. Move closer and touch again.");

}
else
{
llSetClickAction(CLICK_ACTION_SIT);
autorized = 1;
llInstantMessage (id, "You're close enough, thanks! click again to sit");
llSetTimerEvent(10.0);
}
}

changed(integer change)
{
if(change & CHANGED_LINK)
{
key Av = llAvatarOnSitTarget();
if(Av == id)
{
if(autorized == 0)
{
llUnSit(Av);
llInstantMessage (Av, "Not allowed to sit");
}
else
{
llSetClickAction(CLICK_ACTION_TOUCH);
}
}
else
{
llUnSit(Av);
llResetScript();
}
}
}

timer()
{
llSetClickAction(CLICK_ACTION_TOUCH);
autorized = 0;
llInstantMessage (id, "Too late, try again");
llSetTimerEvent(0.0);
}
}
Thanks! works sort of ... , it will still teleport the avatar tho to the object when choosing in right menu mouse click with 'Sit Here'
and when being in range and want to sit it says not allowed: P i think the script makes the object a 'touch' object and removes the the 'click to: sit on object' ?!
You should be more accurate with your requests, your first script was uncomplete too....the one I gave you, allows only to sit wen av within 10 meters and during 10 secs.....or you have to check the distance again....if you sit with right click menu, you got "unsit"....
Répondre

Connectés sur ce fil

 
1 connecté (0 membre et 1 invité) Afficher la liste détaillée des connectés