Jump to content

Whats the problem with the script?


Ninjadanana525
 Share

You are about to reply to a thread that has been inactive for 2624 days.

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

Recommended Posts

This is the script:

list listOptions = [ "picpocket", "confuse" ];
list listAvatarsSensor;
integer channelDialog ;
integer handleListener;

string choicedOption ;

string avatarNameHavingMenu;
key avatarKeyHavingMenu;
float timerDialog = 15.0;
float range = 5.0;
default
{
    touch_end(integer total_number)
    {
        avatarNameHavingMenu = llDetectedName(0);
        avatarKeyHavingMenu =llDetectedKey(0);
        state firstDialog;
    }
}
state firstDialog
{
    state_entry()
    {
        channelDialog= (integer)(llFrand(-1000000000.0) - 1000000000.0);
        handleListener = llListen(channelDialog, avatarNameHavingMenu , avatarKeyHavingMenu  , "");
        llDialog(avatarKeyHavingMenu, "Choose an option:" , listOptions, channelDialog );
        llSetTimerEvent(timerDialog);
    }
    listen( integer i, string n , key k, string m)
    {
        choicedOption = m;
        llSensor("",NULL_KEY,AGENT,range,PI);
    }
    sensor(integer n)
    {
        integer i ;
        listAvatarsSensor = [];
        do
        {
            listAvatarsSensor += llGetSubString(llDetectedName(i), 0, 23) ;
            i++;
        } while ( i < n);
        state secondDialog;
    }
    timer()
    {
        state default;
    }
    state_exit()
    {
        llListenRemove(handleListener);
        llSetTimerEvent(0.0);
    }
}
state secondDialog
{
    state_entry()
    {
        channelDialog= (integer)(llFrand(-1000000000.0) - 1000000000.0);
        handleListener = llListen(channelDialog, avatarNameHavingMenu, avatarKeyHavingMenu , "");
        llDialog( avatarKeyHavingMenu, "Choose an avatar:" , listAvatarsSensor, channelDialog );
        llSetTimerEvent(timerDialog);
    }
    listen( integer i, string n , key k, string m)
    {
    string avName;
    string origName = llGetObjectName();
    avName = llDetectedName(i);
    avName = llList2String( llParseString2List( avName, [" "], [] ), 0 );
    llSetObjectName( avName );
    string detectedName = llDetectedName(0);
    llSay(0, avName + " " + choicedOption + "ed " + m + " ");
    llSetObjectName( origName );
        state default;
    }
    timer()
    {
        state default;
    }
    state_exit()
    {
        llListenRemove(handleListener);
        llSetTimerEvent(0.0);
    }
}

 

The problem whit the results. Its said in the chat this: 

0000000000000-0000-0000-0000-000000000000 03:13

000-0000-0000-0000-000000000000 picpocketed BunnyBoyHun Resident 

The problem with the 0. Thanks for the answers and sry my english is bad >.<

Link to comment
Share on other sites

In state SecondDialog, inside the listen() event handler, you are using llDetectedName() which does not have valid info inside a listen() event (only used in sensor, touch, collision events).

 

Just use the m parameter passed into the listen() event.  It will be the text of the button that was selected in the dialog.  However, since they are limited to 22 (?) characters, you will likely have issues anyway.

 

Link to comment
Share on other sites

llFrand(-1000000000.0) is totally valid :

 

default{    state_entry()    {        integer channelDialog1 = (integer)(llFrand(-1000000000.0) - 1000000000.0);        integer channelDialog2 = (integer)(llFrand(-1000000000.0) - 1000000000.0);        llOwnerSay(llList2CSV([ channelDialog1, channelDialog2 ]));    }}

 outputs

-1384138496, -1555145472 as expected

 

There are two errors , the both are in using llDetectedName(i ) or llDetectedName(0) inside the listen event :

state secondDialog{...........    listen( integer i, string n , key k, string m)    {        string avName;        string origName = llGetObjectName();// llDetectedName(i) returns NULL_KEY// because llDetectedName doesn t run inside the"listen" event// llDetectedName  runs inside touch* , collision*, sensor event// Error ------>        avName = llDetectedName(i);
avName = llList2String( llParseString2List( avName, [" "], [] ), 0 ); llSetObjectName( avName );
// llDetectedName(0) returns NULL_KEY// because llDetectedName doesn t run inside the"listen" event// llDetectedName runs inside touch* , collision*, sensor event// Error : -------> string detectedName = llDetectedName(0); llSay(0, avName + " " + choicedOption + "ed " + m + " "); llSetObjectName( origName ); state default; }

 

 

 

I am not sure if the final message is 

the first name of the toucher has pickpocket/confused  the fist name of the menu displayed 

But the code should be closed to this :

list listOptions = [ "picpocket", "confuse" ];list listAvatarsSensor;list listAvatarsFullNameSensor;integer channelDialog ;integer handleListener;string choicedOption ;string avatarNameHavingMenu;key avatarKeyHavingMenu;float timerDialog = 15.0;float range = 5.0;// Function with// input : full name of one avatar// output : first name of this avatarstring fullName2firstName(string fullName){    return llList2String( llParseString2List( fullName, [" "], [] ), 0 );}default{    touch_end(integer total_number)    {        avatarNameHavingMenu = llDetectedName(0);        avatarKeyHavingMenu =llDetectedKey(0);        state firstDialog;    }}state firstDialog{    state_entry()    {        channelDialog= (integer)(llFrand(-1000000000.0) - 1000000000.0);        handleListener = llListen(channelDialog, avatarNameHavingMenu , avatarKeyHavingMenu  , "");        llDialog(avatarKeyHavingMenu, "Choose an option:" , listOptions, channelDialog );        llSetTimerEvent(timerDialog);    }    listen( integer i, string n , key k, string m)    {        choicedOption = m;        llSensor("",NULL_KEY,AGENT,range,PI);    }    sensor(integer n)    {        integer i ;        listAvatarsSensor = [];        listAvatarsFullNameSensor = [];        do        {            listAvatarsSensor += [ llGetSubString(llDetectedName(i), 0, 23)  ] ;            listAvatarsFullNameSensor += [ llDetectedName(i)  ] ;            i++;        } while ( i < n);        state secondDialog;    }    timer()    {        state default;    }    state_exit()    {        llListenRemove(handleListener);        llSetTimerEvent(0.0);    }}state secondDialog{    state_entry()    {        channelDialog= (integer)(llFrand(-1000000000.0) - 1000000000.0);        handleListener = llListen(channelDialog, avatarNameHavingMenu, avatarKeyHavingMenu , "");        llDialog( avatarKeyHavingMenu, "Choose an avatar:" , listAvatarsSensor, channelDialog );        llSetTimerEvent(timerDialog);    }    listen( integer i, string n , key k, string m)    {        integer index = llListFindList(listAvatarsSensor, [ m ]);        if ( index != -1 )        {            string pickpocketed = llList2String( listAvatarsFullNameSensor, index );            pickpocketed = fullName2firstName(pickpocketed);            string pickpocketer = fullName2firstName( avatarNameHavingMenu );            string origName = llGetObjectName();            llSetObjectName( pickpocketer );            llSay(0, pickpocketer + " " + choicedOption + "ed " + pickpocketed + " ");            llSetObjectName( origName );            state default;        }    }    timer()    {        state default;    }    state_exit()    {        llListenRemove(handleListener);        llSetTimerEvent(0.0);    }}

 

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2624 days.

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...