Jump to content

Note Reader Script for a vendor


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

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

Recommended Posts

Hello, Im a little lost with this one, I have seen vendor systems that allow you to simply list off all the products, and prices, and even have different categorys for those products. I have failed to fine one that works totally how I want it too, and am seeing help in the right direction on how to script my own.

I guess I should work on categorys first, Im guessing this is done with lists, and so I kind of have an idea how to do that, add the product names to the list, but what is a good way to make a category or even maybe a sub-category for this?

Something else that would help is how make a script that can read a note card and know that if it has like "PRODUCT:Jacket" it knows that since there is PRODUCT: that the object for sell is a Jacket. or if it has "PRICE:50" it knows that because PRICE is there it costs 50. Below is the lay out I want in the notecard:

CATEGORY: =Main Option; like Clothing, Accessories, Weapons)

SUBCAT: =Second level; like Male or Female clothing, Boots, Glasses, Swords, or Guns)

PRODUCT: =the Product itself that is to be sold)

PRICE: =the cost of the object)

SPLIT: =I want to give a % of the sell to others, but not on every object, so it should be per object for sell)

Its also important that I dont have to us a per notecard line type script, like have the script look on a given line for what it needs.

I know its unlikely 1 person will have all the information I need, so any and all information anyone can provide would be greatful! Thank you for reading.



Link to post
Share on other sites

Not hard at all. You read the card in a dataserver event that is built around code like this.

    list temp = llParseString2List(msg,["="],[]);    if (llToLower(llStringTrim(llList2String(temp,0),STRING_TRIM)) == "product")    {        gProducts += [llStringTrim(llList2String(temp,1),STRING_TRIM)];    }    else if (llToLower(llStringTrim(llList2String(temp,0),STRING_TRIM)) == "price")    {        gPrices += [(integer)llStringTrim(llList2String(temp,1),STRING_TRIM)];    }

 And so forth.  When you reach EOF, go on to read the next card.  When you're all done, you have the product names, prices, and everything else in parallel global lists.  When you need to get the price of something, look for its name, find its position in the gProducts list, and then use the same index to find the price in gPrices.

 

  • Like 1
Link to post
Share on other sites

so, the position in the gProducts will be the same as the position of its price in gPrices?

Ill try it out of course, just making sure I understand correctly, also in your script that has "list temp = llParesString2List(msg,["="]..... and so on, is the "=" the part that is between the Product and Name of the product like "PRODUCT=Super Man Outfit"?

Link to post
Share on other sites

Yup.  Lists are a litle scary at first, so it's smart to spend an afternon (or longer) digesting everything that the LSL wiki has to say about them.  As with most scripting, though, the heart of the challenge is not the syntax.  It's the logic that you apply to getting where you want to go.  In this case, you have several kinds of information in separate lines on each notecard that your vendor will have to read.

So the first problem is how to recognize which kind of information is on each line.  That's where you use llParseString2List, which (as I wrote it in my example) separates the data read on a line into two list elements: a keyword and a content variable. I told the function to look for "=" as the marker between elements.  See >> http://wiki.secondlife.com/wiki/LlParseString2List

The other problem is to keep track of which list elements were together on the same card. That's really easy. If you always read the same elements off of each card, then every time you add data to one list, it's added in the same order as data is added to the other lists.  The name of PRODUCT read from card #10 is in the same position in gProducts as its PRICE in is gPrices.  Whenever you want to find either one later, just say "Find me the tenth item on the list." (Just remember that lists are numbered starting at zero, so the tenth product is llList2String(gProducts,9), for example.)

  • Like 2
Link to post
Share on other sites

You are extreamly helpful! thank you yet again!

Another question though, Im going to do that SPLIT thing where I share part of the sell with others, but Im not going to do that for every item, from what Im understanding, even if I dont split the profile, I should still put some value in the split for every item? since if I dont, it will mess up the split list..thingy.. right?

Link to post
Share on other sites
You are about to reply to a thread that has been inactive for 3315 days.

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

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.

×
×
  • Create New...