Syntax Error with dataserver
|
|
Ving Xi
Registered User
Join date: 23 Sep 2006
Posts: 9
|
11-19-2006 07:20
I am having a very frustrating problem, and I hope some of you experts can help me out. Here is the code: state divination { state_entry() { question="Which layout do you wish?"; menu=["Celtic Cross", "Four Seasons", "3-card"]; llDialog(llGetOwner(), "\n" + question, menu, DIALOG_CHANNEL); listen_handle = llListen(DIALOG_CHANNEL, "", llGetOwner(), ""); } listen(integer channel, string name, key id, string message) { layout = message; // dialog choice
// Get the first line of the notecard (number = cards in layout) gQueryID1 = llGetNotecardLine(0, layout); dataserver(key query_id, string data) { if (query_id == gQueryID1) { number = (integer) data; } } for (i = 1; i < number; i++) { random = (integer) llFrand(78); gQueryID2 = llGetNotecardLine(cardlist, random); dataserver(key query_id, string data) { if (query_id == gQueryID2) { card = data; } } gQueryID3 = llGetNotecardLine(layout, i); dataserver(key query_id, string data) { if (query_id == gQueryID) { xyz = data; } }
x = llList2Vector(xyz, 0); y = llList2Vector(xyz, 1); z = llList2Vector(xyz, 2);
if (i == 2 & layout == "Celtic Cross") { rot1 = 0.000; rot2 = 0.000; rot3 = 0.000; rot4 = PI; } else { random = (integer) llFrand(78); reversed = llFrand(1); if (reversed > 0.500) { rot1 = 0.000; rot2 = 0.000; rot3 = -PI; rot4 = PI; } else { rot1 = 0.000; rot2 = 0.000; rot3 = PI; rot4 = PI; } } } lRezObject(card, llGetPos() + <x, y, z>, ZERO_VECTOR,<rot1,rot2,rot3,rot4>, 42); } } state_exit() { llListenRemove(listen_handle); } }
On compile, it is moving the cursor to right before the first dataserver command and announcing syntax error. I can't find anything wrong with this, and I ask you to clue me in if you know. NOTE: this is only one state in the entire program. Please let me know if you need more of the program to figure this out. Ving Xi
|
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
11-19-2006 08:22
dataserver() is not a command, it's an event. You can't nest events. 
|
|
Ving Xi
Registered User
Join date: 23 Sep 2006
Posts: 9
|
11-19-2006 09:34
Thank you very much! I'll try to rearrange things so they're not.
Ving Xi
|
|
Ving Xi
Registered User
Join date: 23 Sep 2006
Posts: 9
|
New Problem
11-21-2006 12:36
Well, I finally got everything else cleared up (I think), except that now I get a "name not devined within scope" eror, with the cursor sitting right after the "42":
llRezObject(cardname, llGetPos() + <x, y, z>, ZERO_VECTOR,<rot1,rot2,rot3,rot4>,42);
What can possibly be the problem with this? It worked just fine in the 1.0 version of this script. (I copied and pasted this line and modified it and the 42 was already there when I wrote v1.0.)
Can anyone please help me?
Ving
|
|
Trevor Langdon
Second Life Resident
Join date: 20 Oct 2004
Posts: 149
|
11-21-2006 13:46
Ving--
Looks like you changed your variable names without updating your global definition to match:
Orignial: card
New: cardname
My guess is that your global definition still refers to 'card' instead of the new 'cardname'.
|
|
Ving Xi
Registered User
Join date: 23 Sep 2006
Posts: 9
|
11-21-2006 19:35
Okay, you've all been great.  I have another weird one: state suit { state_entry() { question = "What type?"; menu = ["Trump", llList2String(suits,0), llList2String(suits,1), llList2String(suits,2), llList2String(suits,3)]; llDialog(llGetOwner(), "\n" + question, menu, DIALOG_CHANNEL); listen_handle = llListen(DIALOG_CHANNEL, "", llGetOwner(), ""); } listen(integer channel, string name, key id, string message) { if(message != "Trumps") { cardname = " of " & message; state individual; } else { state trump; } } state_exit() { llListenRemove(listen_handle); } }
It says "Name previously declared with scope" and the cursor sits on the final "}". I have studied this several hours and can't figure it out. Ving I hope this is the last problem I have, but I won't promise anything.
|
|
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
|
11-21-2006 20:59
Have you used "suit" previously in thisscript as a variable?
If you not sure, check with search; the only time to use "suit" is with a "state" statement.
hth Ed
|
|
Ving Xi
Registered User
Join date: 23 Sep 2006
Posts: 9
|
llGetNotecardLine
11-22-2006 07:48
Yeah! It's actually compiling now! I am forever in your debt. But it still isn't working correctly.  My routines will only read the first line of my notecards. I've looked at the Wiki and can't figure out what's happening. If you need more code snippits, ask and ye shall receive! Ving
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
11-22-2006 08:23
From: Ving Xi Yeah! It's actually compiling now! I am forever in your debt. But it still isn't working correctly.  My routines will only read the first line of my notecards. I've looked at the Wiki and can't figure out what's happening. If you need more code snippits, ask and ye shall receive! Ving Are you actually requesting it to read more than one line? Each request requires a seperate call. The request requires a line number, have you incremented it correctly? Check out This Thread or This one for some sample code
|
|
Trevor Langdon
Second Life Resident
Join date: 20 Oct 2004
Posts: 149
|
11-22-2006 08:51
Ving-- As Newgate mentioned, you are probably not performing additional reads required within the Dataserver code block inorder to read more than one line. Here is an example that should help: // Notecard Query Global Variables string sNotecardName; // Name of a notecard in the object's inventory integer iNotecardLine = 0; // Notecard line number key kQueryID; // id used to identify dataserver queries
// ------ In main code block ----------------- // Start DATASERVE Event // Initial Read kQueryID = llGetNotecardLine(sNotecardName, iNotecardLine); // -------------------------------------------------
dataserver(key query_id, string data) { if (query_id == kQueryID) { kQueryID = ""; // Prevent a bug that occurs with dataserver events. if (data != EOF) { // Read notecard line
// ..... // Add your processing code block here // ..... // Increment your counter ++iNotecardLine; // increase line count // Read next notecard line kQueryID = llGetNotecardLine(sNotecardName, iNotecardLine); // request next line } else { // .... // Add code here you want executed once there is no more data read from the notecard // .... } } } // End ======= DATASERVER - Read Notecard ======================
|
|
Ving Xi
Registered User
Join date: 23 Sep 2006
Posts: 9
|
11-22-2006 12:53
Well, I've examined the examples you all so graciously submitted, and it seems I am doing everything correctly, but you know how that goes.  Would someone be willing to have me send them the object I am working on and look at it as a whole? I really don't want to expose it all on the forums, as I've worked long and hard on this program and don't want it released to the general public. I would be willing to pay a reasonable amount of L$ for such a service. I am just at my wit's end at this point because it seems like I've done everything right and it still doesn't work. I usually have better luck with new programming languages than this! Ving
|
|
Trevor Langdon
Second Life Resident
Join date: 20 Oct 2004
Posts: 149
|
11-22-2006 13:03
Ving-- I will take a look; however, I won't be home from work for another couple hours.
I'll check here once I get home to see if you still need assistance.
|
|
Ving Xi
Registered User
Join date: 23 Sep 2006
Posts: 9
|
11-22-2006 13:17
Trevor,
I've sent you the object. I hope you can figure it out. I am only in my second month of programming in LSL, but I think my knowledge has progressed well enough, but I'm not as confident in my debugging (and I suspect it is something REALLY stupid), so I appreciate the help.
Ving
|