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);
}
}