Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

passing random channel to second script?

azure Milev
Registered User
Join date: 5 Jan 2008
Posts: 4
10-22-2008 04:34
Hello, I'm fairly a novice at scripting. I've been working on a dialoge menu that uses a random channel, but I cannot for the life of me figure out how to pass this random channel on to a second script. (This second "slave" script would be in the same prim as the first.). This is the script I've coupled togther creating the random channel: (minus repetive info).



list MAINMENU = [
" ", "Pictures", " "];

list PICS1 = [
"LIST", "Main Menu", "+ >>>",
"07", "08", "09",
"04", "05", "06",
"01", "02", "03"];


string message = "Frame Menu";

integer chan;

integer menu_handler;

default
{
state_entry()
{

chan = 0 - ((integer)llFrand(89999.0) + 10000);
menu_handler = llListen(chan,"","","";);
llListen(chan, "", llGetOwner(), "";);
}

touch_start(integer total_number)
{
//if (llDetectedOwner(0) == llGetOwner()) // IF YOU WANT JUST FOR OWNER

llDialog(llDetectedKey(0), " \n text", MAINMENU, chan);
}

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

if(message == " ";)
{
}
if(message == "Main Menu";)
{
llDialog(id, " \n text", MAINMENU, channel);
}

////////////////////////////////////////////////////////////////////////////////
string picturelist = "\n text";

if(message == "Pictures";)
{
llDialog(id, picturelist, PICS1, channel);
}
if(message == "LIST";)
{
llDialog(id, picturelist, PICS1, channel);
}


if(message == "01";)
{
llSetPrimitiveParams([
PRIM_TEXTURE, 0, "texture",
<1.000, 1.000, 0.0>, <0.0, 0.0, 0.0>, 0.0]);
llSetTextureAnim(ANIM_ON | LOOP, 0,4,3,0,0,8.0); // wide x heigh
llDialog(id, picturelist, PICS1, channel);
}

////////////////////////////////////////////////////////////////////////////////

//NONE
}

on_rez(integer start_param)
{
llResetScript();
}
}


I'd like to be able to create more dialogue button in the second script, if it's possible. Can anyone point me in the right direction for making the second script listen to the first? thank you kindly!
Anya Ristow
Vengeance Studio
Join date: 21 Sep 2006
Posts: 1,243
10-22-2008 04:56
You could pass the menu channel to the second script using llMessageLinked. The second script would have to do its own listening.

You have two listens on the same channel in your script. was that intentional?
_____________________
The Vengeance Studio Gadget Store is closed!

Klug Kuhn
Registered User
Join date: 7 Sep 2007
Posts: 126
10-22-2008 17:25
From: azure Milev
I'd like to be able to create more dialogue button in the second script, if it's possible. Can anyone point me in the right direction for making the second script listen to the first? thank you kindly!


Hi azure~ If you'd like to have multiple menus and more buttons, you could do it in the 1 script under the same state. Below is a working 5-page menu sample script, up to 45 numbers with "prev", "next" and back to main menu page options. Hope that helps. :)


//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
//_/_/_/_/_/_/_/_/_/_/_/_/ The Script Begins /_/_/_/_/_/_/_/_/_/_/_/_/_/
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
key toucher = NULL_KEY; // who touches to use
integer menu_chan = -1; // channel to use in the menu
integer listen_num = -1; // menu listen event handler
integer menu_page = 1; // menu page number
integer using_menu = FALSE; // boolean to avoid multi menus

list MAINMENU = [
" ", "Pictures", " "];

//==============================================================
create_menu(string menu_message,list menu_button)
{ // function used to create menu to "user", given a "menu_message" and "menu_button"
menu_chan = 0 - (integer)llFrand(2147483647);
listen_num = llListen(menu_chan,"", toucher,"";);
llDialog(toucher, menu_message, menu_button, menu_chan);
llSetTimerEvent(60.0); // 60 sec timer used to in case the "ignore" button is pressed or time out
}
//==============================================================
default
{
state_entry()
{
}
touch_start(integer int)
{
if (!using_menu)
{ // only provide menu if no one is using
toucher = llDetectedKey(0);
using_menu = TRUE;
create_menu("MAINMENU MESSAGE",MAINMENU); // create the main menu
}
}
listen(integer channel, string name, key id, string message)
{
llListenRemove(listen_num); // just to save resources
if (message == " ";)
{ // the space is pressed and back to start
using_menu = FALSE;
menu_page = 1;
}
else if (message == "Pictures";)
{ // page 1 begins
string menu_msg = "PAGE 1 MESSAGE";
list page1_button = ["LIST","Main Menu","+ >>>","07","08","09","04","05","06","01","02","03"];
create_menu(menu_msg,page1_button);
}
else if (message == "Main Menu";)
{ // back to main menu
using_menu = FALSE;
menu_page = 1;
create_menu("MAINMENU MESSAGE",MAINMENU);
}
else if ( (message == "- <<<";) || (message == "+ >>>";) )
{ // if the "prev" or "next" page is pressed
if (message == "+ >>>";) // increment the page number
menu_page += 1;
else if (message == "- <<<";) // decrement the page number
menu_page -= 1;

string menu_msg = ""; // initialize a menu message
list template_button = ["- <<<","Main Menu","+ >>>"]; // standardize the bottom 3 buttons

list add_on_button = []; // the buttons to add from different pages
if (menu_page == 1)
{
menu_msg = "PAGE 1 MESSAGE";
add_on_button = ["LIST","Main Menu","+ >>>","07","08","09","04","05","06","01","02","03"];
}
else if (menu_page == 2)
{
menu_msg = "PAGE 2 MESSAGE";
add_on_button = template_button + ["16","17","18","13","14","15","10","11","12"];
}
else if (menu_page == 3)
{
menu_msg = "PAGE 3 MESSAGE";
add_on_button = template_button + ["25","26","27","22","23","24","19","20","21"];
}
else if (menu_page == 4)
{
menu_msg = "PAGE 4 MESSAGE";
add_on_button = template_button + ["34","35","36","31","32","33","28","29","30"];
}
else if (menu_page == 5)
{
menu_msg = "PAGE 5 MESSAGE";
template_button = ["- <<<","Main Menu"," "]; // last page special case, no more "next page"
add_on_button = template_button + ["43","44","45","40","41","42","37","38","39"];
}

create_menu(menu_msg,add_on_button);
}
else if (message == "LIST";)
{ // do "LIST" actions
}
else if (message == "01";)
{ // do "01" actions
}
else if (message == "02";)
{ // do "02" actions
}
// .... add more "else if" in between for each picture number
else if (message == "45";)
{ // do "45" actions
}
}
timer()
{ // 60 sec timer used to in case the "ignore" button is pressed or time out
llListenRemove(listen_num);
llSetTimerEvent(0.0);
using_menu = FALSE;
menu_page = 1;
}
}
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
//_/_/_/_/_/_/_/_/_/_/_/_/ The Script Ends /_/_/_/_/_/_/_/_/_/_/_/_/_/_/
//_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/