Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

need help with variable listen call

patmamu Sandalwood
Registered User
Join date: 1 Dec 2008
Posts: 19
10-01-2009 20:27
Code Snippet:

state game
{
state_entry()
{
string player = llKey2Name(llDetectedKey());
lllisten(1161983, "", NULL_KEY, "pass" + player);




Basically I have person click on object in previous state.
Then I want the next state to listen for pass plus the av name that clicked on it in previous state.
Not sure if this is possible though as I don't know
a= if the name that clicked on it transfers through state change
b= how to set up the listen call to listen for the phrase pass plus the av name that clicked on it.

I still am having a hard time working with variables which I think is the problem here.
Right now I am getting Name Not defined in scope for player. Also don't know if the code the way it is set up will work anyway.
I also tried but it was no joy:

string player = "";

state default
{
touch_start(int num)
{
player = llDetectedName(0);

state game
{
state_entry()
{
lllisten(1161983, "", NULL_KEY, "pass" + player);

The overall goal of script is this in case there is a better way I haven't tried yet.
Person clicks on a board. The board loads player picture (default script from lsl wiki) then switches to state game. In state game the board listens for the call pass + av name (sent by a checkpoint) to advance a score counter in its child. When time is up or board touched script resets for next player to register. Any help that could be provided would be appreciated. Also as I have been knee deep in code all day Im going to sign off for tonight and check back tomorrow so there is no rush. Thanks in advance
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
10-01-2009 22:01
You are missing closing }

CODE

string player = "";

state default
{
touch_start(int num)
{
player = llDetectedName(0);
state game;
}
}

state game
{
state_entry()
{
llListen(1161983, "", NULL_KEY, "pass" + player);
}
//you need to add listen event and other stuff

}

patmamu Sandalwood
Registered User
Join date: 1 Dec 2008
Posts: 19
h
10-02-2009 09:59
still not working and forums broke
Ravanne Sullivan
Pole Dancer Extraordinair
Join date: 10 Dec 2005
Posts: 674
10-02-2009 10:26
From: patmamu Sandalwood
Code Snippet:

state game
{
state_entry()
{
string player = llKey2Name(llDetectedKey());
lllisten(1161983, "", NULL_KEY, "pass" + player);




When you changed states to state game you lost the llDetectedKey(0) from the previous state. In the touch event in the previous state you need to assign the llDetectedKey(0) to a global variable before the state change.
_____________________
Ravanne's Dance Poles and Animations

Available at my Superstore and Showroom on Insula de Somni
http://slurl.com/secondlife/Insula de Somni/94/194/27/
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
10-02-2009 10:50
The more complete script in the OP's post (or at least the version that Destiny cleaned up) does have "player" defined as a global variable. It's being passed in a funny way, though. Unless I'm mistaken you can't get away with a llListen filter that looks like this ...

llListen(1161983, "", NULL_KEY, "pass" + player);

but you don't need to either. Just filter for the message "pass" and then go ahead and use the global variable "player" in state game. It's already loaded in state default, so you can use it in an if test in a listen event or wherever you need to filter for data specific to the person who clicked the object.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Destiny Niles
Registered User
Join date: 23 Aug 2006
Posts: 949
10-02-2009 11:08
Maybe the passing object is not sending the right message?

Here's another cleanup with a debug lines added in the listen event.

CODE

string player = "";

default
{
touch_start(integer num)
{
player = llDetectedName(0);
state game;
}
}

state game
{
state_entry()
{
llListen(1161983, "", NULL_KEY, "pass" + player);
}
listen(integer channel, string name, key id, string message)
{
llWhisper(0, "heard pass message");
}

//you need to add listen event and other stuff

}

uj