Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Swimming Pool Water Script

Vanmere Karillion
Registered User
Join date: 2 Oct 2008
Posts: 17
10-18-2008 06:52
I'm creating a swimming pool script, I use a water prim inside the main linked prims and this script, to give the illusion of it being phantom (and thus non solid).

What I need to adapt it are to unrez and then re-rez the water prim when the main object is moved.

-Updated code in next post-

Thanks for your help.
Vanmere Karillion
Registered User
Join date: 2 Oct 2008
Posts: 17
10-18-2008 07:33
Okay i've done the basic first bit and updated the rotation code to alter based on the objects position, that was easy. Now I just need to find a command that will lldie if the object is moved? I haven't seen one yet, only OBJECT_POS but i've no clue where to start on that score.

Updated Code:

default
{

on_rez(integer start_param)
{
llResetScript();
}

state_entry()
{

vector xyzrot = <0,0,-90>;
rotation rot = llEuler2Rot(xyzrot * DEG_TO_RAD);

llRezObject("VKLiquid", llGetPos() + <9, 0, 0.5>, ZERO_VECTOR, llGetRot() + rot,0);

}
}



Updated Musings, this code below obviously doesn't work but this shows what I was thinking. Reset on touch perhaps? Meaning if someone tried to move the object the water would vanish?

Other than that, could I store the object_pos and object_rot in two variables and have the water disappear when the object pos or rot didn't equal their original values?


default
{

on_rez(integer start_param)
{
llResetScript();
}

touch(integer start_param)
{
llResetScript();
}

state_entry()
{

llDie("VKLiquid";);

vector xyzrot = <0,0,-90>;
rotation rot = llEuler2Rot(xyzrot * DEG_TO_RAD);

llRezObject("VKLiquid", llGetPos() + <9, 0, 0.5>, ZERO_VECTOR, llGetRot() + rot,0);


}

}
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
10-18-2008 07:40
This works for me, assuming the bath's root prim and the water prim share the same orientation (that is, if you look at them both in edit with the local, as opposed to the world, ruler, the arrows are all pointing the same way for both).

CODE

vector eul = <0,0,0>; // get the rotation at which you want objects rezzed from the object's edit box
rotation quat;

default
{
on_rez(integer p)
{
llResetScript();
}

state_entry()
{

eul *= DEG_TO_RAD; //convert to radians
quat = llEuler2Rot(eul); //convert to quaternion

llRezAtRoot(llGetInventoryName(INVENTORY_OBJECT, 0), llGetPos()+<0.0, 0.0, 0.1>, <0.0, 0.0, 0.0>,llGetLocalRot(), 0);

}


}
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
10-18-2008 14:39
Objects can't kill other objects; i.e., llDie() doesn't take an argument. Instead, they have to tell other objects to run llDie() inside that object. (One might use the last parameter to llRezObject--the value passed to the spawned object's on_rez() event--to hand in a random chat channel to talk over if they'll be in the same sim when the water is supposed to die.)

But how much movement are we talking about here, and what causes it? There's a moving_end() event that might work, but most swimming pools don't move around a lot, so is it really moving, or re-rezzing after being taken into inventory? :confused:
Vanmere Karillion
Registered User
Join date: 2 Oct 2008
Posts: 17
10-18-2008 16:55
From: Qie Niangao
Objects can't kill other objects; i.e., llDie() doesn't take an argument. Instead, they have to tell other objects to run llDie() inside that object. (One might use the last parameter to llRezObject--the value passed to the spawned object's on_rez() event--to hand in a random chat channel to talk over if they'll be in the same sim when the water is supposed to die.)

But how much movement are we talking about here, and what causes it? There's a moving_end() event that might work, but most swimming pools don't move around a lot, so is it really moving, or re-rezzing after being taken into inventory? :confused:


Not a huge amount of individual moves but it could be moved a significant distance once or twice.

I am designing a pool to eventually put on a vendor, when I have one of sufficient quality, anyone who places the pool is obviously going to want to position it on their land and occasionally move it around to suit. For now though its a personal item.

I guess this really was a bad idea to take on as my first script, sounds quite complicated :) I’ve done C++ before so its not above my head in terms of scope but it is in terms of syntax.

I’ll have another go tomorrow, thank you for the help and if anyone can offer any examples of calling llDie() on an object or using a chat channel between objects I’d appreciate it.
Faust Vollmar
llSetAgentSanity(FALSE);
Join date: 3 Feb 2007
Posts: 87
10-18-2008 17:22
Another possibility, without needing a script, is to set the water prim Flexible with all values 0 except Drag and Tension at 10.0, so that it's so stiff the Flexi isn't noticeable, and it retains phantomness when linked.
arton Rotaru
Registered User
Join date: 27 Aug 2007
Posts: 43
10-18-2008 17:23
You can detect with moving_start and moving_end if the object was moved. But this don't detect only a rotation. If somebody only rotates the pool, you have a problem. You have to check the rotation thru a timer. Little too much for something that moves only once in while.

Maybe easier you have a button on your pool wich deletes the water and rez the water manualy.
Vanmere Karillion
Registered User
Join date: 2 Oct 2008
Posts: 17
10-19-2008 10:26
From: Faust Vollmar
Another possibility, without needing a script, is to set the water prim Flexible with all values 0 except Drag and Tension at 10.0, so that it's so stiff the Flexi isn't noticeable, and it retains phantomness when linked.


I have used this and its working great, thank you all for the help and idea's. Its been a good warm up of my coding muscles for the future.