Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: EK.IceFlake on Nov 17, 2016, 11:41 AM

Title: C# set/get equivalent in squirrel?
Post by: EK.IceFlake on Nov 17, 2016, 11:41 AM
In C# we can
public string sNub
{
    set
    {
        //...
    }
    get
    {
        //...
        return "nub";
    }
}

so when we
sNub = something
then set will get called and a variable will be created inside it 'value' which will be the something.
in get, whatever we return is the value of that variable

Does squirrel has an equivalent?

Thank you.
Title: Re: C# set/get equivalent in squirrel?
Post by: KAKAN on Nov 17, 2016, 12:16 PM
Squirrel has _set and _get metamod.
Title: Re: C# set/get equivalent in squirrel?
Post by: EK.IceFlake on Nov 17, 2016, 12:18 PM
Quote from: KAKAN on Nov 17, 2016, 12:16 PMSquirrel has _set and _get metamod.
How to use it?
Title: Re: C# set/get equivalent in squirrel?
Post by: KAKAN on Nov 17, 2016, 12:50 PM
Quote from: EK.CrystalBlue on Nov 17, 2016, 12:18 PM
Quote from: KAKAN on Nov 17, 2016, 12:16 PMSquirrel has _set and _get metamod.
How to use it?
class test{
function _set(idx, val){ print( "Someone is trying to change the value of '" + idx + "' to '" + val + "'"); }
function _get(idx, val){ print( "Someone is trying to get the value of '" + idx); }
}
More info here:- http://www.squirrel-lang.org/squirreldoc/reference/language/metamethods.html