[Opensim-dev] new LSL state to implement

Mark Wagner carnildo at gmail.com
Tue Jul 29 21:06:08 UTC 2008


On Tue, Jul 29, 2008 at 13:41, Chang, Francis <francis.chang at intel.com> wrote:

>  New suggestion: Use a magic variable - opensim compilers will automatigically change the value:
>
> string __MAGIC_VAR_SERVER_MAJOR_VERSION__ = "";
>
> string getCurrentGrid() {
>        if ( __MAGIC_VAR_SERVER_MAJOR_VERSION__ == "" )
>                return "LL_GRID";
>        else if ( __MAGIC_VAR_SERVER_MAJOR_VERSION__ == "OPENSIM")
>                return "OS_GRID";
>        else
>                return  "UNKOWN_GRID";
> }
>
> It would work forever going forward, since we're just changing the result of well-defined correct behaviour. This could be handled at both at runtime or compile time.
>
> The drawback is it would be a total hack.
>

Another option that's a total hack would be stub functions that the
OpenSimulator compiler removes, but the SecondLife compiler doesn't.
For example:

string osGetRuntimeEnvironment()
{
    return "Linden";
}

integer osDoSomethingFancyAndServerSpecific()
{
    return 0;
}

default
{
    state_entry()
    {
        if(osGetRuntimeEnvironment() == "OpenSim")
        {
            osDoSomethingFancyAndServerSpecific();
        }
    }
}

When the SecondLife compiler encounters this, it compiles the stub
versions of the OS functions in.  The script runs and does only
Linden-compatible things.  When the OpenSimulator compiler encounters
this, it would discard the stub functions and link to the real ones.
This has the advantage over the magic constants in that you can use OS
functions in the code, and still compile on the SL grid.

-- 
Mark Wagner



More information about the Opensim-dev mailing list