Jump to content

llDialog error more than 24 characters detected name


Mimite Klaar
 Share

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

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

Recommended Posts

Hi everyone I created a trap with selected victim menu using llDialog but obviously more than 24 characters avatar go back to script error

I just want some help with my script to not detect long avatar name 

Can you help me please ? this is the script

 

string victim;
key target;

default
{
    state_entry()
    {
        llListen(6666,"","" ,"");
    }
    on_rez(integer start_param)
    {
        vector here = llGetPos();

        llSetText("touch me", <1,0,0>, 1.0);
         llTargetOmega(<0,0,0>,0,0);
    }
     on_rez(integer start_param)
    {

        llSensor("",NULL_KEY,AGENT,512,PI);
        
    }
    no_sensor()
    {
        llSay(0,"cant find targets");
    }
    sensor(integer num)
    {
        list targets;
        integer i;
        if(num > 12)
            num = 12;
            for(i=0;i<num;i++)
        {
            targets += [llDetectedName(i)];
        }
        llDialog(llGetOwner(),"Select your target",targets,6666);
    }
    listen(integer channel, string name, key id, string message)
    {
        victim = message;
        state stalking;
    }       
}

state stalking
{
        state_entry()
        {
            llSetText("", <0,0,0>, 1.0);

                        llSensorRepeat(victim,NULL_KEY,AGENT,512,PI,0.1);
            
               }
        sensor(integer num)
        { 
            llSetPos(llDetectedPos(0)  + <0, 0, -2> );
        }
}

Link to comment
Share on other sites

If you REALLY need to use llSensor instead of llGetAgentList... try this one. Slightly optimized and potentially without the button limit crash, but you may want to make sure in a crowded place. ;)

list gNames;
list gKeys;
key gVictim;
integer gListenerHandle;

stopListener()
{
    llSetTimerEvent(0);
    llListenRemove(gListenerHandle);
}

default
{

    state_entry()
    {
        stopListener();
        llSetText("touch me", <1,0,0>, 1.0);
        llTargetOmega(<0, 0, 0>, 0, 0);
    }

    on_rez(integer start_param)
    {
        llResetScript();
    }

    no_sensor()
    {
        llOwnerSay("cant find targets");
    }

    touch_start(integer nd)
    {
        if (llDetectedKey(0) == llGetOwner())
        {
            llSensor("", NULL_KEY, AGENT, 512, PI);
        }
    }

    sensor(integer num)
    {

        integer i;
        gNames = [];
        gKeys = [];
        key ownerKey = llGetOwner();

        if (num > 12)
        {
            num = 12;
        }

        for (i = 0; i < num; i++)
        {
            gNames = gNames + llBase64ToString(llGetSubString(llStringToBase64(llDetectedName(i)), 0, 31));
            gKeys = gKeys + llDetectedKey(i);
        }

        stopListener();
        gListenerHandle = llListen(6666, "", ownerKey, "");
        llDialog(ownerKey, "Select your target", gNames, 6666);
        llSetTimerEvent(60);

    }

    timer()
    {
        stopListener();
    }

    listen(integer channel, string name, key id, string message)
    {
        stopListener();
        gVictim = llList2Key(gKeys, llListFindList(gNames, [message]));
        state stalking;
    }
   
}

state stalking
{

    state_entry()
    {
        stopListener();
        llSetText("", <0, 0, 0>, 1.0);
        llSetTimerEvent(0.1);
        llSetMemoryLimit(llGetUsedMemory() + 5120);
    }

    timer()
    {
        vector position = llList2Vector(llGetObjectDetails(gVictim, [OBJECT_POS]), 0);
        if (position != ZERO_VECTOR)
        {
            position = position + <0, 0, -2>;
            if (position.z < 4096)
            {
                llSetRegionPos(position);
            }
            integer maxAttemptsPerMove = 25;
            while (llGetPos() != position && maxAttemptsPerMove > 0)
            {
                --maxAttemptsPerMove;
                llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POSITION, position]);
            }
        }
    }

}

 

Edited by panterapolnocy
Link to comment
Share on other sites

I would also suggest a numbered list, with just numbers for the buttons.

using pantera's script, i added a third list for numbered buttons, and when creating the name list, i had it prepend the name with the number

list gNames;
list gKeys;
list gButtons;
key gVictim;
integer gListenerHandle;

stopListener()
{
    llSetTimerEvent(0);
    llListenRemove(gListenerHandle);
}

default
{

    state_entry()
    {
        stopListener();
        llSetText("touch me", <1,0,0>, 1.0);
        llTargetOmega(<0, 0, 0>, 0, 0);
    }

    on_rez(integer start_param)
    {
        llResetScript();
    }

    no_sensor()
    {
        llOwnerSay("cant find targets");
    }

    touch_start(integer nd)
    {
        if (llDetectedKey(0) == llGetOwner())
        {
            llSensor("", NULL_KEY, AGENT, 512, PI);
        }
    }

    sensor(integer num)
    {

        integer i;
        gNames = [];
        gKeys = [];
        gButtons = [];
        key ownerKey = llGetOwner();

        if (num > 12)
        {
            num = 12;
        }

        for (i = 0; i < num; i++)
        {
            gNames = gNames + [(string)i + ": " +llBase64ToString(llGetSubString(llStringToBase64(llDetectedName(i)), 0, 31))];
            gKeys = gKeys + llDetectedKey(i);
            gButtons = gButtons + [(string)(i+1)];
        }

        stopListener();
        gListenerHandle = llListen(6666, "", ownerKey, "");
        llDialog(ownerKey, llDumpList2String(["Select your target"]+gNames,"\n"), gButtons, 6666);
        llSetTimerEvent(60);

    }

    timer()
    {
        stopListener();
    }

    listen(integer channel, string name, key id, string message)
    {
        stopListener();
        gVictim = llList2Key(gKeys, (integer)message-1);
        state stalking;
    }
   
}

state stalking
{

    state_entry()
    {
        stopListener();
        llSetText("", <0, 0, 0>, 1.0);
        llSetTimerEvent(0.1);
        llSetMemoryLimit(llGetUsedMemory() + 5120);
    }

    timer()
    {
        vector position = llList2Vector(llGetObjectDetails(gVictim, [OBJECT_POS]), 0);
        if (position != ZERO_VECTOR)
        {
            position = position + <0, 0, -2>;
            if (position.z < 4096)
            {
                llSetRegionPos(position);
            }
            integer maxAttemptsPerMove = 25;
            while (llGetPos() != position && maxAttemptsPerMove > 0)
            {
                --maxAttemptsPerMove;
                llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POSITION, position]);
            }
        }
    }

}

 

  • Like 1
Link to comment
Share on other sites

@Ruthven With numbered or lettered buttons you can also substring the names to longer values or you can substring the entire header to the max that llDialog() allows.

Also, you can statistically save header bytes by parsing the " Resident" surname off llDetectedName() returns.

Link to comment
Share on other sites

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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...