[SERVER] GetWorldBounds

Started by vitosca, Jan 22, 2016, 01:59 PM

Previous topic - Next topic

vitosca

Hello. I have latest server windows version x64.

How to parse GetWorldBounds data to float?
Example from http://wiki.vc-mp.org/wiki/Scripting/Squirrel/Functions/Bounds
function onScriptLoad()
{
    local boundaries = GetWorldBounds();
    print( "Worldboundaries has been set to :" + boundaries.maxX + "," + boundaries.minX + "," + boundaries.maxY + "," + boundaries.minY );
}
don't work for me. I got an error 'Member Variable not found'

.

That's because if you look at the documentation history. You will see that it was created by nabs who don't give a f* about testing the code first.


According to the module source code. They begin with a capital letter as well.
Sqrat::RootTable().Bind(_SC("Bounds"), Sqrat::Class<Bounds>(Sqrat::DefaultVM::Get(), _SC("Bounds"))
        .Ctor<float, float, float, float>()

        .Var(_SC("MaxX"), &Bounds::maxX)
        .Var(_SC("MinX"), &Bounds::minX)
        .Var(_SC("MaxY"), &Bounds::maxY)
        .Var(_SC("MinY"), &Bounds::minY)
    );

And creating a piece of code to inspect the type I'm interested in:
foreach (k1, v1 in getroottable())
{
    if (k1 == "Bounds")
    {
        foreach (k2, v2 in v1)
        {
            print("name: " + k2 + " type: " + typeof(v2));

            if (typeof(v2) == "table")
            {
                foreach (k3, v3 in v2)
                {
                    print("-- name: " + k3 + " type: " + typeof(v3));
                }
            }
        }
    }
}

Gives me the following:
[MODULE]  Loaded SqVCMP 0.4 frontend by Stormeus. (v1.0)
[SCRIPT]  name: constructor type: function
[SCRIPT]  name: __setTable type: table
[SCRIPT]  -- name: MinY type: function
[SCRIPT]  -- name: MinX type: function
[SCRIPT]  -- name: MaxY type: function
[SCRIPT]  -- name: MaxX type: function
[SCRIPT]  name: __getTable type: table
[SCRIPT]  -- name: MinY type: function
[SCRIPT]  -- name: MinX type: function
[SCRIPT]  -- name: MaxY type: function
[SCRIPT]  -- name: MaxX type: function
[SCRIPT]  name: weakref type: function

Which confirms the fact that they begin with a capital letter.
.

vitosca

Thank you so much. It's really a big problem with documentation for vc-mp.

.

Quote from: vitosca on Jan 22, 2016, 05:14 PMIt's really a big problem with documentation for vc-mp.

You can always ask on the forum or via IRC.
.

vitosca

#4
Sorry for dumb question. I have make that zone

function onScriptLoad()
{
   SetWorldBounds( -636, -720, 793, 703 );
}
but it no affect on game

edit: It's affects only after reconnect