Jump to content

how to detect the presence of a notecard in a prim


Sylvia Wasp
 Share

You are about to reply to a thread that has been inactive for 1967 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hey, 

I've been trying to figure this out for a long time and I'm so desperate for time now (to complete my project) that I'm finally willing to subject myself to the inevitable bullying and showboating that will definitely occur here, because I know the answer is simple and I just want to get it done! :) 

I code my own vendors but I'm not the best coder.  I use a notecard to list the items in the vendor and everything works perfectly except when the list on the notecard is empty.  When the vendor is *active* but the notecard list is *empty* the vendor display shows that it has "1 of 1 items for $0" because even that empty notecard always has a carriage return.  On the other hand, if I delete the notecard, then the script errors out.  

What I want to do is insert a snippet that basically says: "If the notecard isn't there, then (do something)."  

Just because it would be cleaner.  

 

Everything I've found when I've searched for notecard code is inevitably about how to *read* notecards, and the whole database request thingie which is super confusing to regular mortals and not a box I want to open again now it's already working right.  I just want a snippet that examines the prim inventory and shoots back if a notecard is found.  I know this is in the LSL wiki somewhere but again, for NON-coders, the LSL wiki is a confusing mess and I'm kind of out of time.  

Here's hoping someone has a quick, simple, easy to understand answer for me :) 


Before you get started, I'm NOT AT ALL interested in:

- your advice on why I shouldn't make my own vendors

- advice on why my problem is "stupid" because you don't see the reason for me wanting what I want

- long complicated advice on how to *read* a notecard and the proper use of database request .... Zzzzzz ... 

- long bits of code on some completely different style of vendor that's "so much better" than mine

- advice on how you personally would re-do my entire project etc. 

thanks, 

Sylvia :) 

Edited by Sylvia Wasp
Link to comment
Share on other sites

8 minutes ago, Sylvia Wasp said:

Hey, 

I've been trying to figure this out for a long time and I'm so desperate for time now (to complete my project) that I'm finally willing to subject myself to the inevitable bullying and showboating that will definitely occur here, because I know the answer is simple and I just want to get it done! :) 

I code my own vendors but I'm not the best coder.  I use a notecard to list the items in the vendor and everything works perfectly except when the list on the notecard is empty.  When the vendor is *active* but the notecard list is *empty* the vendor display shows that it has "1 of 1 items for $0" because even that empty notecard always has a carriage return.  On the other hand, if I delete the notecard, then the script errors out.  

What I want to do is insert a snippet that basically says: "If the notecard isn't there, then (do something)."  

Just because it would be cleaner.  

 

Everything I've found when I've searched for notecard code is inevitably about how to *read* notecards, and the whole database request thingie which is super confusing to regular mortals and not a box I want to open again now it's already working right.  I just want a snippet that examines the prim inventory and shoots back if a notecard is found.  I know this is in the LSL wiki somewhere but again, for NON-coders, the LSL wiki is a confusing mess and I'm kind of out of time.  

Here's hoping someone has a quick, simple, easy to understand answer for me :) 


Before you get started, I'm NOT AT ALL interested in:

- your advice on why I shouldn't make my own vendors

- advice on why my problem is "stupid" because you don't see the reason for me wanting what I want

- long complicated advice on how to *read* a notecard and the proper use of database request .... Zzzzzz ... 

- long bits of code on some completely different style of vendor that's "so much better" than mine

- advice on how you personally would re-do my entire project etc. 

thanks, 

Sylvia :) 

Good luck.

Link to comment
Share on other sites

Something based on this should do it

integer iCounter;
key kQuery;
string strNotecard = "Config";//or whatever your notecard is called
default
{
	state_entry()
	{
		if(llGetInventoryType(strNotecard)==INVENTORY_NOTECARD){
			//if there's a notecard called "Config" in the object's inventory
			iCounter = 0;
			kQuery = llGetNotecardLine(strNotecard,iCounter);
		}
	}

	dataserver(key requested, string data)
	{
		if(requested == kQuery){
			if (data != EOF){
				data = llStringTrim(data,STRING_TRIM);//trim non-printing characters, like spaces and carriage returns, from the start and end of the line
				if(data){
					//if there's anything left, then process it
				}

			}

		}
	}
}

 

Edited by Innula Zenovka
  • Like 1
Link to comment
Share on other sites

if ( llGetInventoryType("My Notecard") == INVENTORY_NOTECARD)

{

   // Go ahead and read the notecard named "My Notecard"

}

else

{

    llSay( 0,"There is no notecard named \"My Notecard\" in the vendor." );

}

EDIT:   Innula beat me to it, with a more complete example, but the idea is the same. :)

Edited by Rolig Loon
  • Like 1
Link to comment
Share on other sites

20 hours ago, Rolig Loon said:

if ( llGetInventoryType("My Notecard") == INVENTORY_NOTECARD)

{

   // Go ahead and read the notecard named "My Notecard"

}

else

{

    llSay( 0,"There is no notecard named \"My Notecard\" in the vendor." );

}

EDIT:   Innula beat me to it, with a more complete example, but the idea is the same. :)

Thanks Rolig!!! 🙂  

I actually think you win the thread here. You answered my question both more succinctly and in exactly the way I wanted.  

Many thanks to Innula Zenovka also for the snippet relating to reading the notecard.   

Sylvia

PS - Relating to the "snark" ... no offence meant to anyone.  I just have a lot of experience over a lot of years asking questions here and what I described is exactly what happens about 80% of the time.  And by "80%" I really mean 95%. :) 

It's not just here, it happens on pretty much every Internet forum ever.  

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1967 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...