Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008770opensim[REGION] Script Functionspublic2020-09-12 02:552020-09-13 05:28
Reportertglion 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusnewResolutionopen 
PlatformLinuxOSOS VersionUbuntu 19.04
Product Version 
Target VersionFixed in Version 
Summary0008770: osGetSunParam("day_length") returns always 0
DescriptionosGetSunParam("day_length") returns always 0

This test is done on commit "7c44bb17808575410ba28831922885f162290532" (master)

I still don't have testet the other parameters. I will maybe do it later.
Steps To ReproduceRun this script for test:
default {
    state_entry() {
        float value = osGetSunParam("day_length");
        llOwnerSay("day_length = "+(string)value);
    }
}
TagsNo tags attached.
Git Revision or version number
Run Mode Grid (1 Region per Sim)
Physics EngineubODE
Script EngineXEngine
EnvironmentMono / Linux64
Mono Version6.x
ViewerSingularity Viewer
Attached Files

- Relationships

-  Notes
(0036814)
JeffKelley (reporter)
2020-09-12 05:46

http://opensimulator.org/wiki/OsGetSunParam [^] :

This funtion does nothing on 0.9.2. It did depend on Sun module, removed on 0.9.2
(0036815)
tglion (reporter)
2020-09-12 07:08

Why?
This was a very usefull function for me for a special Sun script.
And now this is no longer working since Jun 2020. :-(
Is there a way to get back this functionality?
If yes, how? Any help?
(0036816)
UbitUmarov (administrator)
2020-09-12 07:23

As Jeff told that function depended on the sun module, that is no longer compatible with new environment

but there are new functions now. see http://opensimulator.org/wiki/OSSL_Implemented [^] on Environment section
plus some lsl new ones like llGetDayLength(), llGetRegionDayLength etc
(0036817)
tglion (reporter)
2020-09-12 07:32

ohhhh ok, I try the new functions and try to migrate this script... :P
Thanks for the hint.
(0036818)
UbitUmarov (administrator)
2020-09-12 08:16
edited on: 2020-09-12 08:17

changed osGetSunParam so day_length does the same as llGetDayLength() ie lenght at prim location
other parameters return dummy values

osSetSunParam does nothing

(0036819)
JeffKelley (reporter)
2020-09-12 08:24

default
{
    touch_start(integer n)
    {
        float value = osGetSunParam("day_length");
        integer ival = llGetDayLength();
        llOwnerSay("osGetSunParam : "+(string)value);
        llOwnerSay("llGetDayLength : "+(string)ival);
    }
}

[08:23] MANTIS 8770: osGetSunParam : 14400.000000
[08:23] MANTIS 8770: llGetDayLength : 14400

Commit 2020-09-12-64fea8f
(0036820)
UbitUmarov (administrator)
2020-09-12 08:42
edited on: 2020-09-12 08:44

well yeah one returns a float other a int.
goal is so allow some old scripts to still do something.

new ones should use the new functions

(0036821)
tglion (reporter)
2020-09-12 09:48

Mhhhh llGetDayLength() seems not yet implemented in opensim?
> Error CS0103: The name `llGetDayLength' does not exist in the current context

And how can I set the DayLength via Script now?

Thanks.
(0036822)
tglion (reporter)
2020-09-12 10:04

Whuaaaa last commit:
error CS0738: 'OSSL_Api' does not implement interface member 'IOSSL_Api.osGetCurrentSunHour()'. 'OSSL_Api.osGetCurrentSunHour()'

I have first to fix this, I have maybe some merging issues on my local branch
 currently.
(0036823)
JeffKelley (reporter)
2020-09-12 10:16

llGetDayLength was not implemented in the last release of opensim (0.9.1.1). You have to grab a master fresher than 7c44bb1.

Opensim is currently implementing EEP (Environmental Enhancement Project). There is a llGetEnvironment function but not a global SetEnvironment. This is by-avatar and is part of SL "Experiences".

http://wiki.secondlife.com/wiki/LlGetEnvironment [^]
http://wiki.secondlife.com/wiki/LlSetAgentEnvironment [^]
http://wiki.secondlife.com/wiki/LlReplaceAgentEnvironment [^]
(0036824)
tglion (reporter)
2020-09-12 10:44

float value = osGetSunParam("day_length");
returns now 14400.0
The old behavior was to return something like 0.1666... and not 14400.0 ?
(It whas in Days not in seconds)
I am not sure why I can't compile script with integer val=llGetDayLength();
Probably I have still a merging issue on my local branch, I try it on original master now...

osSetSunParam("year_length", 365); //
osSetSunParam("day_length", 24.0); // 24h

is not working either?
Or which command can I use for that now?
(0036825)
UbitUmarov (administrator)
2020-09-12 10:47

not sure what version you are running
sun module was present on 0.9.1 even early 0.9.2
if you are on those, then you have some configuration issue and nothing said here applies to you.

if you are on 0.9.2 then keep in mind the issues of updating code.
clear the solution before pull, pull, runprebuild.. etc

in several cases you may also need to delete scriptengines folder, to force scripts recompile.
(0036826)
tglion (reporter)
2020-09-12 10:52

The couriosity of the old behavier was osGetSunParam("day_length") returning in days (float) and osSetSunParam("day_length", value), value was expected in hours (float). Dont'know why, this is what I can see in the script currently, which is no longer working now in my case, but in the past of jul. 2020.
(0036827)
UbitUmarov (administrator)
2020-09-12 10:57

our old docs state:
// Params "day_length" = "number of seconds to a day"
(0036828)
tglion (reporter)
2020-09-12 10:57

This script was last workin on commit "d7089bcff2d2f886e5f8cef5073afcaf4fb2fec9"
(0036829)
UbitUmarov (administrator)
2020-09-12 11:00

yeah meanwhile EEP happened
(0036830)
tglion (reporter)
2020-09-12 11:11

This ist the original script:

// Constants
float timezone = 1.0; // +2 = MESZ/Berlin

integer oneDay = 86400; // 86400 s = 1440 min = 24 h
integer oneHour = 3600;
integer counter = 0;

setCurrentTime() {
    integer checkDayTime = (integer) (osGetSunParam("day_length") * oneDay + 0.5); // to get the time in seconds for now.
    if (checkDayTime != oneDay) {
        llInstantMessage(llGetOwner(), "The time set is now wrong ("+checkDayTime+"), for whatever reason! Is now correcting to "+(oneDay)+" s/day, by automatically restarting the script...");
        llResetScript();
    }

    integer ut = llGetUnixTime();
    integer dayTime = (ut + (integer)(timezone*(float)oneHour)) % oneDay; // mit

    float x = (float)dayTime / (float)oneHour;
    osSetSunParam("current_time", x);
}

//
// default state
//
default {
    state_entry() {
        llSetText("Sun-God",<1,1,1>, 1);
        osSetSunParam("year_length", 365); // Set the year to 365 days, probably this does not have any effect in opensim.
        osSetSunParam("day_length", 24.0); // 24h day (strange, to have set in h and get returns in days...
        osSetSunParam("day_night_offset", 0.0);
        osSetSunParam("day_time_sun_hour_scale", 0.5); // 0.5 = day and night have the same length (does this have any effect in opensim, i think no?)
        osSetSunParam("update_interval", 50); // 10 = 1s, 50 = 5s, 100 = 10s
        setCurrentTime();
        llListen(-800, "", NULL_KEY, "");
        llInstantMessage(llGetOwner(), "INIT Sun-God on region '"+llGetRegionName()+"' is done and ready to work.");
        llSetTimerEvent(1.0);
    }

    on_rez(integer param) {
        llResetScript();
    }

    listen(integer c, string name, key id, string msg) {
        if (c == -800 && id == NULL_KEY) { // SIM restart detected
            llResetScript();
        }
    }

    timer() {
        integer ut = llGetUnixTime();
        integer dayTime = (ut + (integer)(timezone*(float)oneHour)) % oneDay;
        float x = (float)dayTime / (float)oneHour;

        if (++counter > 9) {
           counter = 0;
           setCurrentTime();
        }

        integer istTag = (dayTime <= oneHour*18 && dayTime > oneHour*6);
        if (istTag) {
            integer t = oneHour*18 - dayTime;
            integer h = (integer) t / oneHour;
            integer m = (integer) ((t*60 / oneHour) % 60);
            integer s = (integer) (t % 60);
            llSetText("Sun-God\nTime until sunset: "+(string)h+" h, "+(string)m+" m, "+(string)s+" s.", <1,1,1>, 1);
        }
        else {
            integer t = oneHour*6 - dayTime;
            if (t < 0)
                t = oneDay + t;
            integer h = (integer) t / oneHour;
            integer m = (integer) ((t*60 / oneHour) % 60);
            integer s = (integer) (t % 60);
            llSetText("Sun-God\nTime until sunrise: "+(string)h+" h, "+(string)m+" m, "+(string)s+" s.", <1,1,1>, 1);
        }

    }
}
(0036831)
tglion (reporter)
2020-09-12 11:15

I currently have no idea how to migrate this script correctly to the new EEP Environment.?
(0036832)
tglion (reporter)
2020-09-12 11:18

I am confused for now, try it later again...
(0036833)
tampa (reporter)
2020-09-12 12:03

Would help to know what you want the output to be...
(0036834)
UbitUmarov (administrator)
2020-09-12 12:14

eep viewer do their own time control based on the utc time they see, day length and day offset (from utc)

lsl does not contain any set for those, only get.

for now the close we have is http://opensimulator.org/wiki/OsReplaceRegionEnvironment [^]

osReplaceRegionEnvironment(0, "", 24, 1, -1, -1, -1) ??
or
osReplaceRegionEnvironment(0, "", 24, 2, -1, -1, -1) for berlin?

note you need last commit with fixed osReplaceRegionEnvironment
(0036849)
tglion (reporter)
2020-09-13 02:57

yah, the script is working with osReplaceRegionEnvironment now. :-)
Is this by design, that I can not set values less thann 4 hours?
(0036850)
UbitUmarov (administrator)
2020-09-13 05:28

yes viewer side lower limit

- Issue History
Date Modified Username Field Change
2020-09-12 02:55 tglion New Issue
2020-09-12 05:46 JeffKelley Note Added: 0036814
2020-09-12 07:08 tglion Note Added: 0036815
2020-09-12 07:23 UbitUmarov Note Added: 0036816
2020-09-12 07:32 tglion Note Added: 0036817
2020-09-12 08:16 UbitUmarov Note Added: 0036818
2020-09-12 08:17 UbitUmarov Note Edited: 0036818 View Revisions
2020-09-12 08:24 JeffKelley Note Added: 0036819
2020-09-12 08:42 UbitUmarov Note Added: 0036820
2020-09-12 08:44 UbitUmarov Note Edited: 0036820 View Revisions
2020-09-12 09:48 tglion Note Added: 0036821
2020-09-12 10:04 tglion Note Added: 0036822
2020-09-12 10:16 JeffKelley Note Added: 0036823
2020-09-12 10:44 tglion Note Added: 0036824
2020-09-12 10:47 UbitUmarov Note Added: 0036825
2020-09-12 10:52 tglion Note Added: 0036826
2020-09-12 10:57 UbitUmarov Note Added: 0036827
2020-09-12 10:57 tglion Note Added: 0036828
2020-09-12 11:00 UbitUmarov Note Added: 0036829
2020-09-12 11:11 tglion Note Added: 0036830
2020-09-12 11:15 tglion Note Added: 0036831
2020-09-12 11:18 tglion Note Added: 0036832
2020-09-12 12:03 tampa Note Added: 0036833
2020-09-12 12:14 UbitUmarov Note Added: 0036834
2020-09-13 02:57 tglion Note Added: 0036849
2020-09-13 05:28 UbitUmarov Note Added: 0036850


Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker