Iscopics Posted January 26, 2016 Share Posted January 26, 2016 Hello, world. Please critique my frist attempt to scripting in Secod Life.// Donation Jar Script. // Created by SIMPLE SCRIPT STUFF. // version alpha. // VARIABLES string topMessage = "Please donate to us. \n Thanks"; // <--- CHANGE THIS MESSSAGE TO CHANGE llSetText MESSAGE. // WARNING!!! // DONATIONS VALUES SAVE DON'T WORK, IT MEANS WHEN YOUR OBJECT STATE CHANGE (MOVES TO OTHER REGION, OR TO YOUR INVENTORY SCRIPT RESET. integer totalDonation = 0; integer largestDonation = 0; list payPrice = [10,20,30,40]; // <--- PLEASE CHANGE THIS VALUES TO SET PAY PRICE. // DIALOG - UNDER DEVELOPMENT integer CHANNEL = 42; list MENU_MAIN = ["OPTIONS", "ABOUT" ,"EXIT"]; list MENU_OPTIONS = ["Change Values", "EXIT"]; list MENU_ABOUT = ["EXIT"]; // OPTIONS - UNDER DEVELOPMENT default { on_rez(integer start_param) { llSetText("",<0,0,0>,0); totalDonation = 0; } state_entry() { llListen(CHANNEL, "", llGetOwner(), ""); // DIALOG APPEARS ONLY WHEN OWNER TOUCH OBJECT } touch_start(integer x) { llDialog(llDetectedKey(0), "What do you want, owner?", MENU_MAIN, CHANNEL); } listen(integer channel, string name, key id, string message) { if (llListFindList(MENU_MAIN + MENU_OPTIONS + MENU_ABOUT, [message]) != -1) { if (message == "OPTIONS") llDialog(id, "OPTIONS DIALOG", MENU_OPTIONS, CHANNEL); else if (message == "ABOUT") llDialog(id, "TODO : ABOUT" , MENU_ABOUT, CHANNEL); // TODO! else if (message == "EXIT") llOwnerSay("Good bye " + llKey2Name(id) + "!"); } } money(key giver, integer amount) { if(amount > largestDonation) largestDonation = amount; totalDonation = totalDonation + amount; string donationText = topMessage + "\n" + "Last Donation by: " + llKey2Name(giver) + "." + " Amount: " + " L$" + (string)amount + " \nTotal Donation: " + (string)totalDonation + " L$" + "\n Largest Donation: " + (string)largestDonation + "L$"; string whisperMessage = "Thanks for donation " + llKey2Name(giver) + "!!!"; llWhisper(0, whisperMessage); llSetText(donationText, <1,0,0>, 4.0); } } Link to comment Share on other sites More sharing options...
Ron Khondji Posted January 26, 2016 Share Posted January 26, 2016 You do not need an allways open llListen() for what you're doing.Better would be to open the llListen() just before llDialog() and close that llListen() again in the listen event.. And add a llSetTimerEvent() to close the llListen() when the user ignores or forgets the dialog.Remember to stop the timer in the listen or timer event. Which ever comes first. integer ListenHandle;default{ touch_start(integer x) { llSetTimerEvent(30.0); ListenHandle = llListen(CHANNEL, "", llGetOwner(), ""); // DIALOG APPEARS ONLY WHEN OWNER TOUCH OBJECT llDialog(llDetectedKey(0), "What do you want, owner?", MENU_MAIN, CHANNEL); } timer() { llSetTimerEvent(0.0); llListenRemove( ListenHandle ); } listen(integer channel, string name, key id, string message) { llSetTimerEvent(0.0); llListenRemove( ListenHandle ); if (llListFindList(MENU_MAIN + MENU_OPTIONS + MENU_ABOUT, [message]) != -1)etc. Something like that. Also.People say it's better to use a large negative integer as a channelnumber. Link to comment Share on other sites More sharing options...
Iscopics Posted January 26, 2016 Author Share Posted January 26, 2016 Thanks Ron, i will made the changes. Link to comment Share on other sites More sharing options...
steph Arnott Posted January 26, 2016 Share Posted January 26, 2016 "People say it's better to use a large negative integer as a channelnumber." it makes no difference, it just agreed that human chat in the positive channel, negative for script channels. BTW the script needs to be able to get back to the start else it will stop at the end if you close the listen handle. Typo Link to comment Share on other sites More sharing options...
Rolig Loon Posted January 26, 2016 Share Posted January 26, 2016 It's a good idea to get in the habit of using a large negative number as a chat channel for converations between objects to reduce the possibility of crosstalk with other objects that might be using the same channel (and the possibility of unauthorized listening, although there are better ways of doing that, if that's your concern). Link to comment Share on other sites More sharing options...
steph Arnott Posted January 26, 2016 Share Posted January 26, 2016 Sorry you lost me there, i was just saying that we keep script chat to negative and human to positive as a unofficial rule. I very much doubt if some used channel 12345678902334 it would affect anything. Problem is in the 1 to 100 as people would tend to use them. So in short get into the habit of the unofficial rule. ADDED, guess i wrot the first a bit ambiguose. Link to comment Share on other sites More sharing options...
steph Arnott Posted January 26, 2016 Share Posted January 26, 2016 just as curiosity, how many positive channels above 100 000 actualy get used? Zero? Link to comment Share on other sites More sharing options...
Rolig Loon Posted January 26, 2016 Share Posted January 26, 2016 There's no way to know. The full range of possible values is between −2,147,483,648 and +2,147,483,647, so there's a lot to choose from. The only advantage to using negative numbers rather than positive ones is that you can be sure that avatars will not be listening on negative channels. That's an interesting but not compelling reason for avoiding the positive ones, especially if you use very large, random numbers. As I said earlier, the best reason for using large numbers (positive or negative) is that it's unlikely that you will be using a channel that is already being used by some other object. That means it's unlikely that your object will interfere with another one or be overheard by it. You can also take extra security measures, of course, but the large random channel number is an easy first step. Link to comment Share on other sites More sharing options...
steph Arnott Posted January 26, 2016 Share Posted January 26, 2016 I use negative as a a rule to lock out non script communication, if i put a positive i would end up going back and changing it, just habit. Any how this not relivent to the op. 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