Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Problem with my script using llDialog

Domo Kungfu
Registered User
Join date: 20 Aug 2007
Posts: 6
08-22-2007 01:22
Hello experts,

I'm having a really hard time figuring this one out. I'm trying to get this below script to show more than 12 people in the dialog box. I suppose the script would have to temp remove one of the people on the list and put a "MORE" or "NEXT" button in there that when clicked would take me to a sub menu with the rest of the detected AV's.

The script as it is works flawlessly but I'm really having problems figuring out how to do this and I'm hoping one of you can help me out. I've searched through the forums and found a few leads on how this is accomplished but I really don't quite understand how to implement this into the script.

Anyhow here is the script, any help on this will be greatly appreciated :)

string app = "tba ";
string ver = "1.0b"; // b is for beta!
string cred= "tba";

integer DEBUG_FLAG = TRUE; // let's keep some debugging on for the time being.
DEBUG(list foo) { if(DEBUG_FLAG) llOwnerSay(llList2CSV(foo)) ; }

float GI_RANGE = 300.0; // 96.0 is the range cap as of now but let's account for the future :)

integer GI_SELECT_AV_HANDLE;
integer GI_SELECT_AV_CHANNEL = -636;

list GL_AV_NAME = [];
list GL_AV_KEY = [];

integer fn_check_owner(key id)
{
if ( id != llGetOwner() )
{
return FALSE;
}
else
{
return TRUE;
}
}

integer isNameOnList( string name )
{
integer len = llGetListLength( GL_AV_NAME );
integer i;
for( i = 0; i < len; i++ )
{
if( llList2String(GL_AV_NAME, i) == name )
{
return TRUE;
}
}
return FALSE;
}

fn_easyDialog( key id, string message, list buttons, integer channel )
{
GI_SELECT_AV_HANDLE = llListen(channel, "", id, "";);

llDialog( id, message, fn_validateLength(buttons), channel);
}

list fn_validateLength( list foo)
{
integer li_return_length = 12;
if( llGetListLength(foo) > li_return_length)
{
return llDeleteSubList( foo, 12, -1);
}
return foo;
}

default
{
state_entry() {
}

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

if(id == llGetOwner()) {
if(channel == GI_SELECT_AV_CHANNEL){
integer index_av = llListFindList( GL_AV_NAME, [message] );

if (index_av != -1) {
key av_key = llList2Key( GL_AV_KEY, index_av);

DEBUG(["av key is", av_key]);
}
else {
DEBUG(["Oops! Key not found. Strange..."]);
}
}
}
}

on_rez(integer num) {
llOwnerSay( "Welcome to: " + app + ver + " by " + cred + "." );
llResetScript();
}

sensor(integer num_detected) {
integer i;
list d;
GL_AV_NAME = [];
GL_AV_KEY = [];
for (i = 0; i< num_detected; i++) {

if( isNameOnList( llDetectedName(i) ) == FALSE )
{
GL_AV_NAME += [ llDetectedName(i)] ;
GL_AV_KEY += [ llDetectedKey(i) ] ;
}
}
fn_easyDialog( llGetOwner(), "Pick an AV:", fn_validateLength(d), GI_SELECT_AV_CHANNEL);
}

no_sensor() {
GL_AV_NAME = [];
GL_AV_KEY = [];
llOwnerSay( "No av's within range, exiting." );
}

touch_start(integer num) {
if( fn_check_owner(llDetectedKey(0) ) ) {
llSensor( "", NULL_KEY, AGENT, GI_RANGE, TWO_PI );
}
}
}
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
08-22-2007 01:51
you'd have to modify:

n_easyDialog( key id, string message, list buttons, integer channel )
{
GI_SELECT_AV_HANDLE = llListen(channel, "", id, "";);

llDialog( id, message, fn_validateLength(buttons), channel);
}

to be a function that provides what you need. You'd have to remove all the fn_validateLength calls to pass in the full size list, then keep track of what page the user is on and display the appropriate section of the list in the menu (along with your forward and back buttons). It can be done, I think I wrote a function that does just that for one of my devices.
Domo Kungfu
Registered User
Join date: 20 Aug 2007
Posts: 6
08-22-2007 02:44
Yeah shadow I was thinking the same thing, I just don't know how to go about implementing that.
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
Avatar Key Reader
08-26-2007 00:53
Here you go, this version will break the list up into pages and clip the names to 12 characters.

CODE

// script for reading the keys of chosen nearby avatars

string app = "tba ";
string ver = "1.0b"; // b is for beta!
string cred= "tba";

integer DEBUG_FLAG = TRUE; // let's keep some debugging on for the time being.
DEBUG(list foo) { if(DEBUG_FLAG) llOwnerSay(llList2CSV(foo)) ; }

float GI_RANGE = 300.0; // 96.0 is the range cap as of now but let's account for the future :)

integer GI_SELECT_AV_HANDLE;
integer GI_SELECT_AV_CHANNEL = -636;

list GL_AV_NAME = [];
list GL_AV_KEY = [];


integer fn_check_owner(key id)
{
return id == llGetOwner();
}

integer MAX_BUTTONS = 12;
integer MAX_STRLEN = 12;
integer list_index = 0;
integer indexOnList( string name )
{
return llListFindList(fn_getButtons(GL_AV_NAME, list_index), [name]);
}

fn_easyDialog( key id, string message, list buttons, integer channel )
{
GI_SELECT_AV_HANDLE = llListen(channel, "", id, "");
llDialog( id, message, buttons, channel);
}

list fn_getButtons(list foo, integer index)
{
integer start = index;
integer end = start + MAX_BUTTONS - 1; // subtract 1 for index of last item

integer len = llGetListLength(foo);
list result = [];

if (len > MAX_BUTTONS)
result = ["More"] + llList2List(foo, start, end - 1); // subtract 1 for Menu button
else
result = llList2List(foo, start, end);

integer i = llGetListLength(result);
while (i--)
{
result = llListReplaceList(result, [llGetSubString(llList2String(result, i), 0, 11)], i, i);
}
return result;
}

default
{
state_entry() {
}

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

if(id == llGetOwner()) {
if(channel == GI_SELECT_AV_CHANNEL){
integer index_av = indexOnList( message );

if (index_av >= 0) {
if (message == "More")
{
integer len = llGetListLength(GL_AV_NAME);
list_index = (list_index + 11);
if (list_index > len)
list_index = 0;
fn_easyDialog( llGetOwner(), "Pick an AV:", fn_getButtons(GL_AV_NAME, list_index), GI_SELECT_AV_CHANNEL);
}
else // is an av name
{
key av_key = llList2Key( GL_AV_KEY, index_av);

DEBUG(["av key is", av_key]);
}
}
else {
DEBUG(["Oops! Key not found. Strange..."]);
}
}
}
}

on_rez(integer num) {
llOwnerSay( "Welcome to: " + app + ver + " by " + cred + "." );
llResetScript();
}

sensor(integer num_detected) {
integer i;
GL_AV_NAME = [];
GL_AV_KEY = [];
for (i = 0; i< num_detected; i++) {
GL_AV_NAME += [ llDetectedName(i)] ;
GL_AV_KEY += [ llDetectedKey(i) ] ;
}
fn_easyDialog( llGetOwner(), "Pick an AV:", fn_getButtons(GL_AV_NAME, list_index), GI_SELECT_AV_CHANNEL);
}

no_sensor() {
GL_AV_NAME = [];
GL_AV_KEY = [];
llOwnerSay( "No av's within range, exiting." );
}

touch_start(integer num) {
if( fn_check_owner(llDetectedKey(0) ) ) {
llSensor( "", NULL_KEY, AGENT, GI_RANGE, TWO_PI );
}
}
}
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-26-2007 06:09
" WARN:: ( 25, 1): variable `MAX_STRLEN' declared but never used." :)
_____________________
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
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
08-26-2007 08:21
quite right, change the line:

result = llListReplaceList(result, [llGetSubString(llList2String(result, i), 0, 11)], i, i);

to read


result = llListReplaceList(result, [llGetSubString(llList2String(result, i), 0, MAX_STRLEN - 1)], i, i);