ConVar creation changes

Discuss API design here.
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

ConVar creation changes

Postby satoon101 » Sun Dec 27, 2015 4:23 pm

Previously, if you did not want to use any ConVarFlags when creating a ConVar instance, you had to use either of the following:

Syntax: Select all

from cvars import ConVar
from cvars.flags import ConVarFlags

my_convar = ConVar('name', 'value', ConVarFlags.NONE, 'My ConVar description.')

my_convar = ConVar('name', 'value', description='My ConVar description.')


We decided, since most of the time no flags would be given anyway, to reverse the order of those 2 arguments. So now, you can just use:

Syntax: Select all

from cvars import ConVar

my_convar = ConVar('name', 'value', 'My ConVar description.')


If you do want to pass flags, you would now instead use:

Syntax: Select all

from cvars import ConVar
from cvars.flags import ConVarFlags

my_convar = ConVar('name', 'value', 'My ConVar description.', ConVarFlags.NOTIFY)


All instances of this throughout the API were changed, including the internal _ConVar class. The _ConVar class is now responsible for switching the 2 arguments internally to get the object correctly.
Image

Return to “API Design”

Who is online

Users browsing this forum: No registered users and 14 guests