|
Kakashi Okamoto
Registered User
Join date: 12 Jul 2006
Posts: 32
|
08-18-2006 19:31
What Im trying to do is hold one object, then with some kind of trigger (said word, or key pressed) have the object be switched with another. All of this time though, the object is attached to my right hand, so the second one needs to be attached to my hand as well.
Whats the basic of going about doing this?
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
08-18-2006 22:33
Well, let's see. Something like: integer CHANNEL = 45; string ATTACH_CMD = "equip";
integer listenHandle = 0;
startListen() { if (listenHandle > 0) { llListenRemove(listenHandle); } listenHandle = llListen(CHANNEL, "", llGetOwner(), ATTACH_CMD); }
default { state_entry() { startListen(); }
on_rez() { startListen(); }
listen(integer channel, string name, key id, string message) { // Our filter only allows the owner and a single message, so no need to // test. Just be careful if adding additional messages in future.
llRequestPermissions(llGetOwner(), PERMISSION_ATTACH); }
run_time_permissions(integer perms) { if perms & PERMISSION_ATTACH) { // Note: Anything already attached to the right hand will be // automatically detached. You might want to implement the 'attach' // event handler in that object and/or this if anything needs to be // done at that point.
llAttachToAvatar(ATTACH_RHAND); } } }
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
08-18-2006 23:44
It depends how smooth you want it to be. You could have object A rezzing object B and then detaching itself, and then B attaches (using something like the above for the B) but it will take a little time, and B will need to be rezzed not attached - you can't rez something already attached.
If you're wanting some sort of special effect transforming device, you would be better off building a device that performs both sets of functions, with both sets of prims, and then making some of them appear and some of them disappear using llSetAlpha and llSetLinkAlpha. Setting the alpha of a prim to 0.0 makes it invisible and setting it to 1.0 makes it visible. Since it's an attachment you don't have to worry about the invisible prims bumping into things.
|
|
Kakashi Okamoto
Registered User
Join date: 12 Jul 2006
Posts: 32
|
08-19-2006 08:31
well, Its going to be like a butterfly knife or switchblade, so smooth would be nice, in terms of how fast one switches with the other, but it doesnt need to have any transforming special effects.
So if I want my butterfly knife to open from a closed position, Im going to need the open objects on the closed one invisible with the alpha's set, so that when the trigger is said, on dissapears and the other appears?
|