Another please help moment
|
|
Keith Richter
Registered User
Join date: 27 Jan 2007
Posts: 21
|
10-05-2008 08:53
I'm trying to figure out the trick to getting an object to say the owners name right before the rest of another phrase as it will be changing owners a lot. My attempt is posted below and I'm not quite sure how to go about getting this to work. string ownername = _______; default { state_entry() { } touch_start(integer num_detected) { llWhisper(0, ownername+" is such and such"  ; } } and while I have your attention instead of posting another thread if you can help with Problem B as well that'd be nice. I'm trying to create a random chance system so that after you touch it, it'll generate a random number (i'm using llFrand right now) and depending on that number what will happen. Example: number>50 success number<50 failure. I am completely lost on this one but here is my rough attempt after half an hour: string ownername = ______; integer chance = 0; default { state_entry() { } touch_start(integer num_detected) { llWhisper(0, ownername+" is trying to do so and so"  ; chance = llFrand(1-100); if(chance>50) { llWhisper(0,ownername+" has successfully done so and so"  ; } } } as you can see its part of the same basic script.
|
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
10-05-2008 10:02
to get the owner name you need to use llKey2Name(llGetOwner()); like this From: someone default { state_entry() { } touch_start(integer num_detected) { llWhisper(0, llKey2Name(llGetOwner()) +" is such and such"  ; } } as for generating a random number, llFrand generates a number between 0 and the number in the field. so if you want a number between 1 and 100 it would be: llFrand(99) + 1 or to get a rounded number rather than a number with a decimal llRound(llFrand(99) + 1) like this From: someone integer chance; default { state_entry() { } touch_start(integer num_detected) { llWhisper(0, llKey2Name(llGetOwner()) +" is trying to do so and so"  ; chance = llRound(llFrand(99) + 1); if(chance>50) { llWhisper(0,llKey2Name(llGetOwner()) +" has successfully done so and so"  ; } } }
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
10-05-2008 11:20
Note that if the owner is not present (basically in the same sim), you will need to use llRequestAgentData() instead of llKey2Name(). It's a little more complicated, so I'm not going to post an example and confuse you unless you state that you need it. You can always read about it in the wiki and post a question back here if you really can't figure out how to use it: http://www.lslwiki.net/lslwiki/wakka.php?wakka=llRequestAgentDataI also suggest naming your threads in a way that gives more context to the readers. "Need help" type titles don't give much information, and many people might simply not bother following the link. A decent title for this thread might have been "Getting owner name and testing llFrand() result" for example.
|
|
Keith Richter
Registered User
Join date: 27 Jan 2007
Posts: 21
|
10-05-2008 11:30
Thanks a lot guys, and nah the people will be wearing the object so we don't need to get into complex stuff. But thanks a lot, learnin more every day (still a lot to learn).
|
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
10-05-2008 12:07
From: Keith Richter Thanks a lot guys, and nah the people will be wearing the object so we don't need to get into complex stuff. But thanks a lot, learnin more every day (still a lot to learn). yep, we've all been there, i still am alot of days. like the thing about llGetOwner, i had no idea that the owner needed to be in the same sim. just curious, what does it return if the owner's not there? (not in world to check it out) edit: nevermind, i thought you meant the llGetOwner that didn't work with the owner not present, but it's the llKey2Name (which also works on objects apparently) like keith said, it's a worn object, which is something i've only ever used it for as listen events already get the name and the key of the person/object talking, and detected events (touch, collision, and sensor) also have similar functions
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
10-05-2008 12:36
From: Ruthven Willenov [...]to get a rounded number rather than a number with a decimal
llRound(llFrand(99) + 1)
like this Rounding the result of llFrand() is trickier than one might think, assuming one wants to get a uniform distribution of all the possible results. See the "Rounding" section of http://lslwiki.net/lslwiki/wakka.php?wakka=llFrand for details. What I think is needed to make the result of 100 to be equally likely as that of 1 through 99 is just a cast: (integer)llFrand(101.0). [Edit: No, I don't think that! That's what I get for pushing Submit while dashing off to RL. Of course it should be (integer)llFrand(100.0) + 1 because we don't want the range 0-100, but rather 1-100.]
|
|
Keith Richter
Registered User
Join date: 27 Jan 2007
Posts: 21
|
10-05-2008 15:21
Well after spending all morning scripting for a friend's new sim he's making I've encountered yet another problem I thought I'd try asking here again instead of making ANOTHER thread for it to see if i can save space for people. I have the set up of if(message == "1"  and then the set up of events, is there a way to specify if it gets a message on that channel of anything other then "1" to do a certain action? ex. it works on channel 99 and it hears "2" or "5" or "1938438" instead of "1" Is there a way to make the object then set up a new course of action without having to specify the if message == 2 or 5 or 1938438? I probly restated the same question three times but trying to be clear about it lol.
|
|
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
|
10-05-2008 16:26
So are you basically wanting it to do something if the message is *not* 1? This would do the trick: if (message != "1"  { // do something... } Alternatively, if you make it do one thing for 1 and something else for any other message, then this would work too: if (message == "1"  { // do something } else { // do something else }
|
|
Keith Richter
Registered User
Join date: 27 Jan 2007
Posts: 21
|
10-06-2008 10:24
Thanks again, and of course I have another problem I can't figure out. (In my defense I manage to figure out much more on my own then get stumped on so at least i'm really trying here).
I'm trying to give this object limited usage until it stops working and needs to be replaced and was wondering how to go about doing that. I have been trying to read through gun scripts but the ones that use ammo limits also have a really long and complex script and I cant find the pieces I'm looking for. I'm basically commpletely lost in trying to limit the usage and whatnot, any other tips? ((btw it works on touch activation if thats necessary info or anything.))
|
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
10-06-2008 11:47
that should be quite easy actually for a touch event From: someone integer limit = 10; default { touch_start(integer num_detected) { if (num_detected == limit) { llOwnerSay("you have reached the limit"  ; } }
|
|
Keith Richter
Registered User
Join date: 27 Jan 2007
Posts: 21
|
10-06-2008 12:26
okay after messing around with what you gave me it doesn't seem to be working. I click on it a lot of times and the message never comes up, it doesn't seem to be keeping track of how many times its being touched. I tried to do some random stuff like add "limit - 1" to the script (no not with the quotations) but still seems to be uncooperative.
|
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
10-06-2008 12:59
hmm, well i'm not in world to try it, but it looks like it should work, maybe try reversing it to if(limit == num_detected) if that doesn't work you could try this one integer limit = 10; integer numtchd; default { touch_start(integer num_detected) { numtchd = numtchd + 1; if (numtchd == limit) { llOwnerSay("you have reached the limit"  ; } }
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
10-06-2008 13:22
This will count down from 10, subtracting 1 every time it is touched. Once it hits the limit it will remove the script or if you uncomment llDie; the object will vanish. integer limit = 10;
default{ touch_start(integer num_detected){ if (limit > 0){ //do stuff here } else{ llOwnerSay("you have reached the limit"); llRemoveInventory(llGetScriptName()); //llDie(); } limit--;//this subtracts 1 from limit } } EDIT: Test this script like it is. I have forgotten if the script can be removed while it is attached. At the very least it will stop working.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Keith Richter
Registered User
Join date: 27 Jan 2007
Posts: 21
|
10-07-2008 11:43
Thanks a lot guys this is really helping, and I'm learning a bunch of interesting tricks on the side just for some concepts I'm learning here. But alas, I have come with yet another issue! None of my friends are scripters that I can learn from and the people i've asked are never quite clear or misunderstand the idea (and busy doing their own thing).
Anyways new thing I think would be really simple but I just can't figure out the commands to set it up, but the idea is to cause something to shift from visible to invisible slowly. I know theres llSetAlpha but that is instant, i was looking for a way to make it fade a bit more gradually for effect as opposed to BLINK its gone.
|
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
10-07-2008 12:44
probably need something like this for that.  also i have a script that listens for an alpha value and fades it to that value, i can't remember where i found it. i can post it here or pass it to you in world when i get home later
|
|
Keith Richter
Registered User
Join date: 27 Jan 2007
Posts: 21
|
10-07-2008 14:35
Okay so I'm reading through the script you linked, then trying to patch up the errors in world. Still lost as hell while trying to make it work. I'ma keep trying but if theres any additional info or fully operating demonstrations instead of one with 12 errors that would help. Also while we're on this, I'm hoping that the same commands and concepts used to do this texture fade will also apply to objects but if not My next problem will relate to making objects move at a certain speed without jumping into place.
now back to tinkering with thsi script.
|
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
10-07-2008 14:47
i just realized the script i directed you to isn't a full script, but a function you would add to a script
you can do a slow move by using llSetPos by using steps, but it might be choppy. you can do it with llMoveToTarget, but it would have to be physical, but it would be easier to script
|