Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Listen/Channel-changing script--I'm stumped...

Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
04-01-2006 17:56
I have the following script (the post is the ENTIRE script, not a portion of it):

CODE

integer channel = 99;
integer handle;

string rezindex;

default
{
state_entry()
{
llListenRemove(handle);
handle = llListen(channel, "", llGetOwner(), "");
}

on_rez(integer params)
{
llListenRemove(handle);
handle = llListen(channel, "", llGetOwner(), "");
}

touch_start(integer number)
{
llSay(0,(string)channel); //(for debugging only)
llSay(channel, (string)llGetOwner() + ",rezz " + rezindex);
}
link_message(integer sender, integer num, string str, key id)
{
rezindex = str;
}

listen(integer channel, string name, key id, string message)
{
string command = llGetSubString(message, 0, 6);

if(command == "channel")
{
integer _chan = (integer)llGetSubString(message, 8, -1);
channel = _chan;
llListenRemove(handle);
llSay(0, (string)channel); //for debugging only
handle = llListen(channel, "", llGetOwner(), "");
llInstantMessage(id, "Channel successfully changed to: " + (string)channel);
}
}
}


When I give it a channel command, I get:

Scripted Object: 80
(additional debugging listener): Object: Kenn Nilsson has said channel 80 on channel 99
Scripted Object: Channel successfully changed to: 80

When I touch the prim, I get:

Scripted Object: 99
Object: Object: Scripted Object has said (my avatar key),rezz on channel 99



In other words...I could SWEAR I'm changing the listen channel variable...but...apparently I'm not???
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
04-01-2006 18:06
From: Kenn Nilsson
link_message(integer sender, integer num, string str, key id)
{
rezindex = str;
}
Where is your MessageLinked function?
_____________________
:) Seagel Neville :)
Doc Herrey
DH Graphics
Join date: 30 Nov 2005
Posts: 21
04-01-2006 18:33
This could sound quite trivial and simple, but what about changing states upon the channel command said via chat.

Change your channel global, and enter a new state.
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
04-01-2006 18:40
Seagel--I am not messaging from this script to another linked part...therefore, no need for the function.

Doc--I've thought about that. It'll probably be worth a try.

Anyone with other ideas?
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
04-01-2006 19:12
Aha, sorry, I didn't look carefully at all. :o
Change the global channel name, such as "CHANNEL", or "chan". It collides with "listen(integer channel, string name, key id, string message)".

[EDIT] aww. Doc had already told? :o
_____________________
:) Seagel Neville :)
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
04-01-2006 19:57
Oh wow...it does...haha! Thanks.
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
04-01-2006 20:01
What Seagel said. You have a global variable called 'channel', and your listen handler has a function parameter called 'channel'. This shadows the global, so when you do "channel = _chan", it's the local 'channel' being set, not the global.

Some people name global variables in a specific way, to reduce the chance of this happening. So, for instance, you could call the global gChannel (and name all global variables the same way). That way, you have a different name, and anywhere you see it in the script, you automatically know it's a global just from the name, you don't have to search to find out if it's a local or global variable.