Import variable from plugin a to plugin b
Posted: Wed Feb 05, 2014 6:16 am
Hello,
So i'm trying to import a variable from plugin a to plugin b, but i'm not being able to understand where the error is because the plugin2 just says it can't be loaded.
Code
Is this even possible with SP? I've done something similar with ES and it works. It's probably a namespace issue, but i can't seem to figure it out.
Thanks!
Edit:
I think i "figured it out", i've created at __init__.py with the necessary variables and it allows me to import it correctly.
So i'm trying to import a variable from plugin a to plugin b, but i'm not being able to understand where the error is because the plugin2 just says it can't be loaded.
Code
Syntax: Select all
# cstrike/addons/source-python/plugins/plugin1/plugin1.py
variable = ["foo"]
Syntax: Select all
# cstrike/addons/source-python/plugins/plugin2/plugin2.py
from plugin1 import variable
Code: Select all
# cstrike/cfg/autoexec.cfg
sp load plugin1
sp load plugin2
Is this even possible with SP? I've done something similar with ES and it works. It's probably a namespace issue, but i can't seem to figure it out.
Thanks!
Edit:
I think i "figured it out", i've created at __init__.py with the necessary variables and it allows me to import it correctly.