Change font size
It is currently Tue Jul 17, 2018 11:26 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 2   [ 11 posts ]
Go to page 1, 2  Next
Author Message
 Post subject: Water level script (sim flooding / draining)
PostPosted: Fri Jul 17, 2009 10:00 am 
Furious Typer
User avatar

Joined: Sat Feb 02, 2008 10:02 pm
Posts: 104
Location: Romania, Bucharest
A script which allows smooth flooding / draining of region water to a chosen height. Great for industrial sims with triggered pumps or environments which may contain natural fluxes / refluxes (can be either triggered or random). Uses osSetRegionWaterHeight() so it's only for Opensim... don't forget to enable OS functions and set threat level to High in opensim.ini. Script can also be found in Wright Plaza freebie garden which includes the default sound too.

{L_CODE}:
//----    Water level script by Mircea Kitsune, V1.0    ----

// Configuration:

float initialwaterlevel = 20; // Initial water level, best left at 20.
float targetwaterlevel = 40; // Level the water goes to. Can be anything bigger or smaller then the initial level.
    float waterraisespeed = 0.15; // How fast the water goes up.
    float waterlowerspeed = 0.15; // How fast the water goes down.

float flux = FALSE; // If FALSE the water moves when the object is touched by an avatar. If TRUE the flux and reflux happen at random intervals.
    float fluxtimemin = 30; // If flux is TRUE, the minimum number of secconds in which a flux / reflux can take place.
    float fluxtimemax = 120; // If flux is TRUE, the maximum number of secconds in which a flux / reflux can take place.
float owneronly = TRUE; // Only the owner can trigger by touching (if flux = FALSE).

float notices = 1; // Enable echoing of messages. 0 disables, 1 enables notices on flux / reflux, 2 also prints the water position each loop.
    string message1 = " raises the water level."; // Message when an avatar triggers a flux. Is used as 'avatar name + message'.
    string message2 = " lowers the water level."; // Message when an avatar triggers a reflux. Is used as 'avatar name + message'.
    string message3 = "A flux has started."; // Message when a timed flux takes place (for flux = TRUE).
    string message4 = "A reflux has started."; // Message when a timed reflux takes place (for flux = TRUE).

string sound = "Waterfall"; // Sound to play as the water lowers / raises. Set to "" to disable.
    float soundvol = 1; // Volume of the sound.

// End of configuration.

movewaterto()
{
    float i;
    llSetTimerEvent(0); // Make sure the timer doesn't execute if shorter then the loop time, otherwise it causes glitches.
    llLoopSound(sound, soundvol);
    if(targetwaterlevel > initialwaterlevel)
    {
        for(i = initialwaterlevel; i <= targetwaterlevel; i+=waterraisespeed)
        {
            osSetRegionWaterHeight(i);
            if(notices > 1)
                llSay(0, "Water position at " + (string)i + " meters.");
        }
    }
    else if(targetwaterlevel < initialwaterlevel)
    {
        for(i = initialwaterlevel; i >= targetwaterlevel; i-=waterlowerspeed)
        {
            osSetRegionWaterHeight(i);
            if(notices > 1)
                llSay(0, "Water position at " + (string)i + " meters.");
        }
    }
    llStopSound();
    state atcustomlevel;
}

movewaterfrom()
{
    float i;
    llSetTimerEvent(0); // Make sure the timer doesn't execute if shorter then the loop time, otherwise it causes glitches.
    llLoopSound(sound, soundvol);
    if(targetwaterlevel > initialwaterlevel)
    {
        for(i = targetwaterlevel; i >= initialwaterlevel; i-=waterlowerspeed)
        {
            osSetRegionWaterHeight(i);
            if(notices > 1)
                llSay(0, "Water position at " + (string)i + " meters.");
        }
    }
    else if(targetwaterlevel < initialwaterlevel)
    {
        for(i = targetwaterlevel; i <= initialwaterlevel; i+=waterraisespeed)
        {
            osSetRegionWaterHeight(i);
            if(notices > 1)
                llSay(0, "Water position at " + (string)i + " meters.");
        }
    }
    llStopSound();
    state default;
}

default
{
    state_entry()
    {
        osSetRegionWaterHeight(initialwaterlevel);
        //llPreloadSound(sound);
        if(flux == TRUE)
        {
            float fluxtime = llFrand(fluxtimemax - fluxtimemin) + fluxtimemin;
            llSetTimerEvent(fluxtime);
        }
        else
            llSetTimerEvent(0);
    }

    touch_start(integer num_detected)
    {
        if(flux != TRUE)
        {
            if(owneronly == TRUE & llDetectedKey(0) != llGetOwner())
                return;
            else
            {
                if(notices > 0)
                    if(targetwaterlevel > initialwaterlevel)
                        llSay(0, llDetectedName(0) + message1);
                    else if(targetwaterlevel < initialwaterlevel)
                        llSay(0, llDetectedName(0) + message2);
                movewaterto();
            }
        }
    }

    timer()
    {
        if(notices > 0)
            if(targetwaterlevel > initialwaterlevel)
                llSay(0, llDetectedName(0) + message3);
            else if(targetwaterlevel < initialwaterlevel)
                llSay(0, llDetectedName(0) + message4);
        movewaterto();
    }
}

state atcustomlevel
{
    state_entry()
    {
        osSetRegionWaterHeight(targetwaterlevel);
        //llPreloadSound(sound);
        if(flux == TRUE)
        {
            float fluxtime = llFrand(fluxtimemax - fluxtimemin) + fluxtimemin;
            llSetTimerEvent(fluxtime);
        }
        else
            llSetTimerEvent(0);
    }

    touch_start(integer num_detected)
    {
        if(flux != TRUE)
        {
            if(owneronly == TRUE & llDetectedKey(0) != llGetOwner())
                return;
            else
            {
                if(notices > 0)
                    if(targetwaterlevel > initialwaterlevel)
                        llSay(0, llDetectedName(0) + message2);
                    else if(targetwaterlevel < initialwaterlevel)
                        llSay(0, llDetectedName(0) + message1);
                movewaterfrom();
            }
        }
    }

    timer()
    {
        if(notices > 0)
            if(targetwaterlevel > initialwaterlevel)
                llSay(0, llDetectedName(0) + message4);
            else if(targetwaterlevel < initialwaterlevel)
                llSay(0, llDetectedName(0) + message3);
        movewaterfrom();
    }
}


Top
 Profile  
 
 Post subject: Re: Water level script (sim flooding / draining)
PostPosted: Fri Jul 17, 2009 9:17 pm 
OSG Elite
User avatar

Joined: Sun Dec 07, 2008 4:40 am
Posts: 328
Location: variable
Thank you Mircea.

Tides, Mircea gave us tides. Swamps that fill and drain, boats that sink because anchor chain too short now? :o
I go play now. :D

Shortdog.

_________________
Greybeard.
I applied for the job as village idiot, seems they wanted someone smarter.


Top
 Profile  
 
 Post subject: Re: Water level script (sim flooding / draining)
PostPosted: Fri Sep 11, 2009 4:26 am 
Furious Typer
User avatar

Joined: Fri Feb 06, 2009 12:32 am
Posts: 232
Location: Australia
Thought I'd try this but get the following script error:

"Primitive: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

Server stack trace:
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000]
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000]
at OpenSim.Region.ScriptEngine.Shared.ScriptBase.Executor.ExecuteEvent (System.String state, System.String FunctionName, System.Object[] args) [0x00000]

Exception rethrown at [0]:
---> System.Exception: OSSL Runtime Error: osSetRegionWaterHeight permission denied. Allowed threat level is Low but function threat level is High.

Server stack trace:
at OpenSim.Region.ScriptEngine.Shared.Api.OSSL_Api.OSSLError (System.String msg) [0x00000]
at OpenSim.Region.ScriptEngine.Shared.Api.OSSL_Api.CheckThreatLevel (ThreatLevel level, System.String function) [0x00000] "


in my ini :
[code]
; Allow the use of os* functions (some are dangerous)
; Default is false
AllowOSFunctions = true

; Threat level to allow if os functions are enabled
; One of None, VeryLow, Low, Moderate, High, VeryHigh, Severe
; Default is VeryLow
OSFunctionThreatLevel = Low
[/close]


Top
 Profile  
 
 Post subject: Re: Water level script (sim flooding / draining)
PostPosted: Fri Sep 11, 2009 6:12 am 
Furious Typer
User avatar

Joined: Sat Feb 02, 2008 10:02 pm
Posts: 104
Location: Romania, Bucharest
You need to set "OSFunctionThreatLevel = High" in opensim.ini (or to anything higher then High as described in the comment) otherwise that function is not allowed to run. There are two of them in opensim.ini, use search in Notepad to find them.


Top
 Profile  
 
 Post subject: Re: Water level script (sim flooding / draining)
PostPosted: Sat Sep 12, 2009 12:42 am 
Furious Typer
User avatar

Joined: Fri Feb 06, 2009 12:32 am
Posts: 232
Location: Australia
Grrrr - whmmwaw! - this is beeeeautiful = thankyou :D


Top
 Profile  
 
 Post subject: Re: Water level script (sim flooding / draining)
PostPosted: Sun Sep 13, 2009 11:07 pm 
Site Admin
User avatar

Joined: Wed Jul 16, 2008 7:22 pm
Posts: 186
Mircea Kitsune {L_WROTE}:
You need to set "OSFunctionThreatLevel = High" in opensim.ini (or to anything higher then High as described in the comment) otherwise that function is not allowed to run. There are two of them in opensim.ini, use search in Notepad to find them.

If you do this, you are allowing anyone to use scripts in your region which call high threat level functions - which may allow malicious scripts to deliberately crash your region or modify your landscape, among other things.

A better way to do it would be to explicitly allow the use of osSetRegionWaterHeight by your avatar alone. In the [XEngine] and/or [ScriptEngine.DotNetEngine] sections, add the line:

{L_CODE}:
Allow_osSetRegionWaterHeight = 0dc66107-d6a7-4cd4-892f-f74226054d0f

(replace 0dc66107-d6a7-4cd4-892f-f74226054d0f with your avatar's UUID.)

Or, if you want to allow anyone to change the water height, you could use:

{L_CODE}:
Allow_osSetRegionWaterHeight = true

For more information on permissions, see the Threat level page on the OpenSim wiki.


Top
 Profile  
 
 Post subject: Re: Water level script (sim flooding / draining)
PostPosted: Sun Sep 13, 2009 11:53 pm 
Furious Typer
User avatar

Joined: Fri Feb 06, 2009 12:32 am
Posts: 232
Location: Australia
Wiil do - thanks for the heads up


Top
 Profile  
 
 Post subject: Re: Water level script (sim flooding / draining)
PostPosted: Fri Mar 02, 2012 8:07 pm 

Joined: Thu Apr 15, 2010 5:24 pm
Posts: 45
Hello all,

Does anyone know if this script does NOT work with megaregions? I have used this script before in a non-mega stand-alone setting and it worked great. Now I have a 3x4 mega and I want one of the interior regions to have a lake on a hilltop. I tried using this script, and it does not seem to be working properly.

I am trying to set the water level at 50m. If I go into mouselook, and go under 50m, my vision is blue and muddled, as if I am under the sea, but in regular view (not mouselook), there is no water. I tried turning off water rendering under the Advanced Menu, and then turning it back on, but that accomplished nothing.

I'd like to know if anyone is using thuis on a mega region, thanks!

:)

Pak


Top
 Profile  
 
 Post subject: Re: Water level script (sim flooding / draining)
PostPosted: Fri Mar 02, 2012 10:24 pm 
Site Admin
User avatar

Joined: Sat Feb 02, 2008 5:27 pm
Posts: 843
It is very unlikely this would work in a mega region, I am 99.9999% sure it won't


Top
 Profile  
 
 Post subject: Re: Water level script (sim flooding / draining)
PostPosted: Sat Mar 03, 2012 2:54 am 
Furious Typer

Joined: Fri Dec 12, 2008 9:47 am
Posts: 258
Warin Cascabel {L_WROTE}:
A better way to do it would be to explicitly allow the use of osSetRegionWaterHeight by your avatar alone. In the [XEngine] and/or [ScriptEngine.DotNetEngine] sections, add the line:

{L_CODE}:
Allow_osSetRegionWaterHeight = 0dc66107-d6a7-4cd4-892f-f74226054d0f

(replace 0dc66107-d6a7-4cd4-892f-f74226054d0f with your avatar's UUID.)


And to make life even easier, one can use ESTATE_OWNER insteadof the individual avatars UUID ;)

{L_CODE}:
Allow_osSetRegionWaterHeight = ESTATE_OWNER

_________________
{L_IMAGE}{L_IMAGE}{L_IMAGE}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 2   [ 11 posts ]
Go to page 1, 2  Next


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net