Rezzing Object With Script
|
Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
|
08-13-2005 17:29
I am using llRezObject() to rez an object from an objects inventory. It rezzes out fine. Though, how in world do I get the object to orient depending on the direction I am facing in-world? So, no matter which direction I am facing the object rezzes up in front of me so I can intreract with it.
I tried some scripts I found in my forums search and none had the effect I was looking for. I'm not much the math person so I couldn't figure how to modify them to my liking.
Thanks
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
08-13-2005 17:47
I'm going to assume here that the object rezzes on touching the source object. state default { touch_start( integer n ) { vector pos = llDetectedPos(0) + ( llRot2Fwd(llDetectedRot(0)) * 2 ); // Where the toucher is, plus two meters in "front" if ( llVecDist(pos, llGetPos()) < 9.5 ) // Can only rez up to 10 meters distant. { llRezObject("thing", pos, ZERO_VECTOR, ZERO_ROTATION, 0); } else { llSay(0, "Please step closer."); } } } If not by touch, then it's similar with a sensor, which you'll need to get the avatar's position.
|
Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
|
08-13-2005 19:27
Hey, this works great for putting the object in front of me. Thanks! Although, the rezzed object still faces up towards the sky and is not turned around correctly to face towards me. Any way to fix this part?
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
08-13-2005 19:54
Yes there is. However, I'm not all that good with rotations, and since you say the object is facing skyward, that means having to deal with all three axes of rotation, and that's a bit beyond my ken. Now, either one of the resident geniuses will be along to save us, or... if you could modify the obect so then when it's root object is rotated zero degrees on all axes (as it is when that script rezzes it up) it's facing east, then I could easily make it face you, as it would be down to dealing with just the one axis.
|
Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
|
08-13-2005 20:02
I modified the linked object. It is now all zeroed out as far as rotation goes. With it zeroed out it faces the sky.
|
Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
|
08-13-2005 20:11
Ok, done. Got the parent modified so when linked up it now faces east with a rotation all set to 0.
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
08-13-2005 20:38
Kewlies. Then this could do it: (And, for once, this is compiled and tested in-world.) default { touch_start( integer n ) { vector pos = llDetectedPos(0) + ( llRot2Fwd(llDetectedRot(0)) * 2 ); // Where the toucher is, plus two meters in "front" rotation rot = llDetectedRot(0) * <0.0, 0.0, 1.0, 0.0>; if ( llVecDist(pos, llGetPos()) < 9.5 ) // Can only rez up to 10 meters distant. { llRezObject("thing", pos, ZERO_VECTOR, rot, 0); } else { llSay(0, "Please step closer."); } } }
|
Kurshie Muromachi
Primtastic!
Join date: 24 Apr 2005
Posts: 278
|
08-13-2005 20:54
YAY!!!! Thank you Jillian 
|
Blain Candour
Registered User
Join date: 17 Jun 2005
Posts: 83
|
Because I can!
08-14-2005 20:00
I was tinkering with this and trying to find the cleanest way I could to remove the max rez range weakness. I was trying to pass a variable that I could parse into a position but max variable is just too small. So instead I used a temp whisper and a self deleting listen/mover script. Figured since I spent the time to figure it out for myself I might as well pass it along here. This is kind of like the tringo board effect but it has no range limitations other than how far away you can see it to click it. I reused some of your code in there Jillian. Hope you don't mind. Didn't see any point in rewriting those bits. parent script: //Amazing in front of you spawner thingy made by Blain. I am lazy so some of //Jillian Callahan's code is in here too. string commandName = "Listen to me my child"; //Temp name to use while tlaking to child integer commandChannel = 96356; //Chat Channel to talk to child on vector heightOffset = <0,0,0.75>; //Offset to adjust so things show at right height to avatar rotation rotationOffset = <0.0, 0.0, 1.0, 0.0>; //Adjust for rotation of child. float offsetDistance = 1.5; //How far in front of the person to put the child string childName = "dingosatemybaby"; //name of child prim to spawn.
default { touch_start( integer n ) {
vector pos = llDetectedPos(0) + ( llRot2Fwd(llDetectedRot(0)) * offsetDistance ); // Where the toucher is, plus two meters in "front"
pos = pos + heightOffset; //add our height offset in.
rotation rot = llDetectedRot(0) * rotationOffset; if ( llVecDist(pos, llGetPos()) < 9.5 ) // Can only rez up to 10 meters distant. { //Rez child with 1 as passed paramater so child knows NOT to listen. llRezObject(childName, pos, ZERO_VECTOR, rot, 1); } else //Now the fun starts { //store old name so we can change it back. string realname = llGetObjectName(); //set name that child will listen for llSetObjectName(commandName); //Rez inside of parent so it is close enough tou hear the listen reliably. //Use same rot as above but pass a 2 so child knows to listen for position. llRezObject(childName, llGetPos(), ZERO_VECTOR, rot, 2); //Give the child a moment to wake up llSleep(0.2); //Cut the <> off of pos and say it to the child on predefined channel. string passPos = llGetSubString((string)pos,1,30); llWhisper(commandChannel,passPos); //Restore original name llSetObjectName(realname); } } }
child code: // this removes itself form the child after being spawned by parent
string parentName = "Listen to me my child"; //Temp name parent will usewhile tlaking to me integer commandChannel = 96356; //Chat Channel to talk to parent on
default { on_rez(integer checkformove) { if (checkformove)//check to see if we were rezzed by parent or not { if (checkformove == 2)// need to listen for position { llListen(commandChannel,parentName,"",""); //listen for position llSetTimerEvent(16); //set timeout in case parent never says position } else //no need to listen for anything { llRemoveInventory(llGetScriptName()); //clean up child by removing this script } } } listen(integer channel,string name,key id,string msg) { llSetTimerEvent(0); //Turn off timer to ensure it doesn't stop our work. vector pos; //parse string into list list posList = llParseString2List(msg, [", "],[]); //Convert list back to vector coordinates and plug them into our position pos.x = llList2Float(posList,0); pos.y = llList2Float(posList,1); pos.z = llList2Float(posList,2); //See how many times we have to move 10 meters to get to target integer posSteps = (integer)(llVecDist(pos, llGetPos()) / 10) + 1; integer i; for (i=0;i < posSteps;i++) //move as many steps as we need to { //move to target llSetPos(pos); //wait a second to let the object move. Generous sleep due to possible lag. llSleep(0.75); } //once moving is done clean up child by removing this script llRemoveInventory(llGetScriptName()); } timer() { //let people know what a tragedy this timeout is for you. heh. primicide! Cheese is good. llSay(0, "You never got close to me! I can not find my place in this life!! Goodbye cruel world!"); //destroy object since it is just sitting there on the parent. llDie(); } }
|
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
|
08-14-2005 20:13
I don't mind at all! 
|