Suki Hirano Posted July 19, 2015 Share Posted July 19, 2015 How do I get a script to listen to more than 1 channel? I have an object that has 2 scripts itself, as well as a HUD that sends it messages. I'd like the main script of the object to listen to both message sent by the HUD (channel_dialog1) and the secondary script in itself (channel_dialog2):integer channel_dialog1 = 1 + (integer)("0x" + llGetSubString((string)llGetOwner(), -8, -1)); integer channel_dialog2 = 2 + (integer)("0x" + llGetSubString((string)llGetOwner(), -8, -1)); llListen(channel_dialog1, "", NULL_KEY, ""); llListen(channel_dialog2, "", NULL_KEY, ""); ... ... listen(integer chan, string name, key id, string msg) { if (chan == channel_dialog2) { //do stuff } else if (chan == channel_dialog1) { // do stuffBut channel_dialog1 and channel_dialog2 are not defined within the listen function, how would I go about doing this? Link to comment Share on other sites More sharing options...
Rolig Loon Posted July 19, 2015 Share Posted July 19, 2015 You've done it. At least, you're very close. Make the two channel variables global and then assign values to them the way that you have, but do it in the state_entry event, where you also need to put the two llListen functions. That will open your two channels and make the values available in the listen event for your two if tests. The only improvement I might suggest is to change "0x" to "0xF" so that the resulting channel number is negative. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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