Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

dialog problems

Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
08-22-2008 23:11
Hi team.
My dialog in this script takes two goes to work. It never works the first time
Please see and tell me what's wrong. There will be more than one mistake in this. Help me get it working correctly.
CODE

/////////--REMINDER- Comment or remove memory check!
////////---
///////----
//////-----
/////------
////-------
///--------
//---------

integer DEBUG = FALSE;
integer lineCounter;
key dataRequestID;
integer CHANNEL = -27072008; // Date o f script iteration used for DIALOG channel# Huh?
integer listen_handle;
////////////---------------
string s_notecard = "Settings";
integer INTERIOR;
integer EXTERIOR;
string COMMAND1;
string COMMAND2;
string COMMAND3;
string COMMAND4;
string COMMAND5;
integer DATA_CHANNEL01;
string Inside;
key kQuery;
key gCurKey;
debug(string in)
{
if(DEBUG)llOwnerSay((string)llGetScriptName()+" Debug= " +in);
}
GetParameters(string str){
list lsdata = llParseString2List(str, ["="], [""]);
string item = llList2String(lsdata,0);
string value = llList2String(lsdata,1);
integer intvalue = (integer)value;
//llOwnerSay("Reading " + item + " is set at:" + value);
if ("COMMAND1" == item) { COMMAND1 = (string)value; }
if ("COMMAND2" == item) { COMMAND2 = (string)value; }
if ("COMMAND3" == item) { COMMAND3 = (string)value; }
if ("COMMAND4" == item) { COMMAND4 = (string)value; }
if ("COMMAND5" == item) { COMMAND5 = (string)value; }
if ("DATA_CHANNEL01" == item) {DATA_CHANNEL01 = (integer) value;}

}

//-----------//-----THE MENUS

list MENU_ONE = ["Inside7","Inside8","Inside9","Inside4","Inside5","Inside6","Inside1","Inside2","Inside3","ALPHA","OUTSIDE","MAIN MENU"];
list MENU_TWO = ["Outside7","Outside8","Outside9","Outside4","Outside5","Outside6","Outside1","Outside2","Outside3","ALPHA","INSIDE","MAIN MENU"];
list MENU_THREE = ["Int_0.75","Int_0.50","Int_0.25","Ext_0.75","Ext_0.50","Ext_0.25","Ext_1.0","Ext_0.0","Int_0.0","Int_1.0","INSIDE","OUTSIDE"];



Main_Dialog(){ llDialog(gCurKey, "Set the INTERIOR Texture", MENU_ONE, CHANNEL);
llSetTimerEvent(30.0);return;}

//-----------//----CHANGED FUNCTION
Changed(integer change)
{
// Test for a changed inventory
if (change & CHANGED_INVENTORY)
{
llResetScript();
}
else if (change & CHANGED_OWNER)
{
llResetScript();
}
}
///////------------GET TEXTURE KEYS
list items;
list tex_list;
integer item_len;
loop()
{
//Search Integer Primer
integer i;
//Establish Objects in Inventory
integer totalDetected = llGetInventoryNumber(INVENTORY_TEXTURE) + 1;
//Move into Comparision Loop
for (i = 0; i < totalDetected - 1; i++)
{
//Search Results
string tex_name = llGetInventoryName(INVENTORY_TEXTURE,i);
items += tex_name;
}
item_len = llGetListLength(items) - 1;
tex_list = llList2List(items,0,8 );
return;
}
//////////--------
parse_message(string message){

loop();
string number = llGetSubString(message, -1, -1);
string texkey = llGetInventoryKey(llList2String(tex_list,(integer)number -1));

llMessageLinked(LINK_ALL_OTHERS,0,message+"|"+texkey,NULL_KEY);
llSay(DATA_CHANNEL01,"set_all"+"|"+message+"|"+texkey);
debug((string) message+texkey);
return;
}
//----------//----DEFAULT STATE

default
{
state_entry()
{
state ReadConfig;
}

on_rez (integer change) { Changed(change); }

changed(integer change) { Changed(change) ; }
}

//-------------//-----MAIN RUNNING STATE-----//----------//-
state Running
{
state_entry()
{ //MENU_ONE = [COMMAND1+"7",COMMAND1+"8",COMMAND1+"9",COMMAND1+"4",COMMAND1+"5",COMMAND1+"6",COMMAND1+"1",COMMAND1+"2",COMMAND1+"3",COMMAND4,COMMAND5,"MAIN MENU"];

debug((string)llGetFreeMemory());

}
///////////------------LISTEN EVENTS
listen(integer CHANNEL, string name, key id, string message)
{

if (llListFindList(MENU_ONE+ MENU_TWO + MENU_THREE , [message]) != -1)
{
if (message == "INSIDE")
{
llDialog(id, "Set the INSIDE Texture", MENU_ONE, CHANNEL);
llSetTimerEvent(30.0);
}

else if (message == "OUTSIDE")
{
llDialog(id, "Set the EXTERIOR Texture", MENU_TWO, CHANNEL);
llSetTimerEvent(30.0);
}
else if (message == "ALPHA")
{
llDialog(id, "Set the Percentage of ALPHA." , MENU_THREE, CHANNEL);
llSetTimerEvent(30.0);
}
else if (message == "MAIN MENU") llMessageLinked(LINK_THIS, 0,"MAIN_MENU",NULL_KEY);


else if (llGetSubString(message,0,5) == "Inside")
{ llListenRemove(listen_handle);
debug((string) message);
parse_message(message);

}
else if (llGetSubString(message,0,6) == "Outside")
{ llListenRemove(listen_handle);
debug((string) message);
parse_message(message);
}


else if (llGetSubString(message,0,3) =="Int_")
{ llListenRemove(listen_handle);
llMessageLinked(LINK_ALL_OTHERS,0,message,NULL_KEY);
llSay(DATA_CHANNEL01,message);
debug((string) message);
}
else if (llGetSubString(message,0,3) =="Ext_")
{ llListenRemove(listen_handle);
llMessageLinked(LINK_ALL_OTHERS,0,message,NULL_KEY);
llSay(DATA_CHANNEL01,message);
debug((string) message);
}
}
// else llInstantMessage(id, " picked invalid option '" + llToLower(message) + "'.");
}/////////////----------END LISTEN
timer() {
llListenRemove(listen_handle); //Remove that dialog listener
llSetTimerEvent(0);}
changed(integer change) { Changed(change) ; }
on_rez(integer change) { Changed(change); }

//----------//---------LINK MESSAGE EVENT

link_message(integer sender, integer num, string str, key gCurKey)
{
if (str == "reset_script") {llResetScript();}

if (str=="MENU_1") {
llDialog(gCurKey, "Set the INTERIOR Texture", MENU_ONE, CHANNEL);
CHANNEL = (integer) llFrand (1000000)+1;
listen_handle = llListen(CHANNEL, "",gCurKey, "");

llSetTimerEvent(30);
}
else if (str=="MENU_2") { llDialog(gCurKey, "Set the EXTERIOR Texture", MENU_TWO, CHANNEL);
CHANNEL = (integer) llFrand (1000000)+1;
listen_handle = llListen(CHANNEL, "",gCurKey, "");
llSetTimerEvent(30);
}
else if (str=="MENU_3") { llDialog(gCurKey, "Set the Percentage of ALPHA.", MENU_THREE, CHANNEL);
CHANNEL = (integer) llFrand (1000000)+1;
listen_handle = llListen(CHANNEL, "",gCurKey, "");
llSetTimerEvent(30);
}
}
//End link_message
}//END RUNNING STATE

//----------//---------INITIALISE SETTINGS NOTECARD

state ReadConfig

{
state_entry()
{
lineCounter = 0;
integer itemtype = llGetInventoryType(s_notecard);
if(INVENTORY_NOTECARD == itemtype)
{
kQuery = llGetNotecardLine(s_notecard, lineCounter);
llSetTimerEvent(30);
}
else {
llOwnerSay("Error - configuration notecard missing, Using defaults only!");
state Running; }
}
dataserver( key s_query_id, string sdata ) // read from the notecard
{
if(s_query_id == kQuery)
{ if (sdata != EOF){
if(llStringLength(sdata) > 3)
{
GetParameters(sdata);
} lineCounter++;
kQuery = llGetNotecardLine( s_notecard, lineCounter );}
else
{
llSetTimerEvent(0);
// llOwnerSay("Data looks clean. All Good!");
state Running; }}
}
timer() {
llListenRemove(listen_handle);
llOwnerSay("ERROR - Dataserver time out! aborting");
llSetTimerEvent(0);
state Running;
}
on_rez(integer num) { llResetScript(); }
changed(integer change) { Changed(change) ; }// if something has been updated resetnning;

}
_____________________
SCOPE Homes, Bangu
-----------------------------------------------------------------
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-23-2008 09:11
sigh....................
You are using a combination of styles in some areas and no style at all in other parts of the script. Then you have declared global variables throughout the script and a person has to hunt for them. I can see why no one has responded yet because they would have had to do what I just spent my time doing instead of troubleshooting.

Cleaned up and now readable:
CODE

integer DEBUG = FALSE;
integer lineCounter;
key dataRequestID;
integer CHANNEL = -27072008;
integer listen_handle;
string s_notecard = "Settings";
integer INTERIOR;
integer EXTERIOR;
string COMMAND1;
string COMMAND2;
string COMMAND3;
string COMMAND4;
string COMMAND5;
integer DATA_CHANNEL01;
string Inside;
key kQuery;
key gCurKey;
list MENU_ONE = ["Inside7","Inside8","Inside9","Inside4","Inside5","Inside6","Inside1","Inside2","Inside3","ALPHA","OUTSIDE","MAIN MENU"];
list MENU_TWO = ["Outside7","Outside8","Outside9","Outside4","Outside5","Outside6","Outside1","Outside2","Outside3","ALPHA","INSIDE","MAIN MENU"];
list MENU_THREE = ["Int_0.75","Int_0.50","Int_0.25","Ext_0.75","Ext_0.50","Ext_0.25","Ext_1.0","Ext_0.0","Int_0.0","Int_1.0","INSIDE","OUTSIDE"];
list items;
list tex_list;
integer item_len;

debug(string in)
{
if(DEBUG)llOwnerSay((string)llGetScriptName() + " Debug= " + in);
}

GetParameters(string str)
{
list lsdata = llParseString2List(str, ["="], [""]);
string item = llList2String(lsdata,0);
string value = llList2String(lsdata,1);
integer intvalue = (integer)value;
if ("COMMAND1" == item) { COMMAND1 = (string)value; }
if ("COMMAND2" == item) { COMMAND2 = (string)value; }
if ("COMMAND3" == item) { COMMAND3 = (string)value; }
if ("COMMAND4" == item) { COMMAND4 = (string)value; }
if ("COMMAND5" == item) { COMMAND5 = (string)value; }
if ("DATA_CHANNEL01" == item) {DATA_CHANNEL01 = (integer) value;}
}

Main_Dialog()
{
llDialog(gCurKey, "Set the INTERIOR Texture", MENU_ONE, CHANNEL);
llSetTimerEvent(30.0);return;
}

Changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
llResetScript();
}
else if (change & CHANGED_OWNER)
{
llResetScript();
}
}

loop()
{
integer i;
integer totalDetected = llGetInventoryNumber(INVENTORY_TEXTURE) + 1;
for (i = 0; i < totalDetected - 1; i++)
{
string tex_name = llGetInventoryName(INVENTORY_TEXTURE,i);
items += tex_name;
}
item_len = llGetListLength(items) - 1;
tex_list = llList2List(items,0,8 );
return;
}

parse_message(string message)
{
loop();
string number = llGetSubString(message, -1, -1);
string texkey = llGetInventoryKey(llList2String(tex_list,(integer)number -1));
llMessageLinked(LINK_ALL_OTHERS,0,message+"|"+texkey,NULL_KEY);
llSay(DATA_CHANNEL01,"set_all"+"|"+message+"|"+texkey);
debug((string) message+texkey);
return;
}

default
{
state_entry()
{
state ReadConfig;
}
on_rez (integer change)
{
Changed(change);
}
changed(integer change)
{
Changed(change) ;
}
}

state Running
{
state_entry()
{
debug((string)llGetFreeMemory());
}
listen(integer CHANNEL, string name, key id, string message)
{
if (llListFindList(MENU_ONE + MENU_TWO + MENU_THREE , [message]) != -1)
{
if (message == "INSIDE")
{
llDialog(id, "Set the INSIDE Texture", MENU_ONE, CHANNEL);
llSetTimerEvent(30.0);
}
else if (message == "OUTSIDE")
{
llDialog(id, "Set the EXTERIOR Texture", MENU_TWO, CHANNEL);
llSetTimerEvent(30.0);
}
else if (message == "ALPHA")
{
llDialog(id, "Set the Percentage of ALPHA." , MENU_THREE, CHANNEL);
llSetTimerEvent(30.0);
}
else if (message == "MAIN MENU") llMessageLinked(LINK_THIS, 0,"MAIN_MENU",NULL_KEY);
else if (llGetSubString(message,0,5) == "Inside")
{
llListenRemove(listen_handle);
debug((string) message);
parse_message(message);
}
else if (llGetSubString(message,0,6) == "Outside")
{
llListenRemove(listen_handle);
debug((string) message);
parse_message(message);
}
else if (llGetSubString(message,0,3) =="Int_")
{
llListenRemove(listen_handle);
llMessageLinked(LINK_ALL_OTHERS,0,message,NULL_KEY);
llSay(DATA_CHANNEL01,message);
debug((string) message);
}
else if (llGetSubString(message,0,3) =="Ext_")
{
llListenRemove(listen_handle);
llMessageLinked(LINK_ALL_OTHERS,0,message,NULL_KEY);
llSay(DATA_CHANNEL01,message);
debug((string) message);
}
}
}
timer()
{
llListenRemove(listen_handle);
llSetTimerEvent(0);
}
changed(integer change)
{
Changed(change);
}
on_rez(integer change)
{
Changed(change);
}
link_message(integer sender, integer num, string str, key gCurKey)
{
if (str == "reset_script") llResetScript();
if (str=="MENU_1")
{
llDialog(gCurKey, "Set the INTERIOR Texture", MENU_ONE, CHANNEL);
CHANNEL = (integer) llFrand (1000000)+1;
listen_handle = llListen(CHANNEL, "",gCurKey, "");
llSetTimerEvent(30);
}
else if (str=="MENU_2")
{
llDialog(gCurKey, "Set the EXTERIOR Texture", MENU_TWO, CHANNEL);
CHANNEL = (integer) llFrand (1000000)+1;
listen_handle = llListen(CHANNEL, "",gCurKey, "");
llSetTimerEvent(30);
}
else if (str=="MENU_3")
{
llDialog(gCurKey, "Set the Percentage of ALPHA.", MENU_THREE, CHANNEL);
CHANNEL = (integer) llFrand (1000000)+1;
listen_handle = llListen(CHANNEL, "",gCurKey, "");
llSetTimerEvent(30);
}
}
}

state ReadConfig
{
state_entry()
{
lineCounter = 0;
integer itemtype = llGetInventoryType(s_notecard);
if(INVENTORY_NOTECARD == itemtype)
{
kQuery = llGetNotecardLine(s_notecard, lineCounter);
llSetTimerEvent(30);
}
else {
llOwnerSay("Error - configuration notecard missing, Using defaults only!");
state Running;
}
}
dataserver( key s_query_id, string sdata )
{
if(s_query_id == kQuery)
{
if (sdata != EOF)
{
if(llStringLength(sdata) > 3)
{
GetParameters(sdata);
}
lineCounter++;
kQuery = llGetNotecardLine( s_notecard, lineCounter );}
else
{
llSetTimerEvent(0);
state Running;
}
}
}
timer()
{
llListenRemove(listen_handle);
llOwnerSay("ERROR - Dataserver time out! aborting");
llSetTimerEvent(0);
state Running;
}
on_rez(integer num)
{
llResetScript();
}
changed(integer change)
{
Changed(change) ;
}
}

Post a copy of an example notecard and I will give it a try.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
08-23-2008 10:52
It was certainly too much code for me to go through in any detail. :)

...but I did notice this kind of thing in a few places:

llDialog(gCurKey, "Set the EXTERIOR Texture", MENU_TWO, CHANNEL);
CHANNEL = (integer) llFrand (1000000)+1;
listen_handle = llListen(CHANNEL, "",gCurKey, "";);


Which didn't make a lot of sense... issue the Dialog on CHANNEL, change the CHANNEL, listen on the CHANNEL.

Normally I'd expect to see the llDialog after the setting up of a new channel. As I haven't studied the script too closely this is just a random stab so ignore me if it's all a part of some cunning design. :)
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
08-23-2008 18:09
From: Jesse Barnett
sigh....................
You are using a combination of styles in some areas and no style at all in other parts of the script. Then you have declared global variables throughout the script and a person has to hunt for them. I can see why no one has responded yet because they would have had to do what I just spent my time doing instead of troubleshooting.


Sorry for the mess. I did try to clean it up but not good enough I see.
Your efforts are much appreciated, believe me.
I guess I don't have a style. I certainly can't 'see' a style and never thought about a style.
I will also look at the global variables and try to do something about those.
Thanks Jesse. All comments noted.
p.s. I have used lsl editor but I'm not clued up enough yet and still have to see what happens to changes I make live, inworld.
_____________________
SCOPE Homes, Bangu
-----------------------------------------------------------------
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
08-23-2008 18:17
From: Pale Spectre
It was certainly too much code for me to go through in any detail. :)

...but I did notice this kind of thing in a few places:

llDialog(gCurKey, "Set the EXTERIOR Texture", MENU_TWO, CHANNEL);
CHANNEL = (integer) llFrand (1000000)+1;
listen_handle = llListen(CHANNEL, "",gCurKey, "";);


Which didn't make a lot of sense... issue the Dialog on CHANNEL, change the CHANNEL, listen on the CHANNEL.

Normally I'd expect to see the llDialog after the setting up of a new channel. As I haven't studied the script too closely this is just a random stab so ignore me if it's all a part of some cunning design. :)


LOL.. cunning design lol, me? I've learned a lot in the past two months but cunning design isn't one of them.

From: someone
Which didn't make a lot of sense... issue the Dialog on CHANNEL, change the CHANNEL, listen on the CHANNEL.


Ok, that's a great point. I never even looked at that part for many weeks thinking it was fine but it may be the main problem, calling the dialog before opening the channel.

I have something to go on now that someone else looked. Thank you too Pale...Muchly!
_____________________
SCOPE Homes, Bangu
-----------------------------------------------------------------
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-23-2008 18:48
From: Kornscope Komachi
Sorry for the mess. I did try to clean it up but not good enough I see.
Your efforts are much appreciated, believe me.
I guess I don't have a style. I certainly can't 'see' a style and never thought about a style.
I will also look at the global variables and try to do something about those.
Thanks Jesse. All comments noted.
p.s. I have used lsl editor but I'm not clued up enough yet and still have to see what happens to changes I make live, inworld.


There are several different styles for coding with K&R and Allman being the most popular. Personally I prefer K&R myself, you still have the 4 space/ 1 tab indentation but it shortens the number of lines by putting the opening brace on the same line as the control statement.

The important thing about all of this gobbledy gook thou is that it makes the code more readable and gives it a "flow" that is easier on the eyes. In a short script it doesn't really matter and even a 1000 line script will run on one single extremely long line. The compiler doesn't care beans about indentation etc. It is strictly for your benefit and makes debugging easier.

http://en.wikipedia.org/wiki/Indent_style

Here is the same code from above in my favorit K&R style just to show the difference:

CODE

integer DEBUG = FALSE;
integer lineCounter;
key dataRequestID;
integer CHANNEL = -27072008;
integer listen_handle;
string s_notecard = "Settings";
integer INTERIOR;
integer EXTERIOR;
string COMMAND1;
string COMMAND2;
string COMMAND3;
string COMMAND4;
string COMMAND5;
integer DATA_CHANNEL01;
string Inside;
key kQuery;
key gCurKey;
list MENU_ONE = ["Inside7","Inside8","Inside9","Inside4","Inside5","Inside6","Inside1","Inside2","Inside3","ALPHA","OUTSIDE","MAIN MENU"];
list MENU_TWO = ["Outside7","Outside8","Outside9","Outside4","Outside5","Outside6","Outside1","Outside2","Outside3","ALPHA","INSIDE","MAIN MENU"];
list MENU_THREE = ["Int_0.75","Int_0.50","Int_0.25","Ext_0.75","Ext_0.50","Ext_0.25","Ext_1.0","Ext_0.0","Int_0.0","Int_1.0","INSIDE","OUTSIDE"];
list items;
list tex_list;
integer item_len;

debug(string in){
if(DEBUG)llOwnerSay((string)llGetScriptName() + " Debug= " + in);
}

GetParameters(string str){
list lsdata = llParseString2List(str, ["="], [""]);
string item = llList2String(lsdata,0);
string value = llList2String(lsdata,1);
integer intvalue = (integer)value;
if ("COMMAND1" == item) { COMMAND1 = (string)value; }
if ("COMMAND2" == item) { COMMAND2 = (string)value; }
if ("COMMAND3" == item) { COMMAND3 = (string)value; }
if ("COMMAND4" == item) { COMMAND4 = (string)value; }
if ("COMMAND5" == item) { COMMAND5 = (string)value; }
if ("DATA_CHANNEL01" == item) {DATA_CHANNEL01 = (integer) value;}
}

Main_Dialog(){
llDialog(gCurKey, "Set the INTERIOR Texture", MENU_ONE, CHANNEL);
llSetTimerEvent(30.0);return;
}

Changed(integer change){
if (change & CHANGED_INVENTORY){
llResetScript();
}
else if (change & CHANGED_OWNER){
llResetScript();
}
}

loop(){
integer i;
integer totalDetected = llGetInventoryNumber(INVENTORY_TEXTURE) + 1;
for (i = 0; i < totalDetected - 1; i++){
string tex_name = llGetInventoryName(INVENTORY_TEXTURE,i);
items += tex_name;
}
item_len = llGetListLength(items) - 1;
tex_list = llList2List(items,0,8 );
return;
}

parse_message(string message){
loop();
string number = llGetSubString(message, -1, -1);
string texkey = llGetInventoryKey(llList2String(tex_list,(integer)number -1));
llMessageLinked(LINK_ALL_OTHERS,0,message+"|"+texkey,NULL_KEY);
llSay(DATA_CHANNEL01,"set_all"+"|"+message+"|"+texkey);
debug((string) message+texkey);
return;
}

default{
state_entry(){
state ReadConfig;
}
on_rez (integer change){
Changed(change);
}
changed(integer change){
Changed(change) ;
}
}

state Running{
state_entry(){
debug((string)llGetFreeMemory());
}
listen(integer CHANNEL, string name, key id, string message){
if (llListFindList(MENU_ONE + MENU_TWO + MENU_THREE , [message]) != -1) {
if (message == "INSIDE"){
llDialog(id, "Set the INSIDE Texture", MENU_ONE, CHANNEL);
llSetTimerEvent(30.0);
}
else if (message == "OUTSIDE"){
llDialog(id, "Set the EXTERIOR Texture", MENU_TWO, CHANNEL);
llSetTimerEvent(30.0);
}
else if (message == "ALPHA"){
llDialog(id, "Set the Percentage of ALPHA." , MENU_THREE, CHANNEL);
llSetTimerEvent(30.0);
}
else if (message == "MAIN MENU") llMessageLinked(LINK_THIS, 0,"MAIN_MENU",NULL_KEY);
else if (llGetSubString(message,0,5) == "Inside"){
llListenRemove(listen_handle);
debug((string) message);
parse_message(message);
}
else if (llGetSubString(message,0,6) == "Outside"){
llListenRemove(listen_handle);
debug((string) message);
parse_message(message);
}
else if (llGetSubString(message,0,3) =="Int_"){
llListenRemove(listen_handle);
llMessageLinked(LINK_ALL_OTHERS,0,message,NULL_KEY);
llSay(DATA_CHANNEL01,message);
debug((string) message);
}
else if (llGetSubString(message,0,3) =="Ext_"){
llListenRemove(listen_handle);
llMessageLinked(LINK_ALL_OTHERS,0,message,NULL_KEY);
llSay(DATA_CHANNEL01,message);
debug((string) message);
}
}
}
timer(){
llListenRemove(listen_handle);
llSetTimerEvent(0);
}
changed(integer change){
Changed(change);
}
on_rez(integer change){
Changed(change);
}
link_message(integer sender, integer num, string str, key gCurKey){
if (str == "reset_script") llResetScript();
if (str=="MENU_1"){
llDialog(gCurKey, "Set the INTERIOR Texture", MENU_ONE, CHANNEL);
CHANNEL = (integer) llFrand (1000000)+1;
listen_handle = llListen(CHANNEL, "",gCurKey, "");
llSetTimerEvent(30);
}
else if (str=="MENU_2"){
llDialog(gCurKey, "Set the EXTERIOR Texture", MENU_TWO, CHANNEL);
CHANNEL = (integer) llFrand (1000000)+1;
listen_handle = llListen(CHANNEL, "",gCurKey, "");
llSetTimerEvent(30);
}
else if (str=="MENU_3"){
llDialog(gCurKey, "Set the Percentage of ALPHA.", MENU_THREE, CHANNEL);
CHANNEL = (integer) llFrand (1000000)+1;
listen_handle = llListen(CHANNEL, "",gCurKey, "");
llSetTimerEvent(30);
}
}
}

state ReadConfig{
state_entry(){
lineCounter = 0;
integer itemtype = llGetInventoryType(s_notecard);
if(INVENTORY_NOTECARD == itemtype){
kQuery = llGetNotecardLine(s_notecard, lineCounter);
llSetTimerEvent(30);
}
else{
llOwnerSay("Error - configuration notecard missing, Using defaults only!");
state Running;
}
}
dataserver( key s_query_id, string sdata ){
if(s_query_id == kQuery){
if (sdata != EOF){
if(llStringLength(sdata) > 3){
GetParameters(sdata);
}
lineCounter++;
kQuery = llGetNotecardLine( s_notecard, lineCounter );}
else{
llSetTimerEvent(0);
state Running;
}
}
}
timer(){
llListenRemove(listen_handle);
llOwnerSay("ERROR - Dataserver time out! aborting");
llSetTimerEvent(0);
state Running;
}
on_rez(integer num){
llResetScript();
}
changed(integer change){
Changed(change) ;
}
}


Now to get back to your code. As Pale was alluding to, try commenting out the llFrand's and setting CHANNEL to just one variable and give it a try. If that works then try assigning the llFrand value to CHANNEL once in the state entry.

If that still doesn't fix it then try posting a notecard example I can then give it a try.

PS, glad to see that you still here and coding merrily along.

EDIT: You had already replied to Pale by the time (I was half watching TV while doing this :) )I had finished coming up with my reply.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
08-23-2008 22:06
Thanks heaps for those suggestions. Is working better now.
The fixes mentioned were correct. Those parts of my script were what I was overlooking completely and I realise the error of my ways. It looks so simple now it's been pointed out.

Now to tackle other problems...
_____________________
SCOPE Homes, Bangu
-----------------------------------------------------------------
SuezanneC Baskerville
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
08-23-2008 22:45
Korn enclosed his code in /code tags and they worked thanks to Strife's script.

Jesse enclosed her code in php tags and they didn't work.

Is that what others get or is something wrong on my system?
_____________________
-

So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.

I can be found on the web by searching for "SuezanneC Baskerville", or go to

http://www.google.com/profiles/suezanne

-

http://lindenlab.tribe.net/ created on 11/19/03.

Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard,
Robin, and Ryan

-
Laurence Corleone
Registered User
Join date: 12 Oct 2006
Posts: 126
08-23-2008 22:48
From: SuezanneC Baskerville
Korn enclosed his code in /code tags and they worked thanks to Strife's script.

Jesse enclosed her code in php tags and they didn't work.

Is that what others get or is something wrong on my system?


Or could it be that one ended in /php and the other in \php?
_____________________
There are no stupid questions, just stupid people.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-23-2008 23:00
hmm they both are working for me using the same grease monkey script. Is it better now?
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
SuezanneC Baskerville
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
08-23-2008 23:14
It is working now.
_____________________
-

So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.

I can be found on the web by searching for "SuezanneC Baskerville", or go to

http://www.google.com/profiles/suezanne

-

http://lindenlab.tribe.net/ created on 11/19/03.

Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard,
Robin, and Ryan

-
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
08-24-2008 02:09
Well I spoke too early. The script finally stopped the two times selection issue but now it times out and stops working altogether.
I took the data server stuff out and added a touch and it seemed ok. But as is, is not.
I've tried placing the channel setup in various places but it times out every time.
Another script calls this one but then there is no connection.
What's cusing it to stop?
CODE

integer DEBUG = TRUE;
integer lineCounter;
key dataRequestID;
integer CHANNEL = -27072008;
integer listen_handle;
string s_notecard = "Settings";
integer DATA_CHANNEL01 = -98745632145;
string PLACE_HOLDER;
key kQuery;
key gCurKey;
list MENU_ONE = ["Inside7","Inside8","Inside9","Inside4","Inside5","Inside6","Inside1","Inside2","Inside3","ALPHA","OUTSIDE","MAIN MENU"];
list MENU_TWO = ["Outside7","Outside8","Outside9","Outside4","Outside5","Outside6","Outside1","Outside2","Outside3","ALPHA","INSIDE","MAIN MENU"];
list MENU_THREE = ["Int_0.75","Int_0.50","Int_0.25","Ext_0.75","Ext_0.50","Ext_0.25","Ext_1.0","Ext_0.0","Int_0.0","Int_1.0","INSIDE","OUTSIDE"];
list items;
list tex_list;
integer item_len;

debug(string in){
if(DEBUG)llOwnerSay((string)llGetScriptName() + " Debug= " + in);
}

GetParameters(string str){
list lsdata = llParseString2List(str, ["="], [""]);
string item = llList2String(lsdata,0);
string value = llList2String(lsdata,1);
integer intvalue = (integer)value;
if ("PLACE_HOLDER" == item) {PLACE_HOLDER = (string) value;}
}

Changed(integer change){
if (change & CHANGED_INVENTORY){
llResetScript();
}
else if (change & CHANGED_OWNER){
llResetScript();
}
}

loop(){
integer i;
integer totalDetected = llGetInventoryNumber(INVENTORY_TEXTURE) + 1;
for (i = 0; i < totalDetected - 1; i++){
string tex_name = llGetInventoryName(INVENTORY_TEXTURE,i);
items += tex_name;
}
item_len = llGetListLength(items) - 1;
tex_list = llList2List(items,0,8 );
return;
}

parse_message(string message){
loop();
string number = llGetSubString(message, -1, -1);
string texkey = llGetInventoryKey(llList2String(tex_list,(integer) number -1));
llMessageLinked(LINK_ALL_OTHERS,0,message+"|"+texkey,NULL_KEY);
llSay(DATA_CHANNEL01,"set_all"+"|"+message+"|"+texkey);
debug((string) message+texkey);
// llListenRemove(listen_handle);
//return;
}

default{
state_entry(){
state ReadConfig;
}
on_rez (integer change){
Changed(change);
}
changed(integer change){
Changed(change) ;
}
}

state Running{
state_entry(){
CHANNEL = -41255555;
listen_handle = llListen(CHANNEL, "",gCurKey, "");
debug((string)llGetFreeMemory());
}
listen(integer CHANNEL, string name, key id, string message){
if (llListFindList(MENU_ONE + MENU_TWO + MENU_THREE , [message]) != -1){
if (message == "INSIDE"){
debug((string) message);
llDialog(id, "Set the INSIDE Texture", MENU_ONE, CHANNEL);
llSetTimerEvent(30.0);
}
else if (message == "OUTSIDE"){
debug((string) message);
llDialog(id, "Set the EXTERIOR Texture", MENU_TWO, CHANNEL);
llSetTimerEvent(30.0);
}
else if (message == "ALPHA"){
debug((string) message);
llDialog(id, "Set the Percentage of ALPHA." , MENU_THREE, CHANNEL);
llSetTimerEvent(30.0);
}
else if (message == "MAIN MENU") llMessageLinked(LINK_THIS, 0,"MAIN_MENU",NULL_KEY);
else if (llGetSubString(message,0,5) == "Inside"){
debug((string) message);
parse_message(message);
}
else if (llGetSubString(message,0,6) == "Outside"){
debug((string) message);
parse_message(message);
}
else if (llGetSubString(message,0,3) =="Int_"){
llMessageLinked(LINK_ALL_OTHERS,0,message,NULL_KEY );
llSay(DATA_CHANNEL01,message);
debug((string) message);
}
else if (llGetSubString(message,0,3) =="Ext_"){
llMessageLinked(LINK_ALL_OTHERS,0,message,NULL_KEY );
llSay(DATA_CHANNEL01,message);
debug((string) message);
}
}
}

link_message(integer sender, integer num, string str, key gCurKey){
if (str == "reset_script") llResetScript();
if (str=="MENU_1"){
// CHANNEL = -41255555;
// listen_handle = llListen(CHANNEL, "",gCurKey, "");
llDialog(gCurKey, "Set the INTERIOR Texture", MENU_ONE, CHANNEL);
llSetTimerEvent(30);
}
else if (str=="MENU_2"){
llDialog(gCurKey, "Set the EXTERIOR Texture", MENU_TWO, CHANNEL);
llSetTimerEvent(30);
}
else if (str=="MENU_3"){
llDialog(gCurKey, "Set the Percentage of ALPHA.", MENU_THREE, CHANNEL);
llSetTimerEvent(30);
}
}

timer(){
llListenRemove(listen_handle);
llSetTimerEvent(0);
debug("timer gone off");
}
changed(integer change){
Changed(change);
}
on_rez(integer change){
Changed(change);
}
}

state ReadConfig{
state_entry(){
lineCounter = 0;
integer itemtype = llGetInventoryType(s_notecard);
if(INVENTORY_NOTECARD == itemtype){
kQuery = llGetNotecardLine(s_notecard, lineCounter);
llSetTimerEvent(30);
}
else{
llOwnerSay("Error - configuration notecard missing, Using defaults only!");
state Running;
}
}
dataserver( key s_query_id, string sdata ){
if(s_query_id == kQuery){
if (sdata != EOF){
if(llStringLength(sdata) > 3){
GetParameters(sdata);
}
lineCounter++;
kQuery = llGetNotecardLine( s_notecard, lineCounter );}
else{
llSetTimerEvent(0);
state Running;
}
}
}
timer(){
llListenRemove(listen_handle);
// llOwnerSay("ERROR - Dataserver time out! aborting");
llSetTimerEvent(0);
state Running;
}
on_rez(integer num){
llResetScript();
}
changed(integer change){
Changed(change) ;
}
}

_____________________
SCOPE Homes, Bangu
-----------------------------------------------------------------
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
08-24-2008 03:05
I don't know whether I found everything (nor, if I really got what the script is supposed to do)...

You have a listener and a linked_message-statement in your «state Running».
When you get a chat-/linked-message, you set up a timer to 30 seconds (in case the Dialog isn't answered, so you can kill the listener - which is actually good practice).
BUT: you only set the listener in the state_entry of your running-state. So once the timer fires because the dialog times out, the listener is killed and never initiated again - then, the object stops to listen for chats and dialog-commands.

I don't know why you need the chat-listener, but you obviously do. So this listener has to be persistent. That's why I commented out all the llSetTimer-Events in your code.

There were some more flaws I hope I was able to correct. I added comments where I changed something and left the original statement in your code (also commented out).

I only went over it using TextMate, so there might be some syntax-errors... (I hope not, though :)



CODE

integer DEBUG = TRUE;
integer lineCounter;
key dataRequestID;
integer CHANNEL = -27072008;
integer listen_handle;
string s_notecard = "Settings";
integer DATA_CHANNEL01 = -98745632145;
string PLACE_HOLDER;
key kQuery;
key gCurKey;
list MENU_ONE = ["Inside7","Inside8","Inside9","Inside4","Inside5","Inside6","Inside1","Inside2","Inside3","ALPHA","OUTSIDE","MAIN MENU"];
list MENU_TWO = ["Outside7","Outside8","Outside9","Outside4","Outside5","Outside6","Outside1","Outside2","Outside3","ALPHA","INSIDE","MAIN MENU"];
list MENU_THREE = ["Int_0.75","Int_0.50","Int_0.25","Ext_0.75","Ext_0.50","Ext_0.25","Ext_1.0","Ext_0.0","Int_0.0","Int_1.0","INSIDE","OUTSIDE"];
list items;
list tex_list;
integer item_len;

debug(string in){
if(DEBUG)llOwnerSay((string)llGetScriptName() + " Debug= " + in);
}

GetParameters(string str){
list lsdata = llParseString2List(str, ["="], [""]);
string item = llList2String(lsdata,0);
string value = llList2String(lsdata,1);
integer intvalue = (integer)value;
if ("PLACE_HOLDER" == item) {PLACE_HOLDER = (string) value;}
}

Changed(integer change){
if (change & CHANGED_INVENTORY){
// I assume, you want to re-read the inventory, when it changed - so why resetting the script?
// you should use your loop() to do so...
loop();
//llResetScript();
}
else if (change & CHANGED_OWNER){
llResetScript();
}
}

// I don't really get the purpose of this function. All you do is reading the textures from
// your inventory but then, you only take the first eight into your list - why?
// Plus: everytime you call this function, your item's list will grow
// this will sooner or later produce a stack-heap collision

loop(){

items = []; //empty the item-list, since we're rebuilding it

integer i;
//integer totalDetected = llGetInventoryNumber(INVENTORY_TEXTURE) + 1; // Why are you adding 1 here, just to subtract it in the for-statement???

integer totalDetected = llGetInventoryNumber(INVENTORY_TEXTURE);

//for (i = 0; i < totalDetected - 1; i++){
for (i = 0; i < totalDetected; i++){
string tex_name = llGetInventoryName(INVENTORY_TEXTURE,i);
//items += tex_name; did this ever work? correct would be:
items += [tex_name]; // You need the square brackets to add something to a list
}
item_len = llGetListLength(items) - 1;
tex_list = llList2List(items,0,8 );
return;
}

parse_message(string message){
//loop(); // You only need to call the loop to build up the item's list, when the inventory changed
string number = llGetSubString(message, -1, -1);

// The following will most likely produce an error since you can't put a key into a string without typecasting

//string texkey = llGetInventoryKey(llList2String(tex_list,(integer) number - 1)); // You had -1 here - always add spaces when you want to subtract

string texkey = (string)llGetInventoryKey(llList2String(tex_list,(integer) number - 1));

llMessageLinked(LINK_ALL_OTHERS,0,message+"|"+texkey,NULL_KEY);
llSay(DATA_CHANNEL01,"set_all"+"|"+message+"|"+texkey);
debug((string) message+texkey);
// llListenRemove(listen_handle);
//return;
}

default{
state_entry(){
state ReadConfig;
}
on_rez (integer change){
Changed(change);
}
changed(integer change){
Changed(change) ;
}
}

state Running{
state_entry(){
//CHANNEL = -41255555; channel is defined in the global scope - no need to define it again!
//listen_handle = llListen(CHANNEL, "",gCurKey, ""); // gCurKey isn't defined at this time - so the listener will listen to NULL_KEY, a.k.a. everybody
// I assume, you want it to listen to the owner only, so use llGetOwner() instead
listen_handle = llListen(CHANNEL, "",llGetOwner(), "");
debug((string)llGetFreeMemory());
}

listen(integer CHANNEL, string name, key id, string message){
if (llListFindList(MENU_ONE + MENU_TWO + MENU_THREE , [message]) != -1){

//you obviously want to debug what the message was - so do it once - not in every else-if-statement

debug(message); // 'message' is always a string no need to typecast...

if (message == "INSIDE"){
llDialog(id, "Set the INSIDE Texture", MENU_ONE, CHANNEL);
//llSetTimerEvent(30.0);
}else if (message == "OUTSIDE"){
llDialog(id, "Set the EXTERIOR Texture", MENU_TWO, CHANNEL);
//llSetTimerEvent(30.0);
}else if (message == "ALPHA"){
llDialog(id, "Set the Percentage of ALPHA." , MENU_THREE, CHANNEL);
//llSetTimerEvent(30.0);
}else if (message == "MAIN MENU"){ // Here, you didn't use curly brackets - either use them or not
llMessageLinked(LINK_THIS, 0,"MAIN_MENU",NULL_KEY);
}else if (llGetSubString(message,0,5) == "Inside"){
parse_message(message);
}else if (llGetSubString(message,0,6) == "Outside"){
parse_message(message);
}else if (llGetSubString(message,0,3) =="Int_"){
llMessageLinked(LINK_ALL_OTHERS,0,message,NULL_KEY );
llSay(DATA_CHANNEL01,message);
}else if (llGetSubString(message,0,3) =="Ext_"){
llMessageLinked(LINK_ALL_OTHERS,0,message,NULL_KEY );
llSay(DATA_CHANNEL01,message);
}
}
}

link_message(integer sender, integer num, string str, key gCurKey){
if (str == "reset_script")
llResetScript();

if (str=="MENU_1"){
// CHANNEL = -41255555;
// listen_handle = llListen(CHANNEL, "",gCurKey, "");
llDialog(gCurKey, "Set the INTERIOR Texture", MENU_ONE, CHANNEL);
//llSetTimerEvent(30);
}else if (str=="MENU_2"){
llDialog(gCurKey, "Set the EXTERIOR Texture", MENU_TWO, CHANNEL);
//llSetTimerEvent(30);
}else if (str=="MENU_3"){
llDialog(gCurKey, "Set the Percentage of ALPHA.", MENU_THREE, CHANNEL);
//llSetTimerEvent(30);
}
}

// ****************************************
// Here comes your main error. Once the timer fires, your listener is removed
// and then is never set up again. So don't remove it
// That's why I commented the llSetTimerEvent-statements above
// ****************************************

timer(){
llListenRemove(listen_handle);
llSetTimerEvent(0);
debug("timer gone off");
}
changed(integer change){
Changed(change);
}
on_rez(integer change){
Changed(change);
}
}

state ReadConfig{
state_entry(){
lineCounter = 0;
integer itemtype = llGetInventoryType(s_notecard);
if(INVENTORY_NOTECARD == itemtype){
kQuery = llGetNotecardLine(s_notecard, lineCounter);
//llSetTimerEvent(30); // Why do you set a timer for this??? A notecard-reading usually doesn't time out
}else{
llOwnerSay("Error - configuration notecard missing, Using defaults only!");
state Running;
}
}

dataserver( key s_query_id, string sdata ){
if(s_query_id == kQuery){
if (sdata != EOF){

if(llStringLength(sdata) > 3){
GetParameters(sdata);
}

lineCounter++;
kQuery = llGetNotecardLine( s_notecard, lineCounter );
}else{
//llSetTimerEvent(0);
state Running;
}
}
}

timer(){
llListenRemove(listen_handle);
// llOwnerSay("ERROR - Dataserver time out! aborting");
llSetTimerEvent(0);
state Running;
}

// Correct me if I'm wrong, but the following two events don't really make sense here

on_rez(integer num){
llResetScript();
}

changed(integer change){
Changed(change) ;
}
}
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
08-24-2008 19:36
Thank you very much for your input, comments and help Haruki.

As you see, I have no idea what I'm doing. It's taken me months to make this shitty code and it's far worse than I imagined. No wonder it don't work properly.
I'll try to learn from this but I don't have much faith that I can complete this set of scripts before the next olympics.

But I can do hovertext! I think?

*wanders off, head down, kicking the ground. muttering "Thanks for your help people, sorry to bother you" and climbs back under his rock*
_____________________
SCOPE Homes, Bangu
-----------------------------------------------------------------
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-24-2008 20:37
Never say never Kornscope. My first big script here took me a month and I became extremely frustrated. I actually came so close to stopping a couple of times and my head was hurting and spinning most of the time. Just so much information to absorb, it felt nearly impossible, but then something happened; parts of the script slowly started to resolve into clarity. Slowly more and more came into focus and eventually it all came together. The feeling when it worked was simply indescribable. That script I still use and it still works well.

For all new scripters and no matter what language, I feel everyone probably has to pass through this babtism by fire at some point or another. Before this you are just playing and tweaking scripts, afterwards, even though you still have a lot to learn, you can begin to think of yourself as a scripter.

Starting with that first real script I have had so many moments of utter joy now. To feel your mind grow and expand and to realize that if you can learn something so complex, you can truly learn anything is wonderful. I must say that it is doubly so if you are no longer of the young crowd as I am :)

Now with these lessons learned I have started learning new languages and now have three programs that both myself and others use in the office to make our life easier. It all started with "Hello World".
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum