LegitBonzai Posted January 27, 2023 Share Posted January 27, 2023 (edited) I am looking for a counter script that gives me the number of how much times a item i sell inworld is been bought. I am selling stuff for free. And would like to keep track on what item is been liked the most. where do i look for such thing? I dont know about scripting. So if you wanna teach me, do it step by step and not in big lines. Thank you. Edited January 27, 2023 by LegitBonzai Link to comment Share on other sites More sharing options...
Fenix Eldritch Posted January 27, 2023 Share Posted January 27, 2023 32 minutes ago, LegitBonzai said: So if you wanna teach me I think the more pressing question would be "if you wanna learn" The wiki is a wealth of information, and has lots of tutorials. These two would be a good starting point, and they're not too long: A Gentle LSL Introduction A Basic LSL Tutorial As for your project... The typical way to keep track of this would be with a vendor that uses the money event. When a person pays the vendor object, the money event triggers and can run whatever code is in it. There is where you could give out the selected object and if desired, increment a counter that keeps track of sales. However I don't think that will work the same if the object is being sold for L$0, as you can't pay a sum of 0. So instead, I think you'll have to use the touch event to just blindly give out the item to the person who touched the vendor and track accordingly. This is a slightly modified demo using the example code from llGiveInventory's wiki page: integer totalA; //global variable to count times we give out objectA default { touch_start(integer n) { llGiveInventory(llDetectedKey(0), "test_object_A"); totalA++; //increment the ccounter llOwnerSay("we have given out 'test_object_A' "+(string)totalA+" times"); //sample report } } This example assumes one object per vendor, but you can build upon that by using various methods to select different contents to give/track. Such as llDialog, or parsing local chat, or even building prim buttons into the vendor. 1 Link to comment Share on other sites More sharing options...
LegitBonzai Posted January 28, 2023 Author Share Posted January 28, 2023 Ooh yes. That works to. Thank you so much Link to comment Share on other sites More sharing options...
LegitBonzai Posted January 28, 2023 Author Share Posted January 28, 2023 On 1/27/2023 at 1:54 PM, Fenix Eldritch said: I think the more pressing question would be "if you wanna learn" The wiki is a wealth of information, and has lots of tutorials. These two would be a good starting point, and they're not too long: A Gentle LSL Introduction A Basic LSL Tutorial As for your project... The typical way to keep track of this would be with a vendor that uses the money event. When a person pays the vendor object, the money event triggers and can run whatever code is in it. There is where you could give out the selected object and if desired, increment a counter that keeps track of sales. However I don't think that will work the same if the object is being sold for L$0, as you can't pay a sum of 0. So instead, I think you'll have to use the touch event to just blindly give out the item to the person who touched the vendor and track accordingly. This is a slightly modified demo using the example code from llGiveInventory's wiki page: integer totalA; //global variable to count times we give out objectA default { touch_start(integer n) { llGiveInventory(llDetectedKey(0), "test_object_A"); totalA++; //increment the ccounter llOwnerSay("we have given out 'test_object_A' "+(string)totalA+" times"); //sample report } } This example assumes one object per vendor, but you can build upon that by using various methods to select different contents to give/track. Such as llDialog, or parsing local chat, or even building prim buttons into the vendor. And its not that i dont want to learn.. I just dont understand this kind of code... Is it possible to have a timer in it? So people can only grab one copy per hour or something? Link to comment Share on other sites More sharing options...
Fenix Eldritch Posted January 28, 2023 Share Posted January 28, 2023 (edited) Most of programming in general is really just working out the logic; the step-by-step process for what you want to accomplish. What remains is just syntax (what functions you have available to you, the formatting and rules of whatever language you're using). It can be daunting at first, but once you get familiar with things, it can be great fun! The "gentle LSL introduction" I linked above is specifically geared towards those with little to no programming experience, so if you're very new to it, that would be an excellent place to begin. Give it a read, try some of the examples, and if you have questions, definitely ask them here, as we'll be happy to answer. As for your timer question, yes that certainly is possible. As you'll soon learn, there are many ways to accomplish a given task via coding. One possible approach would be to record the uuid of the avatar when they activate the dispenser, along with the time at which they activated it. Store both of those values somewhere (the recently added linkset data would be a good choice). Then, the next time anyone activates the dispenser, it will first compare the uuid of the person currently activating it and see if it has that same value stored away. If it does, compare the time associated with that uuid with the current time and check if it's within the allowed timeout range (i.e. is it older than an hour?) If so, dispense the object again. Otherwise deny giving the object out, because enough time hasn't elapsed. Edited January 28, 2023 by Fenix Eldritch Link to comment Share on other sites More sharing options...
LegitBonzai Posted January 28, 2023 Author Share Posted January 28, 2023 See. i am already lost in what you are saying. 0.o my main language isnt english Link to comment Share on other sites More sharing options...
Fenix Eldritch Posted January 28, 2023 Share Posted January 28, 2023 Ah, that may complicate things. I don't know how well an automatic translation of the wiki pages might work, but it still may be worth trying it you are interesting in learning to script. Here's a simple demo of what I was talking about in my last post. It uses comments and llOwnerSay commands to narrate what it's doing. It's not a complete solution by any means, but perhaps you can start to tinker with it if you're feeling brave. integer timeout = 60; //number of seconds to wait before giving objec to same person default { state_entry() { llLinksetDataReset(); //empty LSD on startup llOwnerSay("time between giving items to repeat visitors: "+(string)timeout+" seconds"); } touch_start(integer n) { key avatar = llDetectedKey(0); //current avatar ID integer time = (integer)llGetGMTclock(); //current activation time (in seconds) string s = llLinksetDataRead(avatar); //check if avatar is in LinksetData already if(s) //it is was, the value we read won't be empty { integer timediff = time - (integer)s; //difference between saved time and current time //llOwnerSay("test time-currTime: "+(string)time+"-"+s+"="+(string)timediff); //DEBUG if(timediff<0 || timediff>timeout) //if difference is greater than timeout, or negative, give item { llOwnerSay(llKey2Name(avatar)+" is past timeout, give item"); llLinksetDataWrite(avatar,(string)time); //update record } else { llOwnerSay(llKey2Name(avatar)+" is too early: "+(string)timediff); } } else //if avatar wasn't in LinksetData, the value returned will be empty { llOwnerSay(llKey2Name(avatar)+" has no prior record, give item"); llLinksetDataWrite(avatar,(string)time); //update record } } } Link to comment Share on other sites More sharing options...
LegitBonzai Posted January 28, 2023 Author Share Posted January 28, 2023 "empty LSD on startup" i kinda stopped using weed already... so i am good. 1 Link to comment Share on other sites More sharing options...
LegitBonzai Posted January 28, 2023 Author Share Posted January 28, 2023 do in line 14,19 i get a error. Can you explain me whats going wrong here? string s = llLinksetDataRead(avatar); line 23,16: llLinksetDataWrite(avatar,(string)time); line 33,12 llLinksetDataWrite(avatar,(string)time); Link to comment Share on other sites More sharing options...
LegitBonzai Posted January 28, 2023 Author Share Posted January 28, 2023 meanwhile i am making a project out of this: https://wiki.secondlife.com/wiki/LSL_101/The_Structure_of_a_Script Link to comment Share on other sites More sharing options...
Fenix Eldritch Posted January 28, 2023 Share Posted January 28, 2023 What is the error message you're being given? Link to comment Share on other sites More sharing options...
LegitBonzai Posted January 29, 2023 Author Share Posted January 29, 2023 (edited) I made a snap. Edited January 29, 2023 by LegitBonzai Link to comment Share on other sites More sharing options...
Fenix Eldritch Posted January 29, 2023 Share Posted January 29, 2023 "undefined constant/function/variable" means the compiler does not recognize something on the mentioned lines. In this case, I'm guessing it doesn't like the llLinksetData functions. All servers on the Second Life grid should be aware of this new feature, so it shouldn't matter what region you're in when you attempt to compile this script. This does not appear to be the official Linden viewer, so that might be the reason. What viewer are you using and how old is it? If possible, try updating it and see if the problem persists. And if you still get the error, try using a different viewer. Link to comment Share on other sites More sharing options...
LegitBonzai Posted January 29, 2023 Author Share Posted January 29, 2023 (edited) I am using firestorm.. And i also forgot to say.. i am using this on a open grid i just tried it in second life. and it seems to work with no problem Edited January 29, 2023 by LegitBonzai Link to comment Share on other sites More sharing options...
Fenix Eldritch Posted January 29, 2023 Share Posted January 29, 2023 Ah, that'll do it. Open Grid is a separate entity from Second Life and does not have complete parity with SL when it comes to things like LSL functionality and function availability. Another solution that doesn't involve LinksetData would be to instead store the avatar's uuid and access time within a list in the scripts' own memory. I would look at strided lists as a possible application: were each stride contains the avatar's uuid/key and the access timestamp. The thought process would be similar to the previous example: search the list to see if the avatar's key exists within it if the key is found, pull out the associated time and check if it's past the timeout range. if the timeout has elapsed, give the item and update the list with the current time for this avatar if we didn't fined the avatar key in #2, then give them the item and add the avatar's key and timestamp to the list. 1 Link to comment Share on other sites More sharing options...
LegitBonzai Posted January 31, 2023 Author Share Posted January 31, 2023 Sorry. I dont understand this. Link to comment Share on other sites More sharing options...
Recommended Posts
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