Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Dialog menu ok, won't return values though

Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
08-24-2007 00:30
Thank you to everyone who helped me get this going, I went and added another feature that I ALSO can't seem to get working. I am feeling a bit on the frustrated and stupid side right now... I feel like I am learning things, and better ways to format my code, but lately it seems like I am losing my way... sorry to keep bugging everyone...

Here is the new code and information:

integer listPos; // Just to be sure I wasn't mising something... all main variables are now global.
vector targetPos;
integer channel = -10;
list avatarsDetected = [ ];
list keysDetected = [ ];
list posDetected = [ ];
string Gname;
string tool;
integer nextStep;
string nextAvatarName;
string nextAvatarKey;
vector nextAvatarPos;

string menuText = "Select the person to receive surprise coupon!!";

useKey(key targetKey)
{
//Just wanted to check my data, and lo and behold.. no targetPos...
llSay(0,(string)targetKey); //Returns valid key
llSay(0,(string)targetPos); //Returns <0,0,0> everytime no matter who you pick
llSay(0,(string)listPos); //Returns position in list (as far as I can tell it must be right since name and key match
llSay(0,Gname); //Returns correct name when clicked on Dialog Menu
//Since I got it working I thought it would be cool to rez a "coupon" next to a customer
//that would be of just whoever one randomly chose to be the lucky person that could get
//a full sale copy of an item in the store or something... kind of draw attention to things, etc.
//---You could even oversize your sale panel for a big effect ;) I really like this idea the more
//I thought on it....
}

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

link_message(integer sender_num, integer num, string str, key id)
{
if (str == "GetCustomer";){
llSensor("", NULL_KEY, AGENT, 30, PI);
}
}

listen(integer channel, string name, key id, string message)
{
Gname = message;
listPos = llListFindList(avatarsDetected, (list)message);
targetPos = llList2Vector(posDetected, listPos);
useKey(llList2Key(keysDetected, listPos));
}

sensor(integer numDetected)
{
if (numDetected > 12) numDetected = 12;
avatarsDetected = [ ];
keysDetected = [ ];
posDetected = [ ];

for (nextStep = 0; nextStep < numDetected; nextStep++)
{
nextAvatarName = llDetectedName(nextStep);
nextAvatarKey = llDetectedKey(nextStep);
nextAvatarPos = llDetectedPos(nextStep);

if (llStringLength(nextAvatarName) > 24) nextAvatarName = llGetSubString(nextAvatarName, 0, 23);
avatarsDetected = (avatarsDetected=[]) + avatarsDetected + nextAvatarName;
keysDetected = (keysDetected=[]) + keysDetected + nextAvatarKey;
posDetected = (posDetected=[]) + posDetected + (string)nextAvatarPos;
}

llDialog(llGetOwner(), menuText, avatarsDetected, channel);
}
}

Basically, all I added was a THIRD LIST.
All it is supposed to do is grab the vector position of the very SAME avatars it is already recording.
Granted I have never used the DetectedPos function before, but there really isn't much info on the wikki... from what I gleaned from it, and the fact that I didn't get any errors, I think it is right though on format.

All I get are zeros for vectors. Everything else works like it did before, so I am using the script as it sits just fine, but after I came up with the 'coupon / "Nth" visitor today' idea... I really like it.

Although I do plan to make a nifty gadget with this and the scripts linked to it, (Well basically a HUD with options for auto-rez inventory, updating your store, etc.) I plan to make this and everything publicly available because of everyones help. I can't thank everyone enough.

Take care,
-Hap

[sample output: ]
[19:41] Customer Service HUD at3: c123f1ca-b1c5-4a90-b6d5-36daf13679f3
[19:41] Customer Service HUD at3: <0.00000, 0.00000, 0.00000>
[19:41] Customer Service HUD at3: 1
[19:41] Customer Service HUD at3: Lucinda Obviate
[----------------------]
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
08-24-2007 01:10
You don't appear to have set up a listen. I would expect to see something like this:

llListen(channel, "", llGetOwner(), "";);

...often to be found in state_entry() but not always.
Catherine Dollinger
Registered User
Join date: 11 May 2007
Posts: 26
08-24-2007 01:28
Try setting

state_entry()
{
llListen(channel, "", NULL_KEY, "";);
}

Worked for me in a test in LSL Editor, but resulted (in the test environment) in an error within the llList2Key()-call in listen(...) - maybe due to the test environment. But at least the listen(...) part is reached that way :-)
Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
08-24-2007 17:26
Yep, that pretty much fixed it with a little extra tweaking on my end as well. I appreciate it, I knew it was something staring me in the face.. been working on it too long and needed to give up the ghost. :)

Thanks a mint!
- Hap
Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
08-24-2007 19:44
I've added another bug to the system ... I have edited the original post with updated code and information... so sorry to bother anyone again, thanks for helping me out again.

Take care,
-Hap
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
08-25-2007 12:02
Your bugs are getting cunning. ;)


You start with this line:

posDetected = (posDetected=[]) + posDetected + (string)nextAvatarPos;

...where you put the llDetectedPos into the posDetected list as a string. So you have a list of strings. However, later on you try and transform this string into a vector:

targetPos = llList2Vector(posDetected, listPos);

...and then report it as a string:

llSay(0,(string)targetPos);


Now, I'm not going to defend this but the Wiki states (the Wiki I can get working just now):

From: http://cheesefactory.us/lslwm/llList2Vector.htm
"Note: llList2Vector will not automatically cast a string to a vector. Thus, if you attempt to retrieve a list element consisting of a vector cast to a string like "<1,2,4>", llList2Vector will return ZERO_VECTOR or <0,0,0>. This can be avoided by using llList2String and casting directly, as in: vector foo = (vector)llList2String(["<1,2,4>"], 0);"
I would suggest you simply collect the posDetected list as vectors:

posDetected = (posDetected=[]) + posDetected + (vector)nextAvatarPos;

...but I suspect there are several ways to skin this cat and I have no idea where you're going with this script. :D