Jump to content

water buoyancy and flotation script


You are about to reply to a thread that has been inactive for 77 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Posted (edited)
4 minutes ago, Naiman Broome said:

it snaps back always in the position where I edited the script.

Yes, you might have to use something like

llSetPos(llGetPos()+difference);

to avoid that problem.

. . .  but then you're probably going to run into drift problems due to floating point rounding if you have it in continuous operation for a long period of time.

Edited by Quistess Alpha
Link to comment
Share on other sites

I added this but is not working anymore:
 


 FindGroundOrWater()

 {

    vector vTarget = llGetPos();

    vTarget.z = llGround( ZERO_VECTOR );

     float fWaterLevel = llWater( ZERO_VECTOR );

     if( vTarget.z < fWaterLevel )

        vTarget.z = fWaterLevel;

     llSetRegionPos(vTarget) ;

 }

and then


 

 touch_start(integer num_detected)
    {

FindGroundOrWater();
    }

 

Link to comment
Share on other sites

6 hours ago, Naiman Broome said:

Ok I did that but now I cant move from the orignal position the item and it snaps back always in the position where I edited the script.

when we first get into building, how to do it can be a little bit confusing and frustrating. When we just know somehow then happy moonbeams and when not then we can just want to smash stuff

ok so how to do it

when we want to change the position or orientation of the object then:
- edit the object. Open the script
- at the bottom of the script editor is a tickbox which says: Running and a button which says Reset
- untick the Running box (it will stop the script)
- position/orient the object using the edit tools
- then press the Reset button (reset script) and then tick Running (run script)

when we do this then in the below code snippet, pos will be the value we expect it to be

vector pos;

default
{
    state_entry()
    {
        pos = llGetPos();
    }
}

  • Like 2
Link to comment
Share on other sites

6 hours ago, Mollymews said:

when we first get into building, how to do it can be a little bit confusing and frustrating. When we just know somehow then happy moonbeams and when not then we can just want to smash stuff

ok so how to do it

when we want to change the position or orientation of the object then:
- edit the object. Open the script
- at the bottom of the script editor is a tickbox which says: Running and a button which says Reset
- untick the Running box (it will stop the script)
- position/orient the object using the edit tools
- then press the Reset button (reset script) and then tick Running (run script)

when we do this then in the below code snippet, pos will be the value we expect it to be

vector pos;

default
{
    state_entry()
    {
        pos = llGetPos();
    }
}

Ok this works only for me or who edits the script ? What if I have to sell an item withthat script inside and want it to be made in a less intrusive and simplier for customer?

Link to comment
Share on other sites

Posted (edited)
33 minutes ago, Naiman Broome said:

Ok this works only for me or who edits the script ? What if I have to sell an item withthat script inside and want it to be made in a less intrusive and simplier for customer?

with commercial products then I suggest that for commercial help ask for this in Wanted forum, and be prepared to pay something for the help. As the way to do what you are asking requires some slightly advanced coding, that can't be done easily by code snippet examples demonstrating algorithm and technique

commercial scripters have to eat same as any other commercial builders. I don't do commercial work myself, but there are quite a few contributors on here who do

 

Edited by Mollymews
typd
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

2 minutes ago, Mollymews said:

with commercial products then I suggest that for commercial help ask for this in Wanted forum, and be prepared to pay something for the help. As the way to do what you are asking requires some slightly advanced coding, that can't be done by code snippet examples demonstrating algorithm or technique

commercial scripters have to eat same as any other commercial builders. I don't do commercial work myself, but there are quite a few contributors on here who do

 

I have no problems in payingt he right due to , but as I wrote in the original post I had bad luck with commissioners, as some did a sloppy work that in the end didn't work and had several issues, others took money and disappeared, others dropped the script couse was too difficult for them , can you sugest me any serious one available?

  • Haha 1
Link to comment
Share on other sites

6 hours ago, Naiman Broome said:

can you suggest me any serious one available?

I do custom work, and can provide references to previous clients who were happy with my work.

In all honesty, I do drop projects on a rare occasion, if something ends up being over my skill level, or an order of magnitude more time-intensive than the payment justifies. (or if the client can't find a separate contractor for the artistic work :/)

The first or second draft of a script can also be rough sometimes, context matters and scripting for a commercial product can sometimes take a lot more polishing (and therefore expense) than a personal-use script.

Taking the money and running is always a bad sign though >.<

  • Like 1
Link to comment
Share on other sites

11 hours ago, Naiman Broome said:

Ok this works only for me or who edits the script ? What if I have to sell an item withthat script inside and want it to be made in a less intrusive and simplier for customer?

If you're thinking along those lines, the easiest solution is to have it listen on a channel , such as -123, for the owner and obey a set of commands, such as "start", "stop", "reset". Those three would allow the owner to start the boat rocking, stop it (at which point it is to go back to the initial rotation and position values), and reset to a new rotation and/or position after having been moved to a new location.

This approach will be easier to code than a buttons/dialog system.

Don't forget to have a changed event in your script to reset the listen if the owner changes.

But get it working for yourself first and use it in lots of different locations to be cerrtain you've got 99.8% of tthe bugs out before you start marketting it.

  • Like 1
Link to comment
Share on other sites

Actually, looking at what @Naiman Broome already had and how close it is to something more workable, I'd feel bad charging her for it:

integer timer_cycles = 21;
float max_drift_squared = 0.2;

integer timer_count;
vector home_pos;

vector FindGroundOrWater()
{
    vector vTarget = llGetPos();
    vTarget.z = llGround( ZERO_VECTOR );
    float fWaterLevel = llWater( ZERO_VECTOR );
    if( vTarget.z < fWaterLevel )
        vTarget.z = fWaterLevel;
    return vTarget;
}
default
{
    state_entry()
    {
        llSetTimerEvent(0.2);
        llSetStatus(STATUS_PHYSICS,FALSE);
        llSetRegionPos(FindGroundOrWater()+<0,0,0.288>);
        home_pos = llGetPos();
    }
    timer()
    {
        timer_count=++timer_count;
        vector pos = llGetPos();
        if(timer_count %timer_cycles == 0)
        {
            vector pos_diff = pos - home_pos;
            //llOwnerSay((string)(pos_diff*pos_diff));
            if(pos_diff*pos_diff >= max_drift_squared)
            {   // we are out of the max drift range, 
                //assume we have been manually moved and readjust.
                llSetRegionPos(FindGroundOrWater()+<0,0,0.288>);
                home_pos = pos = llGetPos();
            }else // correct for any unintentional drift.
            {   pos = home_pos;
            }
        }
        float t = timer_count * TWO_PI / timer_cycles ;
        float tilt = llCos(t) * 0.15;
        float tilt2 = llSin(t*0.4713) * 0.15; // made the time factor less rational.
        //float tilt3 = llSin(t/2) * 0.05;

        vector normal = <tilt,  tilt2, 2>;
        rotation r = llRotBetween(<0,0,2>, normal);
        float height = llCos(t) * 0.01;
        llSetLinkPrimitiveParamsFast(LINK_THIS,
        [   PRIM_ROTATION, r,
            PRIM_POSITION, pos + <0,0,height>
        ]);
    }
}

I just smoothed over a few rough edges, and added a correction for drift, but only when the drift is a small amount. (if there is a large drift, someone obviously moved the thing)

Although, for anyone curious I did happen to have an eye on the clock, took me about 40 minutes for that rather minor set of changes (Yes, I'm slow. . .)

  • Like 1
Link to comment
Share on other sites

Posted (edited)

Ooh, and a little change to make it possible to change the rotation in the build window while it's running:

        vector normal = <tilt,  tilt2, 2>;
        rotation current_rot = llGetRot();
        rotation apply = llRotBetween(<0,0,2>*current_rot, normal);
        float height = llCos(t) * 0.01;
        llSetLinkPrimitiveParamsFast(LINK_THIS,
        [   PRIM_ROTATION, current_rot*apply,
            PRIM_POSITION, pos + <0,0,height>
        ]);

(Should be obvious enough what that replaces)

Edited by Quistess Alpha
  • Like 1
Link to comment
Share on other sites

Posted (edited)
21 minutes ago, Profaitchikenz Haiku said:

I agree with Quistessa, the OP is so close I'd like to think they could make the final stretch :)

OP is wanting to start/stop the movement, and after changing the position/rotation of the object with the edit tool have the newly edited pos/rot apply to the object. All done via owner touch

OP already realises that they are not close to doing this, as this requirement does not form part of the code they already have, and OP is wanting someone to help them with this touch/reset functionality

edit add:

this is a pretty straight-forward trivial piece of code for an experienced scripter. Can knock the code out in a few minutes. The most time is taken up with explaining to the customer how the script works in the way it does. And is that time a commercial scripter can expect payment for

Edited by Mollymews
  • Like 1
Link to comment
Share on other sites

8 hours ago, Quistess Alpha said:

Actually, looking at what @Naiman Broome already had and how close it is to something more workable, I'd feel bad 

Although, for anyone curious I did happen to have an eye on the clock, took me about 40 minutes for that rather minor set of changes (Yes, I'm slow. . .)

Don't worry for charging me for ur work I am happy to pay it and if possible to add other options I sent you a im describing them plus you wrote you already spent time working on that too ...

  • Like 1
Link to comment
Share on other sites

On 7/9/2021 at 2:36 AM, Quistess Alpha said:

Ooh, and a little change to make it possible to change the rotation in the build window while it's running:

(Should be obvious enough what that replaces)

Did you get my pm?

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 77 days.

Please take a moment to consider if this thread is worth bumping.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...