Strange Convar.set_int behavior
Posted: Mon Jun 04, 2018 6:18 pm
Hey guys,
I'm using this code to initialize server variables from a txt file:
The problem is that ConVar(line).set_int(0) will not set the variable to 0 but to an empty string, which then leads to problems when I try to do math on them.
When I use
it works like it's intended but does not seem like the way it should be. I think this might be a bug.
Thank you :)
I'm using this code to initialize server variables from a txt file:
Syntax: Select all
import os
from cvars import ConVar
def get_addon_path():
path = os.path.dirname(os.path.abspath(__file__))
return path
path = get_addon_path()+"/svar/svar.txt"
file = open(path)
lines = [line.rstrip('\n') for line in file]
for line in lines:
if not line.startswith('//'):
if line != "":
ConVar(line).set_int(0)
file.close()
The problem is that ConVar(line).set_int(0) will not set the variable to 0 but to an empty string, which then leads to problems when I try to do math on them.
When I use
Syntax: Select all
ConVar(line).set_int(1)
ConVar(line).set_int(0)
it works like it's intended but does not seem like the way it should be. I think this might be a bug.
Thank you :)