Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

temporary moving object help

Horg Neurocam
Mineralogist
Join date: 28 Sep 2005
Posts: 19
08-04-2007 00:23
so i'm trying to do some simple tricks in lsl, and i'm still getting stumped on what must be a simple task:

I want an object (in this case, a mining-cart) to temporarily rez, slowly move across a room, then disappear.

I've found most of the commands (lldie, etc) but i cannot seem to make any syntax work as it should, still battling brackets, i'm embarrassed to say

any Whole Script of this nature, that i could tinker with and learn from, would be very appreciated!
AnnMarie Otoole
Addicted scripter
Join date: 6 Jan 2007
Posts: 162
08-04-2007 01:44
Sounds like a great project for you to get to learn lsl scripting.

Here is an outline of how I would go about it.
Others may have more mathematical approaches, this is brute force and not re-locatable.

The item you rez will contain its own script to do the motion.
You will work on that first and worry about rezzing it and killing it later.
You will use llSetPos(position vector) to move it.
At first you include a line that says
llOwnerSay((string)llGetPos());
Move it physically to each "step" along the intended path and SAVE the script. Copy the position vector it gives you in CHAT to add to a list later.
If it needs to change the way it is pointing you will need a rotation vector for each step and add them to the list, or make two lists. with llOwnerSay((string)llGetRot());

Having plotted the path and stored them in a list (or two), remove (or comment out) the two reporting lines - you will only need them if you modify the path later.

Rez the object from some external stimulus to the first position and rotation vectors in your list.

When the object rezzes, use the OnRez function to make sure the default state is executed.

Start a timer that represents the time between position updates depending on how many positions you plotted and how long the motion has to last.

In a timer(){ event have a counter that increments. This will give you the index numbers to fetch the next llSetPos(< >;) and llSetRot(< >;) from the lists you made.
Each time this triggers you will move to the next step.

When this is all working you add one more line that says if(IndexCounter == one more than the number of steps) llDie(); This will cause it to disappear.

CAUTION!!!. When it disappears it is gone forever, it is not returned to inventory, it is not delivered to your trash bin. SO always work with a copy and dillegently save the script in a text file on your computer so you can replace it. And always keep a master copy of the object with NO SCRIPT IN IT so you can make a new one if you lose it.
Horg Neurocam
Mineralogist
Join date: 28 Sep 2005
Posts: 19
08-07-2007 21:38
thanks for the nicely written tutorial!
alas, even the most basic syntax, when i try to create it myself, seems to just sit dead. case in point, my poor attempt to make a rezzed object appear, move someplace, then delete itself.

here's what i have so far:
a "rezzor" rezzes the "mover".

"rezzor" script:
CODE

default
{
touch_start(integer total_number)
{
llWhisper(0, "Rez Object");
llRezObject("mover", llGetPos() + <0, 0, 2>, ZERO_VECTOR, llGetRot(), 0);
}
}


so far so good. of course, this was mostly copied wholesale from somebody else.!

"mover" script
CODE

default
{
on_rez(integer start_param)
{llSetTimerEvent(1.0);
}


state_entry()
{
llSay(0, "Hello, Avatar!");
llOwnerSay((string)llGetPos());
llSetPos(56.65627, 230.29282, 701.00055);
}
timer() {
llDie(); // delete this object
}
}



not only does it not die, when i add in the "llSetPos" command, it gives me an error.

thanks for any help..!
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
08-07-2007 22:12
vector needs < >.
_____________________
:) Seagel Neville :)
Horg Neurocam
Mineralogist
Join date: 28 Sep 2005
Posts: 19
grammar merge
08-19-2007 00:27
so i'm still wrassling with the basic {bracket} grammar, and am attempting to merge two small scripts unsuccessfully. i have this alteration of the rocking chair script:
CODE

rotation Inverse(rotation r)
{
r.x = -r.x;
r.y = -r.y;
r.z = -r.z;
return r;
}
rotation GetParentRot()
{
return Inverse(llGetLocalRot())*llGetRot();
}
SetLocalRot(rotation x)
{
llSetRot(x*Inverse(GetParentRot()));
}

vector normal = <1.55, 0, 0>;

default
{
state_entry()

{
@a;
//SetLocalRot(llEuler2Rot(<normal.x - 2.14, normal.y, normal.z>));
SetLocalRot(llEuler2Rot(<normal.x + 0.07, normal.y, normal.z>));
SetLocalRot(llEuler2Rot(<normal.x + 0.14, normal.y, normal.z>));
SetLocalRot(llEuler2Rot(<normal.x + 0.21, normal.y, normal.z>));
SetLocalRot(llEuler2Rot(<normal.x + 0.14, normal.y, normal.z>));
SetLocalRot(llEuler2Rot(<normal.x + 0.07, normal.y, normal.z>));
SetLocalRot(llEuler2Rot(normal));
SetLocalRot(llEuler2Rot(<normal.x - 0.07, normal.y, normal.z>));
SetLocalRot(llEuler2Rot(<normal.x - 0.14, normal.y, normal.z>));
SetLocalRot(llEuler2Rot(<normal.x - 0.21, normal.y, normal.z>));
SetLocalRot(llEuler2Rot(<normal.x - 0.14, normal.y, normal.z>));
SetLocalRot(llEuler2Rot(<normal.x - 0.07, normal.y, normal.z>));
SetLocalRot(llEuler2Rot(normal));
jump a;
}
}
/
CODE


and this "moving and die-ing script"
CODE

default
{


on_rez(integer x)
{
llWhisper(0,"rezzed");
integer i;
for(i = 0; i < 20; i++)
{
llSleep(.1);
vector here = llGetPos();
here.x += .5;
llSetPos(here);
}
llSleep(1);
//llDie();
// dont die! but could llDie here.
}
}
/
CODE



and i cannot seem to put in enough brackets to remove any syntax errors! or whatever it is i'm doing wrong, there seems to be no answer.

can anybody help me merge this puzzle? thank you!

(btw the desired end result is something that wobbles past, then disappears, as it were a balloon tied to a conveyer belt....!)