Jump to content
Sign in to follow this  
MannyRD

Problems with channels

Recommended Posts

 

Hello friends, I'm new to programming scripts. My project is to create a boat. It has been easier to write the script separately for the lights, the horn, the ignition, movement of the helix, in short, several scripts. The problem is that I want to activate them by command but, in all, I used channel 0, using the function llListen, however, by putting all the scripts in their respective prims inside my boat, it seems that the instructions are mixed making several scripts respond simultaneously, how can I make everyone listen on a different channel?

 

 

best regards.

Edited by MannyRD

Share this post


Link to post
Share on other sites

short tip: don't

instead use messages and keywords to communicate, and best let the user reset the cannel to some onther one, ideally your kewords are very specific to your boat like

"MANNYRDBOAT1 RAISE" that way your boat will not listen to other boats =^.^=

Edited by Fionalein

Share this post


Link to post
Share on other sites

Hello, Manny, and welcome to the Scripting Forum.

The answer to your question is simple.   In each of your scripts, you must already have a line reading something like

 llListen(0,"",llGetOwner(),"");  

(it may not be exactly that, but it will start with llListen(0 ).   Simply change the 0 to some other integer value (positive if you want to be able to say them in chat rather than via a HUD), with different values in each script.   Then use that channel to send commands to the particular item.  

In general, please don't have scripts listen on channel 0, the public chat channel,  unless it's absolutely necessary.    It means that every time someone on the region says something in chat, the simulator wastes resources calculating whether your scripts can hear them and, if they can, the scripts then waste further simulator resources deciding whether the messages are meant for them (which they won't be, most of the time).   It's good practice to avoid having scripts that listen on 0 unless there's a good reason to use that channel and no other.

Share this post


Link to post
Share on other sites
16 minutes ago, Fionalein said:

short tip: don't

instead use messages and keywords to communicate, and best let the user reset the cannel to some onther one, ideally your kewords are very specific to your boat like

"MANNYRDBOAT1 RAISE" that way your boat will not listen to other boats =^.^=

You still need channels, unless everything is linked messages.

Share this post


Link to post
Share on other sites
14 minutes ago, Love Zhaoying said:

You still need channels, unless everything is linked messages.

I see no need for plural there, a singular channel should suffice

PS: ah now I see the misunderstanding, no I didn't want to advice against using channels on boats, just against using more than one on each vehicle

Edited by Fionalein
  • Like 1

Share this post


Link to post
Share on other sites

Please excuse the following general suggestions, and certainly don't let them be discouraging.

It's okay to start out using listen() events like this to get some practice communicating between scripts.

Eventually, though, I think you'll find listen() is most appropriate for communicating between scripts in different objects, not so much for scripts in different prims of the same object, for which link_message() is more efficient, as Fionalein suggested.

Also as you get more practice (and especially for vehicles that might cross sim boundaries) it's a win to minimize the number of scripts, even if fewer, larger scripts get ugly and complicated. Modularity may be prettier and easier to understand, but in LSL that comes with a real cost. Hence the appeal of llSetLinkPrimitiveParamsFast() and the various other *Link*() functions. (Unfortunately there are no link functions for sound, a shortcoming that often arises with vehicles specifically.)

  • Like 2

Share this post


Link to post
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.

Sign in to follow this  

×
×
  • Create New...