Very odd llListen behavior
|
|
Shippou Oud
The Fox Within
Join date: 11 Jul 2005
Posts: 141
|
02-20-2007 21:56
here is the parts of the script that are involven. It does not matter what I type in after /404, it will run both if's (I added return; so it only ran the forst one)..what is wrong here? From: someone integer chan = 404; ... llListen(chan,"",llGetOwner(),""  ; ... listen(integer chan,string name,key id,string xxx) { if (id == llGetOwner()) { if (xxx = "stats"  { llInstantMessage (llGetOwner(),title + rules + " price $L" + (string) price + " min renting time " + (string) limitmi + " days - max renting time " + (string) limitma + " days"  ; return; } else if (xxx = "bootup"  { llInstantMessage(llGetOwner(),"Starting config. process"  ; llGetNotecardLine("info",1); llListenRemove(llListen(chan,"",llGetOwner(),""  ); return; } } Thanks in advace ^-^
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
02-20-2007 22:25
syntax, formating and flow control integer chan = 404; key owner_id;
//Data string title; string rules; integer price; integer limitmi; integer limitma;
default { state_entry() { owner_id = llGetOwner(); llListen(chan,"",owner_id,""); } listen(integer chan,string name,key id,string cmd) { if (id == owner_id) { if (cmd == "stats") { string long_string = ( title + rules + " price $L" + (string) price + " min renting time " + (string) limitmi + " days - max renting time " + (string) limitma + " days" ); llInstantMessage (owner_id, long_string); } else if (cmd == "bootup") { llInstantMessage(llGetOwner(),"Starting config. process"); llGetNotecardLine("info",1); } }
llListenRemove(llListen(chan,"",owner_id,"")); } }
|
|
Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
|
02-20-2007 22:30
Since it's probably not obvious what all Osgeld changed, you missed a couple of = signs; you're assigning not testing. if (xxx = "stats"  ... else if (xxx = "bootup"  Happens to the best of us I gather 
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
02-21-2007 01:10
From: Anti Antonelli Since it's probably not obvious what all Osgeld changed, you missed a couple of = signs; you're assigning not testing. if (xxx = "stats"  ... else if (xxx = "bootup"  Happens to the best of us I gather  Its one of the most common mistakes. A way around it is always put the constant on the left hand side i.e. if("stats" = xxx) This wil get thrown out by the compiler, even the SL one, as you cannot assign to a string literal.
|
|
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
|
02-21-2007 01:48
Just one other tiny observation... note cards start from line zero.
|
|
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
|
02-21-2007 05:07
From: Newgate Ludd Its one of the most common mistakes. A way around it is always put the constant on the left hand side i.e.
if("stats" = xxx)
This wil get thrown out by the compiler, even the SL one, as you cannot assign to a string literal. Cute trick! I like it!
_____________________
 ● Inworld Store: http://slurl.eclectic-randomness.com ● Website: http://www.eclectic-randomness.com ● Twitter: @WinterVentura
|
|
Shippou Oud
The Fox Within
Join date: 11 Jul 2005
Posts: 141
|
02-21-2007 08:41
Thanks for the help =-)
Note card line 0 is not relevet to the script..it's instructions on what to put on line 1. ^-^
|
|
Wicc Cunningham
Registered User
Join date: 25 Jun 2004
Posts: 52
|
02-21-2007 11:45
You can also get rid of the id == owner_id condition in the listen state since you are setting the listen to filter for just the owner already.
|