Jump to content

Listen through List array?


Syngravez
 Share

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

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

Recommended Posts

Hey forum!,

Was having a little go at trying to listen through a List array to get an result and stubbled upon a confusion and kinda met a dead end.
So I wanted to seek advice on how to make a object listen through a list array would be grately helpful!


For example:
This is the list was to be listened to and give a function.

list Testing =["Material1","Material2","Material3"]:


So basically if I gave the object a listener and tried to listen to those titles it will only just output those titles.
The reason why I'm trying to listen to these is that in trying to script up an material page setup, basically has 3 pages so 3 functions but when one of those "List titles" are selected via touch it will give out a function.

So far bee at this for a couple of days now and haven't gotten pretty far and regards to my rusty lsl scripting language.

If anyone can hell me.out on this one that would be great and would help others who need this type of work as well!


Thanks, Syn

Link to comment
Share on other sites

 

llListen(gMyChannel,"","","");...listen(integer(channel, string name, key id, string message){    integer idx = llListFindList(["Material1","Material2","Material3"],[message]);    if (!~idx)    {        //Not a relevant message    }    else if (idx == 0)    {        // Do Material1 stuff    }    else if ( idx == 1)    {        // Do Material 2 stuff    }    else    {        // Do Material3 stuff    }}

 

 

  • Like 1
Link to comment
Share on other sites

you can assign a string to it like so....

list Testing = ["Material1","Material2","Material3"]; string Material;init(){  llListen(0,"","","");   }default{    state_entry()    {  init();    }    on_rez(integer param)    { init();    }    listen(integer channel, string name, key id, string message)
   {     
     if( Material  = llList2String( Testing, llListFindList(Testing,[message])  )  )
       {  //Material is now set to the message
       }
   }}
  • Like 1
Link to comment
Share on other sites

That's sort of a logical impossibility.  After all, the script has to be listening already to hear your chat prompt.  However, you can open a channel with any other trigger you like.  Put your llListen into a collision* or sensor* or touch* event, or just leave it open all the time (unless you have committed the faux pas of opening a llListen on the PUBLIC_CHANNEL.  Never do that for more than the very short period when you actually need it.  Even better, find a way to use some other channel.)

Link to comment
Share on other sites

[in Reply to Xiija]

Well what i mean is i need to send a "Message link" to these for example:

llMessageLinked(LINK_SET,123, "Material1", llGetOwner());

 

Instead of typing i would need to some how make them communicate with each other.  This is a for a HUD that i've made/scripted and this would for the important part of it.

[in Reply to Rolig Loon]

That's the problem i can't have anyone type or be listening to this as it would be in a HUD so only i can llFrand the channel that it's on.

Link to comment
Share on other sites

It's doesn't work that way to be fair , doesn't work via dialog only through llLinked_Message on random channel.

Works like a charm but this is what i need most to complete it as i can add as many "Material Pages" as i need , it's a very complex hud as it is but also scripted it to be "no lag" respondable.

Link to comment
Share on other sites

in your hud:

 list Testing = ["Material1","Material2","Material3"];
string Material;
init()
{  llListen(-333,"","","");   // dialog channel
}
default
{
    state_entry()
    {  init();
    }
    on_rez(integer param)
    { init();
    }
   touch_start(integer num)
   { llDialog(llGetOwner(), "\nChose a Material", Testing , -333);
   }
    listen(integer channel, string name, key id, string message)
   {     
     if( Material  = llList2String( Testing, llListFindList(Testing,[message])  )  )
       {  llRegionSay(-222,Material);
       }
   }
}

in your object that is going to be textured:

init()
{  llListen(-222,"","","");   // listen to incomming regionsay channel
}
default
{
    state_entry()
    {  init();
    }
    on_rez(integer param)
    { init();
    }  
    listen(integer channel, string name, key id, string message)
   {  llMessageLinked(LINK_SET,123, message, llGetOwner());
   }
   link_message(integer sender_num, integer num, string msg, key id)
   {  llSetLinkTexture(LINK_SET,msg, ALL_SIDES);
   }
}

Link to comment
Share on other sites

This is deffinitly helping, well making it out!

 

Is there anyway of not having the dialog in there ? but only touch only that goes through that list and then send the llMessageLink out to the "Receiver" ?

 

I'll set an example of what i'm using currently:

Link 3 objects together and set 1 prim to the left and one to the right and the main one in the middle.

 

Be sure to set the objects name to the prim touches.

MainPrim: _Main_

LeftPrim: _LeftPage_

Right: _RightPage_

 

Main Script

 

key owner;string data;string info;integer i;integer LH;integer Core;string DoStuff(string name){ integer num = llDetectedLinkNumber(0);string comp = llGetLinkName(num);if(comp == "_Main_"){llSay(0, "This is the main");llMessageLinked(LINK_SET,123,"♠ExampleSelected♠",llGetOwner());}if(comp == "_LeftPage_"){llSay(0, "This is the Left Page");llMessageLinked(LINK_SET,123,"♠LeftSelected♠",llGetOwner());}if(comp == "_RightPage_"){llSay(0, "This is the Right Page");llMessageLinked(LINK_SET,123,"♠RightSelected♠",llGetOwner());}return data;}default{state_entry(){owner = llGetOwner();Core = llRound(llFrand(10000000)) + 10;LH = llListen(Core, "",owner,"");llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);llSetTimerEvent(.01);}run_time_permissions(integer perms){llTakeControls(CONTROL_FWD,TRUE,TRUE);}attach(key attached){if(attached == llGetOwner()){llResetScript();}}changed(integer ch){if(ch & CHANGED_INVENTORY){llResetScript();}}touch_start(integer b){if(llDetectedKey(0)){integer num = llDetectedLinkNumber(0);string comp = llGetLinkName(num);info = llGetLinkName(llDetectedLinkNumber(i)) +DoStuff(info);}}timer(){if(llGetFreeMemory() < 100){llInstantMessage(llGetOwner(), "/me is running low on available memory, script is resetting in 5 seconds.");llSleep(5);llResetScript();}}}

 

This is what i'm having trouble with i would need it to go through that list of  "Material1" , "Material2", "Material3" if the left or right side is clicked/touched. But if the the left or right side is click i would need it to check if "Material1" selected then do the function from there.

Link to comment
Share on other sites

few changes mebbe?

 

key owner;
string data;
string info;
integer i;
integer LH;
integer Core;

 DoStuff(string page)
{

    if(page == "_Main_")
    {
    llSay(0, "This is the main");
    llMessageLinked(LINK_SET,123,"♠ExampleSelected♠",llGetOwner());
    }

    if(page == "_LeftPage_")
    {
    llSay(0, "This is the Left Page");
    llMessageLinked(LINK_SET,123,"♠LeftSelected♠",llGetOwner());
    }
    if(page == "_RightPage_")
    {
    llSay(0, "This is the Right Page");
    llMessageLinked(LINK_SET,123,"♠RightSelected♠",llGetOwner());
    }

}


default
{
state_entry()
{
owner = llGetOwner();
Core = llRound(llFrand(10000000)) + 10;
LH = llListen(Core, "",owner,"");
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS);
llSetTimerEvent(.01);
}

run_time_permissions(integer perms)
{
llTakeControls(CONTROL_FWD,TRUE,TRUE);
}

attach(key attached){
if(attached == llGetOwner())
{
llResetScript();
}}

changed(integer ch)
{
if(ch & CHANGED_INVENTORY)
{
llResetScript();
}}

touch_start(integer b)
{
    integer num = llDetectedLinkNumber(0);
    string comp = llGetLinkName(num);
    DoStuff(comp);
   
}

timer()
{
if(llGetFreeMemory() < 100){
llInstantMessage(llGetOwner(), "/me is running low on available memory, script is resetting in 5 seconds.");
llSleep(5);
llResetScript();
}}}

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3286 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...