User talk:ZachSmith Resident: Difference between revisions

From Second Life Wiki
Jump to navigation Jump to search
Blanked the page
Strife Onizuka (talk | contribs)
m even out the distribution of random numbers (using round will scew the distribution) and ensure you never chat on channel zero.
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
This is a simple example I made of the fairly new llTextBox. This is free software for anyone to use or learn with. Please use as you like just keep it free software.


<lsl>
//////////////////////////////
//Made by ZachSmith Resident//
//////////////////////////////
//Global Variables//
integer listen_handle;
string detected_name;
//Default State//
default
{
    //Touch_Start event for when the item is touched//
    touch_start(integer total_number)
    {
        //Set the channel to be a random float but remove the fractional portion so it's an integer since channels must be whole numbers.
        //Add one so it's never zero, since channel zero is PUBLIC_CHANNEL.
        integer channel = 1 + (integer)llFrand(10000);
        //save the name of the person touching to a variable to be used later
        detected_name = llDetectedName(0);
        //set the llListen function to listen on channel for message from the key of the detected toucher
        listen_handle = llListen(channel, "", llDetectedKey(0), "");
        //give instructions on how to use
        llSay(0, "Please type your suggestion in the Text Box and then press send. You have 2 minutes");
        //Show the text box for them to put a message into
        llTextBox(llDetectedKey(0), "Type your suggestion below", channel);
        //set a timer event for 2 minutes giving them plenty of time to type a message so we can then close any listeners.
        llSetTimerEvent(120);
    }
    //listen event which is a result of the llListen
    listen(integer channel, string name, key id, string message)
    {
        //Instant message the owner and tell them the name and suggestion that was just typed in the text box
        llInstantMessage(llGetOwner(), detected_name + ": " + message);
        //remove the listener to help reduce lag
        llListenRemove(listen_handle);
        //turn the timer event to 0 so it does not continue going off every 120 seconds
        llSetTimerEvent(0);
    }
    //timer event, result of the llSetTimerEvent
    timer()
    {
        //tell the user that they are out of time and must click again to reopen the listen
        llSay(0, "Sorry, you did not type your message fast enough and has timed out. Please try again.");
        //remove the llListen so it will take less resources
        llListenRemove(listen_handle);
        //set timer event to 0 so it will not continue to say they have run out of time.
        llSetTimerEvent(0);
    }
}
//string name = ZachSmith Resident;//
//integer value = TRUE;//
///////llSetAwesome(name, value);///////

Latest revision as of 08:24, 27 June 2012

This is a simple example I made of the fairly new llTextBox. This is free software for anyone to use or learn with. Please use as you like just keep it free software.

<lsl> ////////////////////////////// //Made by ZachSmith Resident// //////////////////////////////

//Global Variables// integer listen_handle; string detected_name;

//Default State// default {

   //Touch_Start event for when the item is touched//
   touch_start(integer total_number)
   {
       //Set the channel to be a random float but remove the fractional portion so it's an integer since channels must be whole numbers.
       //Add one so it's never zero, since channel zero is PUBLIC_CHANNEL.
       integer channel = 1 + (integer)llFrand(10000);
       //save the name of the person touching to a variable to be used later
       detected_name = llDetectedName(0);
       //set the llListen function to listen on channel for message from the key of the detected toucher
       listen_handle = llListen(channel, "", llDetectedKey(0), "");
       //give instructions on how to use
       llSay(0, "Please type your suggestion in the Text Box and then press send. You have 2 minutes");
       //Show the text box for them to put a message into
       llTextBox(llDetectedKey(0), "Type your suggestion below", channel);
       //set a timer event for 2 minutes giving them plenty of time to type a message so we can then close any listeners.
       llSetTimerEvent(120);
   }
   //listen event which is a result of the llListen
   listen(integer channel, string name, key id, string message)
   {
       //Instant message the owner and tell them the name and suggestion that was just typed in the text box
       llInstantMessage(llGetOwner(), detected_name + ": " + message);
       //remove the listener to help reduce lag
       llListenRemove(listen_handle);
       //turn the timer event to 0 so it does not continue going off every 120 seconds
       llSetTimerEvent(0);
   }
   //timer event, result of the llSetTimerEvent
   timer()
   {
       //tell the user that they are out of time and must click again to reopen the listen
       llSay(0, "Sorry, you did not type your message fast enough and has timed out. Please try again.");
       //remove the llListen so it will take less resources
       llListenRemove(listen_handle);
       //set timer event to 0 so it will not continue to say they have run out of time.
       llSetTimerEvent(0);
   }

}

//string name = ZachSmith Resident;// //integer value = TRUE;// ///////llSetAwesome(name, value);///////