Jump to content
You are about to reply to a thread that has been inactive for 1472 days.

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

Recommended Posts

#LearningLSL

Suppose :

(Both scripts are in single prim)

1. user is in llDialog() menu where she pressed "enter number" button.

2. User entered a number in text box llTextbox(). 

3. Got the messag through listen() and I have to convert as well as check if the given string is integer. To do so, my function is placed in another script within same object.

4. I send message through llMessageLinked containing the entered string and I will send an integer too (that is 1);

5.if the second script's link_message() will recived integer 1 with that message then it will call the function toInteger(message);

6. toInteger() will return 0 if the given string contains anything except numbers, else it will return the converted integer num. It send result through llMessageLinked() back to main script.

7. the link_message() event of main script recieve that integer sent by toInteger().

-----------------------------------------

Now how I should proceed further to get this integer back to where I sent it first time through llMessageLinked() in another script to get converted(referring to step 4) . If it is not integer then I wanna pop up llDialog() again which say "Enter Again". my all llDialog() menus are in one script and all functions are in another.

(Ps : Firstly, thanks for patient reading. Secondly, I am just learning so please don't suggested how to do it within same script or use a predefined function to check or convert etc etc...)

Link to comment
Share on other sites

If you're using the number parameter in the link messages from the second script to return the converted integer, and the value returned is only zero when there's been an error, have the main script check the return value, and if it's zero, pop up the error dialog there. So the link_message and listen events in the main script would look something like this:

link_message (integer sender, integer number, string message, key id)
{
	if (number == 0)
	{
		llDialog (user, "Invalid integer.", ["Enter again"], channel);
	}
	else
	{
		//do whatever you're going to do with the valid integer
	}
}

listen (integer channel, string name, key id, string message)
{
	if (message == "Enter again")
	{
		//do the text box thing again
	}
	//all the other listen stuff
}

 

Edited by KT Kingsley
Link to comment
Share on other sites

48 minutes ago, KT Kingsley said:

If you're using the number parameter in the link messages from the second script to return the converted integer, and the value returned is only zero when there's been an error, have the main script check the return value, and if it's zero, pop up the error dialog there. So the link_message and listen events in the main script would look something like this:


link_message (integer sender, integer number, string message, key id)
{
	if (number == 0)
	{
		llDialog (user, "Invalid integer.", ["Enter again"], channel);
	}
	else
	{
		//do whatever you're going to do with the valid integer
	}
}

listen (integer channel, string name, key id, string message)
{
	if (message == "Enter again")
	{
		//do the text box thing again
	}
	//all the other listen stuff
}

 

Thank you KT. 

Assume the llDialog() menu some more buttons too. So once user enter the number it has to do all that functions what I explained above and then it has to return back the main menu again. Something like this...

 

listen(......., string message)

{

     If( pointer == 0)   //listening main menu buttons

     {

          if(message == "enter number")

          {

                llTextbox...

                Pointer = 1;

                button = 1;

          }

          else if( message == "enter string")

          .......

         else if(message =="enter float")

         ......

        else     // this equivalent to if(message=="enter again")

              lltextbox....

      }

      else       //when pointer=1;

      {

           if(button==1)

          {

               llMssageLinked(.....,messag);

               ? ? ? // Here I wanna do something 

               ???

               If(not integer)

               {

                    Pointer = 0;

                    enterAgainMenu();    //it gives menu with button ["enter again"];

                }

                else

                       llOwnerSay("number = "+message);

               

                pointer = 0;

               mainMenu(); // it gives back the main menu again

           }

           else if(button == 2)

            ...........

           else if........

          ...........

          }

     }

}

link_message(.....)

{

     ???

}

 

In this case how do I handle it.

(If I will apply the logic you gave it will popup main menu and also the textbox at a same time I guess...?)

Edited by 0IInoaII0
Link to comment
Share on other sites

When you send the text to the second script you have to wait for that script to reply with the result. You'll know when the second script has replied because it'll trigger a link_message event. It's only when you check that link message that you'll know the result, so anything you do that depends on that result has to wait until the link_message event.

default
{
    listen(......., string message)
    {
        If( pointer == 0)   //listening main menu buttons
        {
            if(message == "enter number")
            {
                llTextbox...
                Pointer = 1;
                button = 1;
            }
            else if( message == "enter string")
            .......
            else if(message =="enter float")
            ......
            else     // this equivalent to if(message=="enter again")
                lltextbox....
        }
        else       //when pointer=1;
        {
            if(button==1)
            {
                llMssageLinked(.....,messag); //send text box result to second script
                //if what you want to do here depends on the result of the conversion
                //to an integer it should be done in the link_message event, where you
                //learn what the result is. If it's something you're going to do 
                //whatever the result, it's fine here
                ? ? ? // Here I wanna do something 
                ???
            }
            else if(button == 2)
            ...........
            else if........
            ...........
        }
    }

    //result comes back from second script
    link_message (integer sender, integer number, string message, key id)
    {
        If(not integer) //the failure of the conversion should be flagged somehow
        //e.g. number == 0, message == "error"
        {
            Pointer = 0;
            enterAgainMenu();    //it gives menu with button ["enter again"];
        }
        else
        {
            llOwnerSay("number = "+message);
            pointer = 0;
            mainMenu(); // it gives back the main menu again
        }
    }
}

I hope this makes sense.

  • Like 2
Link to comment
Share on other sites

I tried doing this way but it was behaving weird, like calling enterAgainMenu() twice and also always executing the failure condition. I think link_message event of 1st script was listening it's own llMessageLinked(). So i had to add one more if condition in link_message that compares the key in order to avoid link_message of same script listen its own messageLinked.

now after some hit and trial finally everything is sorted and it's working how i wanted. high5 KT  \*.*

Edited by 0IInoaII0
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

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