Environmental Enhancements and Improved Scripting

Provide feedback, criticism or praise about Kitely, or suggest new features
User avatar
Dot Matrix
Posts: 1585
Joined: Sun Jul 28, 2013 3:26 am
Has thanked: 1111 times
Been thanked: 2217 times

Re: Environmental Enhancements and Improved Scripting

Post by Dot Matrix »

Graham Mills wrote:
Fri May 14, 2021 6:02 pm
Of course, for anyone starting from scratch this would be a very useful resource, not least by virtue of the preview images, so many thanks to Dot for her efforts to date.
Thanks, Graham -- that's a good idea. I'll try to add the preview images to the preset folders from now on.

If anyone is wondering, the photos are taken from various viewpoints in Intersections and Paths, the latter being a layered compilation of ancient but classic OpenSim builds by Paislee Myrtle and Shenn Tao slowly being updated where necessary/possible -- you might recognise the plant tendrils in the previews for EEP: Places, and here’s a fresh photo using an EEP setting available from EEP: [TOR] skies

Paths-Illusion-[TOR]-MightyMoon_001.png
Paths-Illusion-[TOR]-MightyMoon_001.png (437.8 KiB) Viewed 1021 times
These users thanked the author Dot Matrix for the post (total 2):
Ilan TochnerGraham Mills
Graham Mills
Posts: 1090
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 747 times
Been thanked: 861 times

Re: Environmental Enhancements and Improved Scripting

Post by Graham Mills »

Simple HUD for parcel-level daycycle image display (as per Dot's product albeit those aren't daycycles) and setting replacement. Feel free to improve.

Box prim <0.45000, 0.25000, 0.00100> tapered 0.3 on X axis to give three faces. I colour the left (face 2) and right (face 4) red and green respectively and leave the large central one white to display the image. You may need to play with the face values. Attach to HUD display and rotate/position to suit so you can see the three faces.

The image and daycycle setting need to be numbered in a similar manner, e.g. 01image, 01dc, 02image, 02dc, etc and added to the prim inventory along with the script below.

Select the red and green face to page through the images displayed on the middle face and select the middle face to change the parcel daycycle.

Code: Select all

integer p = 0;
integer count;
integer transition = 3;

default
{
    state_entry()
    {
        p = 0;
        count = llGetInventoryNumber(INVENTORY_TEXTURE);
        llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, p), 0);
    }
    
    touch_start(integer n)
    {
        integer face = llDetectedTouchFace(0);
        if (face == 4)
        {
            //next
            p++;
            if (p == count)
            {
                p = 0;
            }
            llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, p), 0);
        }
        else if (face == 2)
        {
            //prev
            p = p-1;
            if (p < 0)
            {
                p = count-1;
            }
            llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, p), 0);
        }
        else if (face == 0)
        {
            //replace
            osReplaceParcelEnvironment(transition, llGetInventoryName(INVENTORY_SETTING, p));
        }
    }
}
These users thanked the author Graham Mills for the post (total 3):
Ilan TochnerDot MatrixShandon Loring
Graham Mills
Posts: 1090
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 747 times
Been thanked: 861 times

Re: Environmental Enhancements and Improved Scripting

Post by Graham Mills »

Same HUD but this time extended for region daycycle replacement. If your avatar is on a standard parcel, parcel replacement is used. If the avatar is on a parcel with Region in its name then region replacement at ground level is used. However, it is also necessary to use the World|Parcel details|Environment|Use Region Settings button or nothing will happen. As ever, feel free to ignore/improve; this is very much a learning exercise for yours truly. As previously, you will need appropriate permissions for changes to take effect.

ps If you override region/parcel settings by setting, for example, Midday from the World|Environment menu, you will also need to enable Use Shared Environments from the same menu to enable the HUD.

PS Useful thread on the default daycycle viewtopic.php?f=8&p=30328#p30328

Code: Select all

integer p = 0;
integer count;
integer transition = 3;

default
{
    state_entry()
    {
        p = 0;
        count = llGetInventoryNumber(INVENTORY_TEXTURE);
        llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, p), 0);
    }
    
    on_rez(integer n)
    {
        p = 0;
        count = llGetInventoryNumber(INVENTORY_TEXTURE);
        llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, p), 0);
    }
    
    touch_start(integer n)
    {
        list details = llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_NAME]);
        string flag = "";
        if (llSubStringIndex(llList2String(details ,0), "Parcel") > -1)
        {
            flag = "Parcel";
        }
        else if (llSubStringIndex(llList2String(details ,0), "Region") > -1)
        {
            flag = "Region";
        }    
        integer face = llDetectedTouchFace(0);
        if (face == 4)
        {
            //next
            p++;
            if (p == count)
            {
                p = 0;
            }
            llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, p), 0);
        }
        else if (face == 2)
        {
            //prev
            p = p-1;
            if (p < 0)
            {
                p = count-1;
            }
            llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, p), 0);
        }
        else if (face == 0)
        {
            //replace   
            if (flag == "Region")
            {
                llOwnerSay("Changing region daycycle");
                osReplaceRegionEnvironment(transition, llGetInventoryName(INVENTORY_SETTING, p), (float)(llGetRegionDayLength()/3600), (float)((llGetRegionDayOffset()/3600)-24.0), 0, 0, 0);
                osReplaceRegionEnvironment(transition, llGetInventoryName(INVENTORY_SETTING, p), 4.0, -8.0, 0, 0, 0);
            }
            else 
            {
                llOwnerSay("Changing parcel daycycle");
                osReplaceParcelEnvironment(transition, llGetInventoryName(INVENTORY_SETTING, p));
            }
                
        }
    }
}
Last edited by Graham Mills on Sun May 23, 2021 11:59 am, edited 1 time in total.
These users thanked the author Graham Mills for the post (total 2):
Ilan TochnerDot Matrix
Graham Mills
Posts: 1090
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 747 times
Been thanked: 861 times

Re: Environmental Enhancements and Improved Scripting

Post by Graham Mills »

Modified HUD by adding taper value 0.3 in Y dimension to expose further faces at top (face 3) and bottom (face 1). Touching face 1 assigns currently displayed daycycle to avatar irrespective of location on that region, face 3 reverts to region default. Usual caveats.

Code: Select all

integer p = 0;
integer count;
integer transition = 3;

default
{
    state_entry()
    {
        p = 0;
        count = llGetInventoryNumber(INVENTORY_TEXTURE);
        llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, p), 0);
    }
    
    on_rez(integer n)
    {
        p = 0;
        count = llGetInventoryNumber(INVENTORY_TEXTURE);
        llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, p), 0);
    }
    
    touch_start(integer n)
    {
        list details = llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_NAME]);
        string flag = "";
        if (llSubStringIndex(llList2String(details ,0), "Parcel") > -1)
        {
            flag = "Parcel";
        }
        else if (llSubStringIndex(llList2String(details ,0), "Region") > -1)
        {
            flag = "Region";
        }    
        integer face = llDetectedTouchFace(0);
        if (face == 4)
        {
            //next
            p++;
            if (p == count)
            {
                p = 0;
            }
            llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, p), 0);
        }
        else if (face == 2)
        {
            //prev
            p = p-1;
            if (p < 0)
            {
                p = count-1;
            }
            llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, p), 0);
        }
        else if (face == 0)
        {
            //replace   
            if (flag == "Region")
            {
                llOwnerSay("Changing region daycycle");
                osReplaceRegionEnvironment(transition, llGetInventoryName(INVENTORY_SETTING, p), (float)(llGetRegionDayLength()/3600), (float)((llGetRegionDayOffset()/3600)-24.0), 0, 0, 0);
                osReplaceRegionEnvironment(transition, llGetInventoryName(INVENTORY_SETTING, p), 4.0, -8.0, 0, 0, 0);
            }
            else 
            {
                llOwnerSay("Changing parcel daycycle");
                osReplaceParcelEnvironment(transition, llGetInventoryName(INVENTORY_SETTING, p));
            }    
        }
        else if (face == 1)
        {
            llOwnerSay("Changing avatar daycycle");
            osReplaceAgentEnvironment(llDetectedKey(0), transition, llGetInventoryName(INVENTORY_SETTING, p));
        }
        else if (face == 3)
        {
            llOwnerSay("Reverting avatar daycycle");
            osReplaceAgentEnvironment(llDetectedKey(0), transition, NULL_KEY);
        }
    }
}
These users thanked the author Graham Mills for the post:
Ilan Tochner
Graham Mills
Posts: 1090
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 747 times
Been thanked: 861 times

Re: Environmental Enhancements and Improved Scripting

Post by Graham Mills »

A rather inelegant mod, this both changes the avatar-specific daycycle and makes that daycycle accessible inworld by rezzing an object (daycycle sensor) that changes the daycycle for any avatar that touches it. It could, of course, respond to other events such as proximity or collision.

HUD

Code: Select all

integer p = 0;
integer count;
integer transition = 3;
key DC;

default
{
    state_entry()
    {
        p = 0;
        count = llGetInventoryNumber(INVENTORY_TEXTURE);
        llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, p), 0);
    }
    
    on_rez(integer n)
    {
        p = 0;
        count = llGetInventoryNumber(INVENTORY_TEXTURE);
        llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, p), 0);
    }
    
    object_rez(key k)
    {
        osMessageObject(k, DC);
    } 
        
    
    touch_start(integer n)
    {
        list details = llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_NAME]);
        string flag = "";
        if (llSubStringIndex(llList2String(details ,0), "Parcel") > -1)
        {
            flag = "Parcel";
        }
        else if (llSubStringIndex(llList2String(details ,0), "Region") > -1)
        {
            flag = "Region";
        }    
        integer face = llDetectedTouchFace(0);
        if (face == 4)
        {
            //next
            p++;
            if (p == count)
            {
                p = 0;
            }
            llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, p), 0);
        }
        else if (face == 2)
        {
            //prev
            p = p-1;
            if (p < 0)
            {
                p = count-1;
            }
            llSetTexture(llGetInventoryName(INVENTORY_TEXTURE, p), 0);
        }
        else if (face == 0)
        {
            //replace   
            if (flag == "Region")
            {
                llOwnerSay("Changing region daycycle");
                osReplaceRegionEnvironment(transition, llGetInventoryName(INVENTORY_SETTING, p), (float)(llGetRegionDayLength()/3600), (float)((llGetRegionDayOffset()/3600)-24.0), 0, 0, 0);
                osReplaceRegionEnvironment(transition, llGetInventoryName(INVENTORY_SETTING, p), 4.0, -8.0, 0, 0, 0);
            }
            else 
            {
                llOwnerSay("Changing parcel daycycle");
                osReplaceParcelEnvironment(transition, llGetInventoryName(INVENTORY_SETTING, p));
            }    
        }
        else if (face == 1)
        {
            llOwnerSay("Changing avatar daycycle");
            osReplaceAgentEnvironment(llDetectedKey(0), transition, llGetInventoryName(INVENTORY_SETTING, p));
            DC = llGetInventoryKey(llGetInventoryName(INVENTORY_SETTING, p));
            llRezObject("daycycle sensor", llGetPos(), ZERO_VECTOR, ZERO_ROTATION, 0);
        }
        else if (face == 3)
        {
            llOwnerSay("Reverting avatar daycycle");
            osReplaceAgentEnvironment(llDetectedKey(0), transition, NULL_KEY);
        }
    }
}
daycycle sensor (needs to be added to prim and then taken into HUD inventory)

Code: Select all

key DC;

default
{    
    dataserver(key query_id, string data)
    {
        DC = data;
    }
    
    touch_start(integer n)
    {
        osReplaceAgentEnvironment(llDetectedKey(0), 3, DC);
    }
}
These users thanked the author Graham Mills for the post:
Ilan Tochner
Graham Mills
Posts: 1090
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 747 times
Been thanked: 861 times

Re: Environmental Enhancements and Improved Scripting

Post by Graham Mills »

While there are a number of guides/tutorials on EEP, this is the most useful I've yet found on the role of the various options available under sky and water settings. It includes guidance on how to create a rainbow setting.

https://community.secondlife.com/knowle ... ditor-r24/

Inara Pey also has a number of relevant blogs

https://modemworld.me/2020/04/21/enviro ... -a-primer/

https://modemworld.me/2020/04/21/tutori ... oject-eep/

https://modemworld.me/2020/12/10/firest ... e-release/
These users thanked the author Graham Mills for the post (total 3):
Ilan TochnerDot MatrixAda Radius
Graham Mills
Posts: 1090
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 747 times
Been thanked: 861 times

Re: Environmental Enhancements and Improved Scripting

Post by Graham Mills »

Worth noting that direct access to the old sky presets is available from the Quick Prefs button, bottom right. There are also a few daycycle options, plus any you add yourself.
These users thanked the author Graham Mills for the post:
Ada Radius
Post Reply