Bridge Commander Central
BC Forums => BC Scripting => Topic started by: Rob Archer on August 29, 2006, 01:20:48 PM
-
I know how to get the SetName Using the
pSet.GetName() command
but i want to use it to import the corosponding file from a directory.
Example of what ive tried:
pPlayer = MissionLib.GetPlayer()
pSet = pPlayer.GetContainingSet()
sSetName = pSet.GetName()
print("Current Location: " + str(sSetName))
__import__ ("Custom.QBautostart.NFSystemDirectory." + sSetName)
So it will import the name of the system i.e Belaruz4 and add it so it will
import Custom.QBautostart.NFSystemDirectory.Belaruz4
Ive had it working with the Print Command but i cant get it to acctually import the file can someone lend a hand.
-
For starters, there would need to be a file (or directory with __init__.py in it) called that way in scripts/Custom/QBautostart/NFSystemDirectory.
-
I know how to get the SetName Using the
pSet.GetName() command
but i want to use it to import the corosponding file from a directory.
Example of what ive tried:
pPlayer = MissionLib.GetPlayer()
pSet = pPlayer.GetContainingSet()
sSetName = pSet.GetName()
print("Current Location: " + str(sSetName))
__import__ ("Custom.QBautostart.NFSystemDirectory." + sSetName)
So it will import the name of the system i.e Belaruz4 and add it so it will
import Custom.QBautostart.NFSystemDirectory.Belaruz4
Ive had it working with the Print Command but i cant get it to acctually import the file can someone lend a hand.
I presume you know the __import__ command doesn't work quite like normal importing?
If you're trying to access variables or methods in the imported module, you need to do something like this:
mModule = __import__("stuff")
mModule.Whatever()
-
Thanks Guys
I figured it out in the end anyway and the system seems to be doing what i want
Thanks for the help.