Tabris Daxter
Snake oil Salesman
Join date: 22 Feb 2009
Posts: 61
|
09-14-2009 16:06
What is wrong here? integer dialog_channel1; integer dialog_channel2; integer dialog_channel3; key Key_ID; string name;
default { integer channel() { // top of script in functions //Gets Owner Key as integer return (integer)("0x"+llGetSubString((string)llGetOwnerKey(Key_ID),-16,-1)) ; }
integer channel2() { // top of script in functions //Gets HASH of Owner Key and Owner Name as integer return (integer)("0x"+llGetSubString((string)llSHA1String ( Key_ID + name),-16,-1)) ; }
integer CommandIs(string msg,string cmd) { return llSubStringIndex(msg,cmd) == 0; } ParseAndIssueCommand(string cmd) //*** error refers to here { if (CommandIs(cmd,"title")) { string name = llGetSubString(cmd,6,-1); if (name == "title") llSetText("",<0,1,0>,1.0); else llSetText(name,<0,1,0>,1.0); } }
state_entry() { { llListen(dialog_channel3,"",llGetOwner(),""); } } on_rez(integer start_param) { llResetScript(); } listen(integer channel, string name, key id, string msg) { ParseAndIssueCommand(msg); //} //{ //Private Channel Code Key_ID = llGetOwnerKey(ID); name = llKey2Name(Key_ID); dialog_channel1 = channel(); dialog_channel2 = channel2(); dialog_channel3 = (dialog_channel2 * dialog_channel1) * -1; //Listen //llListen(dialog_channel3,"","",""); // Here Down is Self explanitory. llSay(0, "Hello, " + name);
} }
This is the Error that i get in LsL editor: *** Class, struct, or interface method must have a return type
_____________________
DANCE WITH KIRBY (^'-')^ (^'-')> (>'-')> <  '-'^) ^('-'^) (^'-')^ (^'-')> (>'-')> <  '-'^) ^('-'^)
|
EF Klaar
Registered User
Join date: 11 Jun 2007
Posts: 330
|
09-14-2009 16:22
The declarations of the global functions channel, channel2 and commandIs should be made outside of the state "default", in the same area as you declare your global variables. "top of script in functions" really does mean top of script. (Edit) Looking closer, I see that the whole structure is wrong. Go to http://wiki.secondlife.com/wiki/LSL_Portal for references and examples of LSL scripting. Basically, a script looks like this: integer global_variable = 1; integer GlobalFunction () { return 1; } default { state_entry () { integer scope_variable = 2; global_variable = scope_variable + GlobalFunction (); } touch_start (integer number_of_touches) { state other; } } state other { state_entry () { integer another_scope_variable = 5; global_variable = another_scope_variable + GlobalFunction (); } touch_start (integer number_of_touches) { state default; } }
|
Tabris Daxter
Snake oil Salesman
Join date: 22 Feb 2009
Posts: 61
|
09-14-2009 19:05
stupid error in Cut & paste.
now i got another one
'channel' is a 'variable' but is used like a 'method'
referring to this line
dialog_channel1 = channel();
_____________________
DANCE WITH KIRBY (^'-')^ (^'-')> (>'-')> <  '-'^) ^('-'^) (^'-')^ (^'-')> (>'-')> <  '-'^) ^('-'^)
|
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
|
09-14-2009 19:10
/me points at this line... From: Tabris Daxter listen(integer channel, string name, key id, string msg)
edit: and this my be the time for the semi-anual scripting tips preachy thing about coding style... As somebody who's been writing code for a RL living for more than a few years, I can tell you - without a doubt, no question about it, really listen to this - that a consistant coding style is important. From: someone integer dialog_channel1; integer dialog_channel2; integer dialog_channel3; key Key_ID; string name;
/me raises a rolled up newspaper threateningly.. You're mixing styles here. All but Key_ID are pretty consistant but Key_ID uses a different convention - you've cap'ed the K. Seems silly but this WILL come back to bite you at some point. I'd have done... integer gDialogChannel1; integer gDialogChannel2; integer gDialogChannel3; key gKeyID; string gName; ...which prefixes all global things with a 'g' and then uses camel case on the rest of the name. From: someone integer channel() { ... }
integer CommandIs(string msg,string cmd) { ... }
/me thwaps Tabris on the nose with the rolled up newspaper. Same thing only different, and the cause of your 2nd post error. If you consistantly use a format like you have on the 2nd function, and define globals as gSomeVariable, and define locals like someVariable, you won't run into that kind of problem again, you'll find your code is easier to read, and you won't run into evil scoping errors.. The style you pick doesn't really matter, as long as you consistantly follow it. Take what I use or not - doesn't matter to me. Just pick your style and stick to it. It will save you many, many hours of grief. /me trips and falls as she climbs off the soap box.
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!! - Go here: https://jira.secondlife.com/browse/SVC-3895- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
EF Klaar
Registered User
Join date: 11 Jun 2007
Posts: 330
|
09-14-2009 21:05
From: Tabris Daxter stupid error in Cut & paste.
now i got another one
'channel' is a 'variable' but is used like a 'method'
referring to this line
dialog_channel1 = channel(); Not enough here for me, at least, to figure out what's up. Can you post the whole script without the cut and paste error?
|
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
|
09-14-2009 21:16
From: EF Klaar Not enough here for me, at least, to figure out what's up. Can you post the whole script without the cut and paste error? It continues to be the way the listen event is declared. It's got an argument named 'channel' which out-scopes the function named 'channel'.
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!! - Go here: https://jira.secondlife.com/browse/SVC-3895- If you see "if you were logged in.." on the left, click it and log in - Click the "Vote for it" link on the left
|
Tabris Daxter
Snake oil Salesman
Join date: 22 Feb 2009
Posts: 61
|
09-14-2009 21:36
From: Sindy Tsure /me thwaps Tabris on the nose with the rolled up newspaper. Same thing only different, and the cause of your 2nd post error.
/me dodges newspaper. maybe i write like that to confuse people. (wrote an entire IT class essay in HEX) i used to make all my variables/functions/other only something i could figure out. but thanks any way. sorta works i just gotta tweak the last part in world.
_____________________
DANCE WITH KIRBY (^'-')^ (^'-')> (>'-')> <  '-'^) ^('-'^) (^'-')^ (^'-')> (>'-')> <  '-'^) ^('-'^)
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
09-14-2009 22:21
Avoid global and local variable names, and also function names, that duplicate the parameter names of functions or event handlers. That's asking for BIG trouble. In most languages more localized scoping would take care of things for you, and you'd have some kind of syntax tool for distinguishing in any case when you really need to. LSL, on the other hand, tends to have hissy fits when you do stuff like that.
|