These forums are CLOSED. Please visit the new forums HERE
touch start - setting owner permissions |
|
|
Johnathan Padar
Registered User
Join date: 27 Jul 2005
Posts: 23
|
02-07-2006 06:24
hello, when you create a new script and it says hello avatar! when you touch it, how do you change it to where only the owner of the object can make it work to say hello avatar?
|
|
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
|
02-07-2006 07:11
Hi, Johnathan.
Here is the relevant code from the new script: CODE touch_start(integer total_number)We can't prevent other residents from touching the object, but we can ignore them by checking their key. An av's key is their unique identifier - and all object know what their owner's key is (using llGetOwner). Inside the touch_start event handler we have access to the detection functions. The one you want is llDetectedKey, which returns the key of the av touching the object. So you want to have something like CODE if ( llDetectedKey(XXX) == llGetOwner() )where XXX is a number. What number? Well, many events can be triggered by multiple actions. For example, if you touch an object, the system calls touch_start(1) to let it know that there is only 1 touch event. If I touch, the same thing happens. If we both touch it at more or less the same time, touch_start gets called once, but with a total_number value of 2 instead. If 7 people touch it together, the system calls touch_start(7), and so on. If total_number is 1, then we only need to check the first llDetectedKey - but as is traditional with most programming languages, we start counting detected keys from 0, not from 1. So the first key is llDetectedKey(0). If total_number is 2, we need to check llDetectedKey(0) and llDetectedKey(1). Make sure you understand this code: CODE touch_start(integer total_number)(Sorry if I'm overexplaining - but even if you already know this, there may be someone else that doesn't )Now that code will work fine - but for bonus points, work out why I usually write it something like this: CODE touch_start(integer total_number) Edit: Brackets fixed - thanks for the save, El. |
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
02-07-2006 07:16
And try it with curved not square brackets around the llDetectedKey(0) and llDetectedKey(i) sections!
Ben must have posted just as I was scribbling the code myself! |
|
Johnathan Padar
Registered User
Join date: 27 Jul 2005
Posts: 23
|
02-07-2006 07:50
=) cool...ok what about setting it to where a group could make it work i tried
if ( llDetectedOwner(0) == llGetOwner() ) ( llDetectedGroup) ) but that didn't seem to work. |
|
Folco Boffin
Mad Moo Cow Cultist
Join date: 27 Feb 2005
Posts: 66
|
02-07-2006 17:21
To steal the earlier code...
CODE touch_start(integer total_number) The object has to be set (don't think it needs be deeded for llDetectedGroup, but I could be wrong) to the group you are checking against. And the person touching has to have that group active. The following also does the exact same thing: CODE touch_start(integer total_number) _____________________
^-^
Signed, Gorgarath, Whom in this game called Second Life, plays the avatar Folco Boffin, and in this game called First Life, plays the avatar John McDonnell. |
|
Sky Honey
Coder
Join date: 16 May 2005
Posts: 105
|
02-08-2006 06:11
Great explanation, Ben! It really makes me wish for that tutorial about rotations you promised a couple of weeks ago
![]() |
|
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
|
02-08-2006 06:18
Great explanation, Ben! It really makes me wish for that tutorial about rotations you promised a couple of weeks ago ![]() had some RL deadlines that got in the way got some commitments to get out of the way soon, and then I'll finish it up. ![]() |
|
Sky Honey
Coder
Join date: 16 May 2005
Posts: 105
|
02-08-2006 06:24
haven't forgotten, sky had some RL deadlines that got in the way got some commitments to get out of the way soon, and then I'll finish it up. ![]() RL! Hey, time to set your priorities! Just kidding, we're looking forward to it whenever you can manage it, thanks ![]() |