Jump to content
Sign in to follow this  
ChaosRaine

Trying to alter scripts with notecards

Recommended Posts

I have the idea down on how to let somebody change a nonmodify script using the object discription, but I can seem to master using note cards. I did something like this        gUUID = llList2String(llGetObjectDetails(llGetKey(), ([OBJECT_DESC])), 0); to get a uuid number from the objects discription for example. How would I alter that to get a uuid from a notecard. I will admit I am a very uneducated about this so if somebody could just send me to some good reading material on the subject that would be greatly appreciated. Thank you in advance.

Share this post


Link to post
Share on other sites

Yeah so for a simple example I have a hover text script

default{    state_entry()    {        llSetText("Hello there",<1.0, 1.0, 1.0>,1.0);    }}

 and lets say I want somebody to be able to change the text, color, and transparency from a notecard I'm coming up with something like this

key notecardQueryId;string notecardName = "Text";integer notecardLine;default{    state_entry()    {        // Check the notecard exists, and has been saved        if (llGetInventoryKey(notecardName) == NULL_KEY)        {            llOwnerSay( "Notecard '" + notecardName + "' missing or unwritten");            return;        }        // say("reading notecard named '" + notecardName + "'.");        notecardQueryId = llGetNotecardLine(notecardName, notecardLine);    }     dataserver(key query_id, string data)    {        if (query_id == notecardQueryId)        {            if (data == EOF)        llSetText((notecardLine, 0), <1.0, 1.0, 1.0>, 1.0);    }}}

 I'm still have trouble working this out based on the examples on wiki

Share this post


Link to post
Share on other sites

Ok so far I have something working to get the text to read

key notecardQueryId;string notecardName = "Text"; // script-wise, the first notecard line is line 0, the second line is line 1, etc.integer notecardLine; say(string inputString){    llOwnerSay(inputString);} default{    state_entry()    {        // Check the notecard exists, and has been saved        if (llGetInventoryKey(notecardName) == NULL_KEY)        {            llOwnerSay( "Notecard '" + notecardName + "' missing or unwritten");            return;        }        // say("reading notecard named '" + notecardName + "'.");        notecardQueryId = llGetNotecardLine(notecardName, notecardLine);    }     dataserver(key query_id, string data)    {        if (query_id == notecardQueryId)        {              //  ++notecardLine;                llSetText(data,<1.0, 0.0, 0.0>, 1.0);            }        }} 

 Now I'm trying to figure out how to get it to add more cards or lines. I would prefure to use the same card with more lines to get the color and transparency, but I'm not stuck on it.

Share this post


Link to post
Share on other sites

Here is a more versatile, easy to use version.

key notecardQueryId;string notecardName = "Text";integer notecardLine;string gsText;vector gvColor;float gfAlpha;default{    state_entry()    {        // Check the notecard exists, and has been saved        if (llGetInventoryKey(notecardName) == NULL_KEY)        {            llOwnerSay( "Notecard '" + notecardName + "' missing or unwritten");            return;        }        // say("reading notecard named '" + notecardName + "'.");        notecardQueryId = llGetNotecardLine(notecardName, notecardLine);    }     dataserver(key query_id, string data)    {                list lTemp;        string sName;        string sValue;                    if (query_id == notecardQueryId)        {            if (data != EOF)             {       // Checking for comment lines, and empty lines.                if (llStringTrim(llGetSubString(data, 0,1), STRING_TRIM) != "//" && llStringTrim(data, STRING_TRIM) != "")                {                     lTemp = llParseString2List(data, ["="], []); // Parse the data string into a list, seperated by '='                    sName = llStringTrim(llList2String(lTemp, 0), STRING_TRIM); // the name of the name=value pair                    sValue = llStringTrim(llList2String(lTemp, 1), STRING_TRIM); // the value of the name=value pair                                        if (llToLower(sName) == "text") {                        gsText = sValue;                    }                    else if (llToLower(sName) == "color") {                        gvColor = (vector)sValue;// typecasting to vector                    }                    else if (llToLower(sName) == "alpha") {                        gfAlpha = (float)sValue;// typecasting to float                    }                }                notecardQueryId = llGetNotecardLine(notecardName, ++notecardLine); // proceed to next notecard line            }            else {// We are at the end of the file                llSetText(gsText, gvColor, gfAlpha);                llOwnerSay("Done!");            }        }    }}

 The NC would look like this:

// Comment lines start with //// Separate name value pairs with a equals sign "="
Text = Hello, World!Color = <1,0,0>Alpha = 1.0

 

  • Like 1

Share this post


Link to post
Share on other sites

It should indeed read "&&" and not "||" in:

if (llStringTrim(llGetSubString(data, 0,1), STRING_TRIM) != "//" && llStringTrim(data, STRING_TRIM) != "")

 Corrected it in the post above.

Share this post


Link to post
Share on other sites

To make it even more practical, you maybe want to add a changed(integer change) event, to automatically catch everytime the notecard is re-saved in the object.

This would look like this:

changed(integer change) {    // Resets the script everytime the objects inventory changed.    if (change & CHANGED_INVENTORY) {        llResetScript();     }}

 

Share this post


Link to post
Share on other sites

Ok I was playing with this one a little and I notice that I can add more lines with \n it just puts it in the text. I have to imagine I am missing something stupid at this point or is it not going to work the same with the notecard format?

Share this post


Link to post
Share on other sites

Try this:

 if (llToLower(sName) == "text") {     gsText = llDumpList2String(llParseString2List(sValue, ["\\n"], []), "\n"); }

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...