|
Zena Tiki
Registered User
Join date: 16 Nov 2006
Posts: 37
|
11-01-2007 02:10
I have the scrip in a prim and along with a Notecard called "Chan" - why doesn't it give me the content of line 1 - instead it gives me a key of something?
string myName= " "; default { touch_start(integer total_number) { myName = llGetNotecardLine("chan", 1); llSay(0,"myName = " + myName); } }
|
|
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
|
11-01-2007 02:26
It's because llGetNotecardLine doesn't return the line requested. What it does is send a request off to the asset server. This request might take a short time to come back, so instead of just looking at the result of the llGetNotecardLine call, you need to implement another type of even, called a dataserver event.
Dataserver basically just handles responses from the asset server, for things like notecards. If you just wanted the first line of a notecard, you would do something like the following:
default { touch_start(integer total_number) { llGetNotecardLine("chan", 0); }
dataserver( key query_id, string data) { if (data != EOF) { llSay (0, "myName = " + data); } } }
Note that the first line in a notecard is line 0, not line 1. We're also checking against the notecard being empty by checking for EOF (end-of-file).
If you need to request multiple lines then you basically need to request line 1 when you receive the event for line 0, line 2 in the event for line 1 etc.
|
|
Zena Tiki
Registered User
Join date: 16 Nov 2006
Posts: 37
|
11-01-2007 04:15
 giggle - thankyou 
|
|
Kahiro Watanabe
Registered User
Join date: 28 Sep 2007
Posts: 572
|
11-01-2007 05:18
site highly recommended for this issues: www.lslwiki.net
|
|
Zena Tiki
Registered User
Join date: 16 Nov 2006
Posts: 37
|
Please Sir I Wont More
11-01-2007 05:48
I will check this site but PLEASE SIR I WANT SOME MORE: I'm trying to read a channel number of the card but don't know enought to figure it out - Ihave: integer CHANNEL; // Channel to talk on //==================================================================================== // States //------------------------------------------------------------------------------------ default { state_entry() { llGetNotecardLine("chan", 0); // read notecard string Owner; key OwnerKey; OwnerKey = llGetOwner(); // Get the owner for commands Owner = llKey2Name(OwnerKey); // And their name // etc ... llListen(CHANNEL, "", "", ""  ; // Listen for Commands } Now where do I put?? //------------------------------------------ dataserver( key query_id, string data) { if (data != EOF) { CHANNEL = (integer)data; } } //---------------------------------------------
|
|
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
|
11-01-2007 05:57
You can't do it like that. The problem is that your llListen call will happen before the dataserver event gets called, so the listen will be set up with the default (0) channel. You need to move the llListen into the dataserver event, then put the dataserver event inside the default state (anywhere, as long as it's not in another event!) So something like the following: integer CHANNEL; // Channel to talk on
default { state_entry() { llGetNotecardLine("chan", 0); // read notecard string Owner; key OwnerKey; OwnerKey = llGetOwner(); // Get the owner for commands Owner = llKey2Name(OwnerKey); // And their name // etc ... } dataserver( key query_id, string data) { if (data != EOF) { CHANNEL = (integer)data; llListen(CHANNEL, "", "", ""); // Listen for Commands } }
Depending on what you're doing with them, you may need to make your owner and ownerkey variables global, or move the into the dataserver event.
|
|
Zena Tiki
Registered User
Join date: 16 Nov 2006
Posts: 37
|
11-01-2007 06:02
tank q
|