def load_user_logic(module_name):
full_path = bge.logic.expandPath("//bgelogic/cells/{}.py".format(module_name))
loaded_value = _loaded_userlogic_files.get(full_path)
if loaded_value: return loaded_value
import sys
python_version = sys.version_info
major = python_version[0]
minor = python_version[1]
if (major < 3) or (major == 3 and minor < 3):
import imp
loaded_value = imp.load_source(module_name, full_path)
elif (major == 3) and (minor < 5):
from importlib.machinery import SourceFileLoader
loaded_value = SourceFileLoader(module_name, full_path).load_module()
else:
import importlib.util
spec = importlib.util.spec_from_file_location(module_name, full_path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
loaded_value = module
_loaded_userlogic_files[module_name] = loaded_value
return loaded_value
评论列表
文章目录