Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Waterwheel problem

Sebastiaan Siegel
Registered User
Join date: 2 Feb 2007
Posts: 18
02-13-2007 04:05
Im currently building a waterwheel (ancient machine for extracting power from the flow of water - wiki). In the default entry the wheel is turning but with one click i want to make it stop. A second click makes it turn again. This works but when its stopped it spins back to its default position. Is there a way to make it stop and start from its current position?

CODE

default
{
state_entry()
{
state water_on;
}
}

state water_on
{
state_entry()
{
llSay(0, "The water is flowing");
llTargetOmega(<-1,0,0>,1,1);
rotation llGetRot;
}


touch_start(integer total_number)
{
state water_off;
}
}

state water_off
{
state_entry()
{
llSay(0, "The water stopped flowing");
llTargetOmega(<0,0,0>,1,1);
}

touch_start(integer total_number)
{
state water_on;
}
}
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-13-2007 06:17
lltargetOmega is aclient side effect, the object is not actually roatetd.
At least that was the case prior to 1.13.
You could rotate the object yourself using llSetRot() in a timer and then just stop the timer to stop it updating.
Note each call to llSetRot delays for 0.2 seconds so no faster update than that can be achieved.
Sebastiaan Siegel
Registered User
Join date: 2 Feb 2007
Posts: 18
02-13-2007 07:58
Are you sure about llTargetOmega being clientside?

Because weve got multiple pc's here and when i check at my buddies' the wheel is rotating at his screen as well.
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
02-13-2007 08:24
From: Sebastiaan Siegel
Are you sure about llTargetOmega being clientside?

Because weve got multiple pc's here and when i check at my buddies' the wheel is rotating at his screen as well.


I think what he meant is that the effect is generated client side, sure, when it's rotating, everyone sees it rotate, but when llTargetOmega is called, the EFFECT is generated client side, as opposed to being generated on the server, and the output streamed to the client. As for you situation, it's going to reset each time. As was pointed out earlier, you could rotate with llSetRot(), but that'll wind up choppy due to the .2 second delay.
Lee Ponzu
What Would Steve Do?
Join date: 28 Jun 2006
Posts: 1,770
02-13-2007 08:26
You are all clients. I think it works like this...

The script on the server executes the llTargetOmega(). This causes a message to be sent to all clients that view that scene. That message tells the local GPU to start rotating the object. The local GPU starts rotating it.

Somebody new comes along, the server sends down all the visual info, including the fact that it is rotating. They see rotation too.
racush Cheeky
Registered User
Join date: 23 Jan 2006
Posts: 23
02-13-2007 20:35
Well here is a simple way to do as you request keep in mind some rotations on the z axis will produce undesierd rotation from the llTargetOmega but i'm shure you or maybe another will find a way around this but here is a simple form of what you asked for :)

CODE

default
{
touch_start(integer total_number)
{
llSay(0, "The water stopped flowing");
llTargetOmega(<0.5,0,0>,1,1); state stopped;
}
}
state stopped
{
touch_start(integer total_number)
{
llSay(0, "The water stopped flowing");
llTargetOmega(<0,0,0>,0,0); state default;
}
}


allthough i notice it do a simular effect as you sated if you select the object during its active state, so just be shure to avoid it and it will not happen with this here.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-14-2007 00:30
You may find the following thread useful.
Sebastiaan Siegel
Registered User
Join date: 2 Feb 2007
Posts: 18
02-16-2007 04:16
So i modified the script and started to use a timer instead of llTargetOmega.
The wheel turns in a very choppy fashion. (the wheel itself has a diameter of 10 meters)
Im using a high updaterate for the timer and a low rotation to get it as smooth as possible, but its still very choppy :/
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-16-2007 05:07
From: Sebastiaan Siegel
So i modified the script and started to use a timer instead of llTargetOmega.
The wheel turns in a very choppy fashion. (the wheel itself has a diameter of 10 meters)
Im using a high updaterate for the timer and a low rotation to get it as smooth as possible, but its still very choppy :/



You have a minimum delay of 0.2 seconds with llSetRot so you cannot get faster than that.
Another way to do it is to combine the two, use llTargetOmega to start the (visual) rotation but also keep track of the 'real' rotation and use llSetRot to set this when you switch states.
Dustin Widget
Script Monkey for hire
Join date: 15 Feb 2006
Posts: 101
02-16-2007 08:39
You can use a physical water wheel. On touch use llApplyRotationalImpulse() to set the thing spinning. Then, on touch, apply an equal and opposite impulse.