Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Namespace, enumerators, identifiers. Man it's difficult.

Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
07-09-2009 00:12
Finally got my legal copy of vista cracked so I can use it in VirtualBox3 and boy is it slow.
The only reason is LSL editor. Nothing else! And that's even slower.
Anyhow, onto the problem...

I point out first, I'm a mug scripter and know nothing of the following errors.
Another script in this set has exactly the same code in this "add-remove state" which works fine, or it passes syntax check in Lsl editor.

This one does not. Several errors which I cannot seem to fix any at all. all errors are in this part. I know the dialog will not come up in state entry "in world" but everything seems to work otherwise.
I searched the errors but can't speak C or ASP or anything else.

One error: A namespace does not directly contain members such as fields or methods

Several: Expected class, delegate, enum, interface, or struct

One: Identifier expected

Please give me a clue. I been trying for many hours (read weeks) to rid these. Thanks for any help.

CODE

state ADD_REM_STATE
{
state_entry()
{
CHANNEL = (integer) llFrand (1000000)+1;
llListen(CHANNEL, "","", "");
llListen(COM_CHANNEL, "","","");
llDialog(llDetectedKey(0), "PRESS 'EXIT' To leave here now.", ["EXIT","LIST"], CHANNEL);
llSetTimerEvent(60);
llOwnerSay("State Add Remove...");
}
listen(integer CHANNEL, string name, key id, string msg)
{
llDialog(llDetectedKey(0), "PRESS 'EXIT' TO GET OUT OF HERE", ["EXIT","LIST"], CHANNEL);
if (msg == "exit") state Running;
if (msg == "list"){
LIST_TEMPLIST();
llDialog(id, "PRESS 'EXIT' TO GET OUT OF HERE", ["EXIT","LIST"], CHANNEL);
}
if(llSubStringIndex(msg, "add=") >= 0)
{
string person = llGetSubString(msg, 4, llStringLength(msg));
temp_list += [llToLower(person)];
llSay(0,person +" Has been added to the list");
list tmplist = llCSV2List(llToLower(ACCESS_LIST));
door_access_list = [] + temp_list + tmplist;
LIST_ALLOWED();
debug("AccessList / "+" / "+(string)access_list+" / "+(string)door_access_list);
state Running;
}
if(llSubStringIndex(msg, "remove=") >= 0)
{
string kill_name = llGetSubString(msg, 7, llStringLength(msg));
if (removeName(llToLower(kill_name)))
{
llSay(0,kill_name +" has been removed from the list");
}
else
{
llSay(0,kill_name +" not found on the list. Exiting. Please try again");
}
LIST_ALLOWED();
debug("AccessList / "+" / "+(string)access_list+" / "+(string)door_access_list);

state Running;
}
if(llSubStringIndex(msg, "exit") >= 0)

state Running;
}
timer()
{
llSay(0, "60 Second Timeout! aborting");
llListenRemove(listen_handle);
llListenRemove(CHANNEL);
state Running;
}
}
_____________________
SCOPE Homes, Bangu
-----------------------------------------------------------------
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-09-2009 01:17
llDetectedKey only works in events that support detected functions (touch, collision, sensor)..

in state entry you'll probably want to replace it with llGetOwner(), and in the listen you can replace it with id... those are the ones I see immediately... there's also several variables that I can't tell if they were initialized elswhere, but assume they are (like CHANNEL)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
07-09-2009 04:06
Thank you void

There must be a name for it:
The process of posting a question after many failed attempts, then trying again with success after wasting your own and others' time.
~~~~~~~~~~~~~~`
One problem was: It appears I should have declared the lists with [] empty brackets at the top of the script. (among others)

Might just ask a question related to that.

Should this always be done? For lists that may change? Does it matter?
What about others, like boolean switches? Should they be declared with a zero (or a one) right from the start as a global variable? i.e.
integer some_switch; or
integer some_switch = 0;
Or should they be initiated in state_entry or a bit of both.
Should everything be decared as something if possible from the get go?
I mean, is it ok to have some_switch undeclared until it's needed.
I guess, what's best practice here?
_____________________
SCOPE Homes, Bangu
-----------------------------------------------------------------
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-09-2009 23:09
From: Kornscope Komachi
Thank you void

There must be a name for it:
The process of posting a question after many failed attempts, then trying again with success after wasting your own and others' time.
~~~~~~~~~~~~~~`
One problem was: It appears I should have declared the lists with [] empty brackets at the top of the script. (among others)

Might just ask a question related to that.

Should this always be done? For lists that may change? Does it matter?
What about others, like boolean switches? Should they be declared with a zero (or a one) right from the start as a global variable? i.e.
integer some_switch; or
integer some_switch = 0;
Or should they be initiated in state_entry or a bit of both.
Should everything be decared as something if possible from the get go?
I mean, is it ok to have some_switch undeclared until it's needed.
I guess, what's best practice here?

dunno about lsl editor, but it's not REQUIRED....

it is a good practice to pre initialize them especially if you would be doing that anyway, plus it makes it more apparent what your starting values are for less experienced scripters (the experienced ones automatically add the default values in their head) and can help you avoid some small errors when writing in other languages that have different variables. script byte-code-wise it doesn't cost you anything (since initial variables in the global section are inserted by the compiler)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -