Jump to content

How do I teleport someone AFTER they answer a question?


firegrove
 Share

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

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

Recommended Posts

I am trying to ask students a question and then teleport them if they get the answer correct (and only give feedback if they get the answer wrong). I have tried playing with the location of llMapDestination, but the script won't pause for the user input. Depending where I put the llMapDestination, it either runs automatically or won't run at all. I'm hoping someone can give me a little guidance on how to make this work. THANKS!

 

// this code is for the teleporting doors after the students answers the question correctly

integer gListener;

vector Room1 = <70, 60, 441>;

vector Room2 = <88, 59, 441>;

vector Room3 = <105, 60, 441>;

vector Room4 = <105, 43, 441>;

vector Room5 = <88, 43, 441>;

vector Room6 = <71, 43, 441>;

vector Room7 = <71, 27, 441>;

vector Room8 = <88, 27, 441>;

vector Room9 = <104, 27, 441>;

string simName = "TejanoTech";

vector tpDest = Room2;

vector lookAt = ZERO_VECTOR;

 

// I tried putting this in a callable function to place it in the listen function but then it will not run

//teleporting () {

//   llMapDestination(simName, tpDest, lookAt);

// }

 

default

{

 state_entry()

    {

        llSetText("Sample Question #1.", <1.0, 1.0, 1.0>, (float)TRUE);

    }

 

    touch_start(integer total_number)

    {

        integer channel = -13572468;

       

        gListener = llListen( channel, "", "", "");    

        llTextBox(llDetectedKey(0), "What color is the sky?\na. blue\nb. green\nc. brown.\nPlease enter ONLY the letter of the correct answer.", channel);

        llSetTimerEvent(60.0); // I tried this timer after seeing this in another script but it had no effect

// when I put it here, the teleport runs regardless of user input 

llMapDestination(simName, tpDest, lookAt);

    }

 

    listen(integer channel, string name, key id, string message)

    {

        if (message=="a"){

            llSay(0, "You are correct, the sky is blue.");

// teleporting(); // If I try to place the llMapDestination here, it doesn't run regardless of user input

            llSetTimerEvent(0.1);

        } else {

            llSay(0, "Sorry, that's incorrect. The sky is blue.");

            llSetTimerEvent(0.1);

        }

        llListenRemove(gListener);

    }

   

    timer()

    {

        llListenRemove(gListener);

        llSetTimerEvent(0);

    }

}

Link to comment
Share on other sites

At quick glance, your teleport function is always going to try to teleport people to the same destination, Room 2, but it will fail because you have defined 

vector tpDest = Room2;

in your block of global variables, where you are not allowed to do that. You have to give tpDest a value in the main body of your script, presumably right where you are about to need it for teleporting a student.  That value will have to change depending on the student's answer, of course.

As you are using it, the timer event is simply killing the listener after 60 seconds.  That's fine, just in case the student doesn't respond at all within a minute of clicking on the object.  Having done that, you don't need to also put

llListenRemove(gListener);

in the listen event, since you have llSetTimerEvent(0.1) statements there that achieve the same goal.

Link to comment
Share on other sites

Actually, you can declare a global variable as another global variable provided you do so in the right order:

vector Room2 = <88, 59, 441>;
vector tpDest = Room2;

works – tpDest is assigned the value of Room2, while:

vector tpDest = Room2;
vector Room2 = <88, 59, 441>;

doesn't – it throws a "Name not defined within scope" compiler error.

Link to comment
Share on other sites

vector tpDest is equal to Room 2 because this is a generic script for about 18 doors (notice that I don't have any of the other room/location vectors used through the rest of the script). By declaring Room# vectors and then assigning a vector for the room I am actually using this script for, it allows me to easily and quickly change the script for numerous doors. Everything for that works fine. The problem is that it doesn't wait for the student/user to answer the question before it asks them if they want to teleport. That is the delay that I'm looking for. Thanks for the input, though!

Link to comment
Share on other sites

12 minutes ago, firegrove said:

vector tpDest is equal to Room 2 because this is a generic script for about 18 doors (notice that I don't have any of the other room/location vectors used through the rest of the script). By declaring Room# vectors and then assigning a vector for the room I am actually using this script for, it allows me to easily and quickly change the script for numerous doors. Everything for that works fine. The problem is that it doesn't wait for the student/user to answer the question before it asks them if they want to teleport. That is the delay that I'm looking for. Thanks for the input, though!

From the wiki: https://wiki.secondlife.com/wiki/LlMapDestination

Quote

Only works for scripts attached to avatar, or during touch events.

 

15 minutes ago, firegrove said:

That is the delay that I'm looking for.

If this is all in the same region, at the same height, I would consider using SitTeleporters. That is you sit on an object (click action sit) and the object moves with llSetRegionPos and does an llUnSit(key) operation.
If question is correct, rez/activate a sign infront of them which is the SitTP object.

Link to comment
Share on other sites

1 hour ago, arton Rotaru said:

I would consider using SitTeleporters.

I'm rather partial to slurls as a solution to the "Teleportation is weird and deals with permissions" problem. for example

llRegionSayTo(id,0,"[secondlife:///app/teleport/"+llGetRegionName()+"/"+(string)destination.x+"/"+destination.y+"/"+destination.z+" right click-> 'run this command' to teleport to destination.]");

 

  • Like 2
Link to comment
Share on other sites

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