Jump to content

Link # vs Link Text


Lolita Erin
 Share

Recommended Posts

Hello people, i like advise. i have from one script many message using  llMessageLinked, but i start to generate many messages to others scripts usin a number example  llMessageLinked(LINK_ROOT, 95678,"on",""); but here is my question is more recomendable use same number and direrent text or is preferable or faster us only numbers samples:

Current

llMessageLinked(LINK_ROOT, 9543678,"on",""); //ligth on
llMessageLinked(LINK_ROOT, 9543678,"off",""); //ligth on

llMessageLinked(LINK_ROOT, 9543679,"on",""); //door open
llMessageLinked(LINK_ROOT, 9543679,"off",""); //coor close

or use same number and diferennt text?

llMessageLinked(LINK_ROOT, 9543678,"lighton",""); //ligth on
llMessageLinked(LINK_ROOT, 9543678,"lightoff",""); //ligth on
llMessageLinked(LINK_ROOT, 9543678,"dooron",""); //door
llMessageLinked(LINK_ROOT, 9543678,"dooroff",""); //door

what is fastter or more recomendet consider i have many message to send from one script to another.

 

Link to comment
Share on other sites

It's much faster to compare integers than to compare strings. A message-receiving script, then, will be more efficient if it can just step through a bunch of integer-testing conditions to determine what to do in response to the message.

But I'm not sure I understand the question completely. Why are you sending the strings at all?

Link to comment
Share on other sites

Thanks Roling, i use  llSetLinkPrimitiveParamsFast the door was just and example i need to pass on / off varaibles from one script to other basicaly.

i do belive that integers are faster but when it comes to code it will be more if''s i belive i have more than 10 on / off variables that i need to pass

Link to comment
Share on other sites

Ah... good reason.  I have had to do the same with really complex vehicle scripts.  Still, you can handle all the doors, lights, and similar things from a single script and yank all of that stuff out of the vehicle script itself to reduce its memory.  Just leave the vehicle script to control the vehicle.

Link to comment
Share on other sites

Hi Lolita,

I'm sharing Rolig's and Qie's confusion over what you're trying to do. It appears that you're going to have multiple child prims in one object sending messages to the root prim, and that the root prim wants to know not only what to do (on, off.. etc) but which of several potential functions (light, door... etc) should respond.

The most computationally efficient way to pack/parse such messages is to code each function/command pair as an integer...

integer LIGHTON   = 0;integer LIGHTOFF  = 1;integer DOOROPEN  = 2;integer DOORCLOSE = 3;llMessageLinked(LINK_ROOT), LIGHTON,"","");llMessageLinked(LINK_ROOT), DOOROPEN,"","");

If you have multiples of each function (ex. DOOR1, DOOR2, DOOR3) the list will get out of hand quickly.

To manage this complexity, encode functions, commands and selectors in a way that makes it easy to parse from the message, like this...

//Functionsinteger DOOR  =    0;integer LIGHT = 1000;//Commandsinteger OFF   =    0;Integer CLOSE =    0;integer ON    =  100;integer OPEN  =  100;

Notice that OFF and CLOSE are equivalent. I do that for ease of understanding. It's not clear what turning a door off actually does. This particular coding allows you to have over 2 million functions (0-2147483000 (almost the maximum positive integer) by thousands), ten commands (0-900 by hundreds) and up to 100 instances of each function (0-99 by ones). You specify Which instance of many functions by adding an integer selector to the message...

llMessageLinked(LINK_ROOT), DOOR+1+OPEN,"",""); // open door 1llMessageLinked(LINK_ROOT), LIGHT+3+OFF,"",""); // turn off light 3

And here's how you'd parse that message in the receiving script...

//Functionsinteger DOOR  = 0000;integer LIGHT = 1000;//Commandsinteger OFF   =  000;Integer CLOSE =  000;integer ON    =  100;integer OPEN  =  100;
link_message(sender, message, str, id){ integer Function = (message/1000)*1000; // results in DOOR, LIGHT, etc integer Command = ((message-Function)/100)*100; // Results in OFF, ON, etc integer Which = message-Function-Command; // Identifies which light, door, etc (0-99) // more code}

 

This method could be made even more computationally efficient by coding the functions, commands and selectors in binary...

//Functionsinteger DOOR  = 0x00000000;integer LIGHT = 0x00001000;//Commandsinteger OFF   = 0x00000000;Integer CLOSE = 0x00000000;integer ON    = 0x00000100;integer OPEN  = 0x00000100;

This coding allows over a million functions (0x0 to 0xfffff000 by 0x1000s) and 16 commands (0x0 to 0x0f00 by 0x0100s) and 256 selectors (0x0000 to 0x00ff by 0x1s). Encoding this way is exactly as efficient as in decimal. The encoding is done as the script is compiled. The code to do that is exactly as for the decimal version above...

llMessageLinked(LINK_ROOT), DOOR+1+OPEN,"",""); // open door 1llMessageLinked(LINK_ROOT), LIGHT+3+OFF,"",""); // turn off light 3

but the parsing code is different and a little faster...

link_message(sender, message, str, id){    integer Function = message & 0xfffff000; // results in DOOR, LIGHT, etc    integer Command  = message & 0x00000f00; // results in OFF, ON, etc    integer Which    = message & 0x000000ff; // Identifies which light, door, etc    // more code}

 

Link to comment
Share on other sites

Wow Madelaine, thanks so much for your info that help me a lot to make more easy code, my problem is that my code is very big and not fit on 1 script so i have to make 3 scipts and when something change on each script i have to let the others script to know what happend or change like for example the light.

 

thank so much again great detail

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...