|
Abraxes Binder
Registered User
Join date: 23 May 2008
Posts: 205
|
05-23-2008 07:45
Hi, I wonder if it is posible to have a linked prim respond on different event-handlers. imagine a linked prim with n 'parts' If the *top prim is 'touched' the whole structure moves up *bottom prim is 'touched' the whole structure moves down *left prim is 'touched' the ... <you have guest it.. ;) >
These touch-prim would essential be 'buttons' on the whole structure I have embeded script into seperate prims (edit linked parts) but the 'click-a-billity' is not limited to the sub-prim (button). Any click on any part of the structure fires the touch event - Any sugestions?
BR ab
|
|
Shyan Graves
Registered User
Join date: 10 Feb 2007
Posts: 52
|
llDetectedLinkNumber() to determine button pressed
05-23-2008 08:02
Hi, If I got it right, your top prim, bottom prim, left prim, ... are seperate linked prims and not parts of a prim! If that is what you meant try llGetDetectedLinkNumber in the touch event of the root prim. To get a more readable value for your script you can name this button prims and then use llGetLinkName. Be aware of that if you have a script in the buttons with an touch event you also have to use llPassTouch. Regards, Shyan
|
|
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
|
05-23-2008 08:05
Yes, instead of making a script for each prim, give each prim a different name. Then when one is touched, a single script in the root prim can receive a touch_start event, and you can get the name of the prim that was touched with llGetLinkName(llDetectedLinkNumber()) or something similar. Then use some if/else statements to handle what should happen based on the name. Personally, I find it easier than managing 20 scripts just for button actions, and it helps reduce script load on the sim.
|
|
Dora Gustafson
Registered User
Join date: 13 Mar 2007
Posts: 779
|
05-23-2008 09:23
Put this in each prim that shall not pass the event to the parent default { state_entry() { llPassTouches( FALSE ); }
touch_start(integer num_detected) { // have to have a touch event handler } }
Oh my dear! who said faces??
_____________________
From Studio Dora
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
05-23-2008 09:51
Just to be very clear, this will work for different PRIMS just fine, as stated. It will NOT work for different FACES of a single prim (maybe someday LL will give us something like that, but it isn't available now).
|
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
05-23-2008 10:06
Here's the long and short of it: string buttonPressed; list direction = ["up", "down", "left", "right"]; list movement = [<0,0,1>,<0,0,-1>,<-1,0,0>,<1,0,0>];
default { touch_start(integer num) { vector position = llGetPos(); rotation rot = llGetRot(); buttonPressed = llGetLinkName(llDetectedLinkNumber(0)); integer dir = llListFindList (direction, [buttonPressed]); vector move = llList2Vector (movement, dir); position += move * rot; llSetPos (position); } }
Create 4 button prims, name them up, down, left, and right. Create the base prim, drop this script in it and save. Select the buttons first, and the base prim last, link, done.
|
|
Abraxes Binder
Registered User
Join date: 23 May 2008
Posts: 205
|
05-24-2008 01:46
Thank you so mutch for the explanations. BR ab
|