Dhuanolil Posted February 19, 2014 Share Posted February 19, 2014 Through a lot of Googling, dissecting freebie scripts, and trial and error, I managed to make the script below for dice:integer Chan=6; string ObjectName; default { state_entry() { llListen(Chan, "", NULL_KEY, "" ); } // This is for the emotive channel dice roll. listen( integer channel, string name, key id, string message ) { if (channel==Chan && id==llGetOwner()) { ObjectName=llGetObjectName(); llSetObjectName(""); string player = llGetDisplayName(llDetectedKey(0)); integer roll = (integer)(llFrand(100.0)+1); llSay(0, "/me " + "secondlife:///app/agent/" + (string) id + "/displayname rolled " + (string)roll + ", " + message); llSetObjectName(ObjectName); } } // This is for the simple click-to-roll dice. touch_start(integer num) { ObjectName=llGetObjectName(); llSetObjectName(""); string player = llGetDisplayName(llDetectedKey(0)); integer roll = (integer)(llFrand(100.0)+1); llSay(0, "/me " + player + " rolled " + (string)roll); } } However, players in the sim would like the ability to have a number bonus added to their dice if they rank up (perhaps +5 each time they rank up? There will only be four ranks). How can this be done? Is there a way for an admin to add a bonus to someone's dice?Any help would be appreciated. The dice will be free, copiable and transferable (though not modifiable; I don't want anyone hacking into them to add bonuses), and anyone who helps me here will have credit given to them. Thank you for reading. Link to comment Share on other sites More sharing options...
Ron Khondji Posted February 19, 2014 Share Posted February 19, 2014 I do not know the answer to your question.What I did notice was a very strange construction you use in your listen event. Instead of: string player = llGetDisplayName(llDetectedKey(0)); llSay(0, "/me " + "secondlife:///app/agent/" + (string) id + "/displayname rolled " + (string)roll + ", " + message); You could have done: string player = llGetDisplayName(id); llSay(0, "/me " + player + " rolled " + (string)roll + ", " + message); Because llDetectedKey() only works in touch and sensor events, and the key of the 'speaker' is allready available in the listen event. Link to comment Share on other sites More sharing options...
revochen Mayne Posted February 20, 2014 Share Posted February 20, 2014 The easiest way i can think of is by changing the touch_start event into: touch_start(integer num) { if(llDetectedName(0) == "Ed Min") // when bonus-admin touching the dice { llSay(0, "Player "+llKey2Name(llGetOwner())+" got +5 bonus!"); } else { ObjectName=llGetObjectName(); llSetObjectName(""); string player = llGetDisplayName(llDetectedKey(0)); integer roll = (integer)(llFrand(100.0)+1); llSay(0, "/me " + player + " rolled " + (string)roll); } } Link to comment Share on other sites More sharing options...
LepreKhaun Posted February 20, 2014 Share Posted February 20, 2014 Dhuanolil wrote: Through a lot of Googling, dissecting freebie scripts, and trial and error, I managed to make the script below for dice: integer Chan=6;string ObjectName;default{ state_entry() { llListen(Chan, "", NULL_KEY, "" ); }// This is for the emotive channel dice roll. listen( integer channel, string name, key id, string message ) { if (channel==Chan && id==llGetOwner()) { ObjectName=llGetObjectName(); llSetObjectName(""); string player = llGetDisplayName(llDetectedKey(0)); integer roll = (integer)(llFrand(100.0)+1); llSay(0, "/me " + "secondlife:///app/agent/" + (string) id + "/displayname rolled " + (string)roll + ", " + message); llSetObjectName(ObjectName); } }// This is for the simple click-to-roll dice. touch_start(integer num) { ObjectName=llGetObjectName(); llSetObjectName(""); string player = llGetDisplayName(llDetectedKey(0)); integer roll = (integer)(llFrand(100.0)+1); llSay(0, "/me " + player + " rolled " + (string)roll); }} However, players in the sim would like the ability to have a number bonus added to their dice if they rank up (perhaps +5 each time they rank up? There will only be four ranks). How can this be done? Is there a way for an admin to add a bonus to someone's dice? Any help would be appreciated. The dice will be free, copiable and transferable (though not modifiable; I don't want anyone hacking into them to add bonuses), and anyone who helps me here will have credit given to them. Thank you for reading. Simple answer: Learn LSL. Trying to "google a script" is going to result in just that, a take-it-or-leave-it script that is worth every bit you paid for. Do not bother to come here looking for others to do your work for you. Link to comment Share on other sites More sharing options...
irihapeti Posted February 20, 2014 Share Posted February 20, 2014 assuming that the dice are not connecting to some external game server then you need a way to persist the owner/players rank that will survive a script restart. Which i think is what you are also asking a way to do this is to store it in the description of the prim: llGetObjectDesc and llSetObjectDesc the general algo goes something like: rank = getdesc() roll = 1 + random(mag) + (rank * bonus) total += roll if (total == win) { rank += (rank < toprank) setdesc(rank) } rank * bonus 0 * 5 = 0 1 * 5 = 5 2 * 5 = 10 3 * 5 = 15 Link to comment Share on other sites More sharing options...
Dhuanolil Posted February 25, 2014 Author Share Posted February 25, 2014 Heya Ron! That is originally what I had done but, unfortunately, it would not work. It was only after I changed it that it would show the display name. Revochen - I will try that out. Thank you for your suggestion! LepreKhaun - I appreciate you took the time to respond, but it was unneeded. You can choose to believe me or not, but I have tried learning. Unfortunately I am not gifted when it comes to scripting or coding of any sort; even the simplest LSL is very difficult for me, though I have no doubt it is easy for you (though I hope to someday understand it, if I keep on trying). Nor was I expecting people to do my work for me -- it was just a hope that someone might be kind enough to give a bit of advice. Which Ron, Revochen, and Irihapeti were generous enough to do, and I appreciate their kindness. Irihapeti - Thank you! That was extremely helpful. I appreciate your response. Take care, all. Link to comment Share on other sites More sharing options...
LepreKhaun Posted February 25, 2014 Share Posted February 25, 2014 Whatever gave you the idea that learning LSL was easy for any of us? One never learned to walk by asking to be carried. 1 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