Change font size
It is currently Fri Jul 19, 2019 3:32 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 6 posts ]
Author Message
 Post subject: teleporter using sensor
PostPosted: Sat May 18, 2019 3:59 pm 
Furious Typer

Joined: Mon Feb 13, 2017 1:53 pm
Posts: 65
Hi again!
I'm trying to build a teleporter that is supposed to teleport the users from one task to the next.
As far as I know, teleporting only works using vectors.
However, I would like the teleporter to use the names of objects, for example as follows:

From an object/prim called "task 1" you teleport to an object called "task 2", from there to "task 3" and so on.

This would make it possible to rearrange the "task"-objects/prims to a different position
without having to adjust the vector coordinates in each script every time.

I've made a script using the llMoveToTarget function, which works.
However, this is a bit less convenient than an actual teleporter
since it is more time-consuming to use and also a little distracting.
I'm posting it below.

What I would like to have is a teleporter that, similar to the script below,
uses a sensor function to "find" the next task-prim.
Then, it is supposed to find out the position of that prim.
Next, it should turn the position into a vector
and teleport the avatar to that position.

Here is my llMoveToTarget-version of that script:
{L_CODE}:
vector sit_position = <0.0, 0.0, 0.5>;
vector sit_rotation = <0.0, 0.0, 0.0>;

default
{
state_entry()
{
llSitTarget(sit_position, llEuler2Rot(sit_rotation * DEG_TO_RAD));
}

changed(integer change)
{
if (change & CHANGED_LINK)
{

state sensing;
}
}
}

state sensing
{
    state_entry()
    {
        llSetStatus(STATUS_PHYSICS, TRUE);
        llSensor ("task2","",PASSIVE,96.0,PI);
        }

sensor(integer num)
{
   vector iTarget = llDetectedPos(0); 
   key user = llAvatarOnSitTarget();
   llRotLookAt( llRotBetween( <0.5,0.0,0.0>, llVecNorm( iTarget - llGetPos() ) ), 0.1, 0.4 );
   llMoveToTarget(iTarget,0.4);
   
   llSetTimerEvent(10);
    }
   
    timer()
    {
     llDie();
      }
}


Is it possible to achieve this using an actual teleport function?
Thanks!


Top
 Profile  
 
 Post subject: Re: teleporter using sensor
PostPosted: Sat May 18, 2019 5:44 pm 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 220
Location: Belgium / Brussels
This script looks for the named targets #0, #1, #2, #3, ... :)
{L_CODE}:
// Target Sensor Teleporter v0.1 by djphil (CC-BY-NC-SA 4.0)

key user;
integer counter;

default
{
    state_entry()
    {
        llOwnerSay("Initialisation ...");
    }

    touch_start(integer number)
    {
        user = llDetectedKey(0);
        llSensor("#" + counter, "", PASSIVE, 96.0, PI);
        llSetText("#" + counter, <1.0, 1.0, 1.0>, 1.0);
    }

    sensor(integer number)
    {
        ++counter;
        vector det_pos = llDetectedPos(0);
        rotation det_rot = llDetectedRot(0);
        osSetPrimitiveParams(llGetKey(), [
            PRIM_POSITION, det_pos,
            PRIM_ROTATION, det_rot
        ]);
        osTeleportAgent(user, det_pos, ZERO_VECTOR);
    }

    no_sensor()
    {
        counter = 0;
        llSensor("#" + counter, "", PASSIVE, 96.0, PI);
        llSetText("#" + counter, <1.0, 1.0, 1.0>, 1.0);
    }
}

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Last edited by dj phil on Sun May 19, 2019 5:06 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: teleporter using sensor
PostPosted: Sun May 19, 2019 8:26 am 
Furious Typer

Joined: Mon Feb 13, 2017 1:53 pm
Posts: 65
Hi again!
Thank you so much for your help!
I got it to work.
This is going to save me a lot of work. :-)

I guess you did more than what I originally needed.

Originally I only needed a teleporter that teleports to one specific prim,
which in turn then is itself another teleporter.
And this teleporter teleports to the next teleporter and so on.
Your script teleports to all numbered prims in a sequence,
which opens up many more opportunities.

I just simplified it a little bit for my particular needs.
I simply took out the counter and added the respective number to the "#"
("#1" connecting to prim "#1" and "#2" connecting to the next and so on),
so that each teleporter now only teleports to one specific prim.
I also left out the osTeleportObject, because that seemed to get stuck sometimes.

I hope this makes some sense.
It seems to work anyway.

I'm posting it below for other users possibly interested in this.

Thank you very much for your help.
I tried all afternoon yesterday and couldn't do it.
Thanks again! :-)

This teleporter teleports to a prim called: "#1"
(hint for other newbies like me:
In the llSensor-section, it says PASSIVE.
This means it teleports to a prim that does not contain scripts.
If it is supposed to teleport to an object containing scripts,
then it must say SCRIPTED instead of PASSIVE in that section.)
{L_CODE}:
// Target Sensor Teleporter v0.1 by djphil (CC-BY-NC-SA 4.0)

key user;

default
{
    state_entry()
    {
        llOwnerSay("Initialisation ...");
    }

    touch_start(integer number)
    {
        user = llDetectedKey(0);
        llSensor("#1", "", PASSIVE, 96.0, PI);
        llSetText("#1", <1.0, 1.0, 1.0>, 1.0);
    }

    sensor(integer number)
    {
        vector det_pos = llDetectedPos(0);
        rotation det_rot = llDetectedRot(0);
        //osTeleportObject(llGetKey(), det_pos, det_rot, OSTPOBJ_NONE);
        osTeleportAgent(user, det_pos, ZERO_VECTOR);
    }

    no_sensor()
    {
        llSensor("#1", "", PASSIVE, 96.0, PI);
        llSetText("#1", <1.0, 1.0, 1.0>, 1.0);
    }
}


Top
 Profile  
 
 Post subject: Re: teleporter using sensor
PostPosted: Sun May 19, 2019 8:44 am 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 220
Location: Belgium / Brussels
osTeleportObject sometimes fails if you click too fast to teleport.
Do not forget that osTeleportAgent has a delay of 0.5 sec.
You can easily work around this little problem by delaying.

I opted for a simple version with only one script.
You now have a functional example, made you happy.

To replace the sensor, which is limited to 96.0 meters, you could use a target uuid's list.
In this way, you can detect the position of your targets on the var region where the distances are larger.

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Top
 Profile  
 
 Post subject: Re: teleporter using sensor
PostPosted: Sun May 19, 2019 10:59 am 
Furious Typer

Joined: Mon Feb 13, 2017 1:53 pm
Posts: 65
Thanks for the tip.
Good idea, because that's the one weakness that this teleporter has.
I might try that soon.
Cheers!


Top
 Profile  
 
 Post subject: Re: teleporter using sensor
PostPosted: Sun May 19, 2019 5:09 pm 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 220
Location: Belgium / Brussels
I modified the script slightly to eliminate the TP problem of the object.
(That sometimes failed with osTeleportObject).

Now it should work better ... :)

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 6 posts ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net