Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Listening Help

Nezu Garside
Custom titles are too sho
Join date: 12 Mar 2008
Posts: 40
08-08-2008 16:14
Alright, I set a second listen in my second state to return my code to the default state, but it doesn't work. Any ideas as to why?

state MuzzleOn
{
state_entry()
{
llSay(0,"State MuzzleOn Entered";);
owner = llGetOwner();
llSetTimerEvent(TimerTime);
OldStatus=0;
BasePos= (RAD_TO_DEG*llRot2Euler(llGetLocalRot()));
}
timer()
{
llListen(9,"",owner,"/9Muzzleoff";);
integer NewStatus= llGetAgentInfo(owner) & AGENT_TYPING;
if(Muzzle==TRUE)
{
if(NewStatus==AGENT_TYPING)
{
llTargetOmega(<1,1,1>,1,1);
}
if(NewStatus!=AGENT_TYPING)
{
llTargetOmega(ZERO_VECTOR,0,0);
}
}
}
listen(integer channel, string name, key id, string message)
{
params=llGetObjectDetails(owner,[OBJECT_OWNER]);
owner=llList2Key(params,0);
Muzzle=FALSE;
state default;
}
}
Talon Brown
Slacker Punk
Join date: 17 May 2006
Posts: 352
08-08-2008 18:00
Well for starters you have the string and key parameters in the listen event reversed, it should be: string str, key id. Then there's the listener command filter you are using, "/9Muzzleoff". Unless you actually expect someone to type "/9/9Muzzleoff" you need to get rid of that /9 as it will never be part of a normal listener command. Not to mention the fact that I've no idea why you even have the llListen call inside the timer event anyway as it should only be called once, usually in state_entry.
Nezu Garside
Custom titles are too sho
Join date: 12 Mar 2008
Posts: 40
08-08-2008 18:04
From: Talon Brown
Well for starters you have the string and key parameters in the listen event reversed, it should be: string str, key id. Then there's the listener command filter you are using, "/9Muzzleoff". Unless you actually expect someone to type "/9/9Muzzleoff" you need to get rid of that /9 as it will never be part of a normal listener command. Not to mention the fact that I've no idea why you even have the llListen call inside the timer event anyway as it should only be called once, usually in state_entry.


Because I didn't post my whole code, just the problem with it, secondly I've tried multiple different ways including placing the llListen inside the state_entry, thirdly the /9Muzzleoff is designed that way on purpose for my debugging style. And the code is actually executed by a HUD so I do not expect anyone to factually type anything out.
Talon Brown
Slacker Punk
Join date: 17 May 2006
Posts: 352
08-08-2008 18:07
Well if you're using a HUD to send this message why are you filtering by owner? The HUD's key isn't going to be the owner's key unless I am utterly wrong about how listeners work.
Nezu Garside
Custom titles are too sho
Join date: 12 Mar 2008
Posts: 40
08-08-2008 18:09
From: Talon Brown
Well if you're using a HUD to send this message why are you filtering by owner? The HUD's key isn't going to be the owner's key unless I am utterly wrong about how listeners work.


I could try NULL'ing the key, but honestly I have been struggling with this for over a week, so any ideas would be great plus any additional information someone may want or if someone wants to IM me in SL, I will gladly discuss it further there.
Nezu Garside
Custom titles are too sho
Join date: 12 Mar 2008
Posts: 40
08-08-2008 18:16
Thanks Talon. The idea about NULL'ing the owner fixed my problem. :D
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-08-2008 21:07
BTW, if you wait long enough without issuing the command, this script is going to complain that it has too many listens active (and I THINK maybe it freezes at that point until manual reset). I'd move the call to llListen() from the 'timer' event handler to the 'state_entry' event handler. That way you only start it ONCE before you transition into another state (and thereby clear all listens).
Beezle Warburton
=o.O=
Join date: 10 Nov 2006
Posts: 1,169
08-08-2008 21:20
From: Talon Brown
Well if you're using a HUD to send this message why are you filtering by owner? The HUD's key isn't going to be the owner's key unless I am utterly wrong about how listeners work.


Something like:

if (owner == llGetOwnerKey(id))
_____________________
Though this be madness, yet there is method in't.
-- William Shakespeare

Warburton's Whimsies:
In SL
Apez.biz