|
Everett Streeter
Registered User
Join date: 28 Apr 2007
Posts: 20
|
04-01-2008 13:19
Ok, so this is a little simplified to make it easier, but here is the gist of my question. Let's say I have a radio and tv script all in one script and it works fine, but sometimes I get errors noting that the script is full/too long. So I want to break it into two scripts. So I create a main script that is simple and just asks "radio" or "tv" with a drop-down menu. How do I then direct it to the right script to run. Is there a line of code that once you select a variable from a drop-down box, it will then take you to a specific script in a single prim? As always, many, many thanks for the help in advance.
Everett
|
|
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
|
04-01-2008 14:19
You'd have to send a link message to the prim. All the scripts in the prim will hear that message, so the message contents will have to indicate that you only want one of the scripts to act on it. The other script will then receive the message, check it, and ignore it.
Look up link messages on the Wiki to learn more about them.
So for example, let's say you use 0 for radio and 1 for TV. So something like:
Master script does:
llMessageLinked(LINK_THIS, 0, "some command", NULL_KEY); // A command meant for the radio llMessageLinked(LINK_THIS, 1, "some command", NULL_KEY); // A command meant for the TV
Radio script:
link_message(integer sender, integer num, string str, key id) { if (num != 0) { // Not for me; return; }
... }
TV script:
link_message(integer sender, integer num, string str, key id) { if (num != 1) { // Not for me; return; }
... }
|
|
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
|
04-01-2008 14:25
Your drop-dowm menu (llDialog) will say the word 'radio' or 'tv' on its assigned channel.
Any script listening on that channel can hear the words - and I mean *any* script. So, assuming both of your scripts are listening on the correct channel then they can respond to the command coming from the menu.
The unintuitive bit here is that those blue dialog menus aren't tied to any script. They simply act as a proxy to the agent who clicks their buttons and repeat (on behalf of the agent) whatever is assigned to the button.
Your other scripts simply need to respond as if you were typing, for example, '/1 radio' or '/1 tv'
[Edit: Heh, or, as Ziggy describes, the main script can itself listen to the menu dialog and relay the commands via llMessageLinked to the other scripts - this assumes all the scripts are in the same linkset. Something has to listen to the menu dialog though!]
|