note card query help
|
|
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
|
04-22-2009 12:49
I need to have my script read 3 variables from a nc so that the end user can easily change these to there position after purchase without leaving my script mod so it can be copied.
Basically what I need it to do is get the x, y, z positions from a nc that the end user can change once the item is rezzed. The script works great if I manually imput these positions into it but would like for it to query a nc for them. Here are the 3 parts of the script that need to be queried:
float BOTTOM = 37; float XPOS = 212.352; float YPOS = 87.309;
Or if there is a way for the script to automatically get these variables and input them on rezz.
Not sure if this can even be done as I have never had to do this before. Thanks for every ones help in advance.
|
|
MystyReus Korobase
Registered User
Join date: 15 Jun 2008
Posts: 25
|
I saw a script at th LSL library in world...
04-22-2009 13:10
You changed the NC and when the avatar attached the item, it gave them a pop up dialouge that asked them to choose. I will be in world later, I can show you where it is if you like?
|
|
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
|
04-22-2009 13:50
Sorry, I should have stated that the object isn't an attachment but rather a object that is rezzed on the ground to be used.
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
04-22-2009 14:13
You'll want something like this. Type your three values on a notecard, separated by commas, and drop it in the contents of the object along with your script. string gName; key gQueryID; integer gLine = 0; float BOTTOM; float XPOS; float YPOS; default { on_rez(start_param) { gName = llGetInventoryName(INVENTORY_NOTECARD, 0); gQueryID = llGetNotecardLine(gName, gLine); } dataserver(key query_id, string data) { if (query_id == gQueryID) { if (data != EOF) { list tempLine = llParseString2List(data, [,],[]); BOTTOM = llList2Float(tempLine(0)); XPOS = llList2Float(tempLine(1)); YPOS = llList2Float(tempLine(2)); } } } // Then all the rest of your program // }
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
|
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
|
04-22-2009 14:47
Ok, I have added your idea to the script, but it wont save it and gives me a syntax error. It might be that I am just not seeing straight tonight or I am missing something but here is the whole top part of my script with yours added all the way to the state_entry() of where my script starts. I have just never done a script that uses a nc for its data so I may just not be seeing something simple.
integer CHANNEL = -42; list MENU_MAIN = ["Floor 1", "Floor 2", "Floor 3", "Floor 4", "Floor 5", "Floor 6", "Floor 7"]; string gName; key gQueryID; integer gLine = 0; float BOTTOM; float XPOS; float YPOS; float FLOOR_HEIGHT = 10; float SPEED = 0.5; float target; default { on_rez(integer start_param) { gName = llGetInventoryName(INVENTORY_NOTECARD, 0); gQueryID = llGetNotecardLine(gName, gLine); } dataserver(key query_id, string data) { if (query_id == gQueryID) { if (data != EOF) { list tempLine = llParseString2List(data, [,],[]); BOTTOM = llList2Float(tempLine(0)); XPOS = llList2Float(tempLine(1)); YPOS = llList2Float(tempLine(2)); } } }
{ state_entry()
Thanks again for the help!!
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
04-22-2009 14:52
It's impossible to diagnose without knowing what the syntax error is, and where.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
|
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
|
04-22-2009 14:54
it says: (24, 42) : Syntax error
and that would be
list tempLine = llParseString2List(data, [,],[]); and is in [,]
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
04-22-2009 15:03
There's a stray { just before your state_entry line. That's not line 24, but the complier could be kicking it back from there. Remove that {.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
|
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
|
04-22-2009 15:05
ok, removed it and the syntax error is the same
integer CHANNEL = -42; list MENU_MAIN = [""]; string gName; key gQueryID; integer gLine = 0; float BOTTOM; float XPOS; float YPOS; float FLOOR_HEIGHT = 10; float SPEED = 0.5; float target; default { on_rez(integer start_param) { gName = llGetInventoryName(INVENTORY_NOTECARD, 0); gQueryID = llGetNotecardLine(gName, gLine); } dataserver(key query_id, string data) { if (query_id == gQueryID) { if (data != EOF) { list tempLine = llParseString2List(data, [,],[]); BOTTOM = llList2Float(tempLine(0)); XPOS = llList2Float(tempLine(1)); YPOS = llList2Float(tempLine(2)); } } }
state_entry()
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
04-22-2009 15:47
Ooops! Sorry about that. That's what happens when I type fast. Change the following lines to remove errors. list tempLine = llParseString2List(data, [","],[]); BOTTOM = llList2Float(tempLine,0); XPOS = llList2Float(tempLine,1); YPOS = llList2Float(tempLine,2);
It ought to work now.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
|
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
|
04-22-2009 15:51
Thank you!!! If I owe you anything Rolig just let me know!!!
Now for a simple question, if the object gets moved will it grab its new position or will I have to put a change event in the script as well?
|
|
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
|
04-22-2009 16:04
Since I don't know what the rest of your script looks like, I can't tell how it's grabbing its position. In the absence of any information, though, I will guess that it should work just fine at a new location. The way to tell, of course, is to try it out yourself. It occurs to me that you might also want to make provision for the possibility that whoever is using this device might want to replace the notecard and expect it to read without having to re-rez the thing. If so, then put the following line llAllowInventoryDrop(TRUE); in your on_rez or state_entry event and then add a changed event that looks like this ... changed(integer change) { if(change & CHANGED_INVENTORY) { llResetScript(); } }
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask....  Look for my work in XStreetSL at 
|
|
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
|
04-22-2009 16:23
I sent you an IM here in the forums Rolig.
|