Exemplo n.º 1
0
    def _load(self, name, module, path, path_es, listener):
        assert name not in self, name

        try:
            instance = self.instance(name)
        except:
            warn(f'Unable to load {name}.')

            raise

        instance.type = self._get_value_module_type(name, path, path_es)

        if instance.type is None:
            raise FileNotFoundError(ENOENT, strerror(ENOENT),
                                    path / name / '__init__.py')

        self[name] = instance

        if instance.type is ModuleType.SP:
            try:
                self[name].module = import_module(
                    f'wcs.modules.{module}.{name}')
            except:
                del self[name]

                raise
        else:
            es.load(f'wcs/modules/{module}/{name}')

        listener.manager.notify(name, instance)

        return instance
Exemplo n.º 2
0
def load():
    if cvar.find_var('eventscripts_addondir') is not None:
        raise RuntimeError('EventScripts is already loaded.')

    print('Adding "{}" to sys.path.'.format(str(ES_PATH)))
    sys.path.append(str(ES_PATH))

    print('Adding "{}" to sys.path.'.format(ES_LIBS_PATH))
    sys.path.append(str(ES_LIBS_PATH))

    print('Initializing console variables...')
    from . import cvars

    print('Initializing console commands...')
    from . import cmds

    print('Initializing logic...')
    from . import logic

    print('Initializing EventScripts...')
    import es

    logic.post_initialization()

    # TODO: There is a conflict between ES' and SP's keyvalues module
    import _libs.python.keyvalues as x
    sys.modules['keyvalues'] = x
    es.load('esc')
    es.server.queuecmd('es_load corelib')
Exemplo n.º 3
0
 def mapStart(self,gameplay=''):
     self.gameplay = gameplay if gameplay else self.gameplay
     if not self.gameplay or not self.gameplay in gameplay_ini or not lmv_scripts_for_gameplay: return
     for script in gameplay_ini[self.gameplay]['Scripts']:
         es.load(gameplay_ini[self.gameplay]['Scripts'][script])
     for cfg in gameplay_ini[self.gameplay]['Configs']:
         es.server.queuecmd('es_mexec ../%s/%s.cfg'%(gamename,gameplay_ini[self.gameplay]['Configs'][cfg]))
Exemplo n.º 4
0
def load():
    herolist = str(es.ServerVar('herolist')).split(',')
    counter = 0
    global heroes
    heroes = {}
    for hero in herolist:
        es.load('superhero/heroes/' + str(hero))
        counter += 1
    print "[SH] Loaded", counter, "Heroes"
Exemplo n.º 5
0
def load():
    herolist = str(es.ServerVar('herolist')).split(',')
    counter = 0
    global heroes
    heroes = {}
    for hero in herolist:
        es.load('superhero/heroes/'+str(hero))
        counter += 1
    print "[SH] Loaded",counter,"Heroes"
Exemplo n.º 6
0
def _reload(argv):
  if argv:
    addonname = cleanpath(argv[0])
    if addonname in addons:
      addons[addonname].reload()
    elif addonname in pyaddons():
      sv.save()
      es.reload(addonname)
    else:
      es.load(argv[0])
Exemplo n.º 7
0
def load(argv):
  if argv:
    addonname = cleanpath(argv[0])
    newaddon = Addon(addonname)
    if newaddon.pyscriptexists():
      sv.save()
      es.load(addonname)
    else:
      newaddon.load()
  else:
    es.dbgmsg(0, '[Eventscripts] Loaded:\n')
    for addonname in sorted(addons):
      es.dbgmsg(0, '[Eventscripts] [%sabled] %s' % ('dis' if addons[addonname].disabled else 'en', addonname))
    for addonname in sorted('/'.join(addon.__name__.split('.')[1:]) for addon in es.addons.AddonList):
      es.dbgmsg(0, '[Eventscripts] [enabled] %s' % addonname)
Exemplo n.º 8
0
def load(argv):
  if argv:
    addonname = cleanpath(argv[0])
    newaddon = Addon(addonname)
    if newaddon.pyscriptexists():
      sv.save()
      es.load(addonname)
    else:
      newaddon.load()
  else:
    es.dbgmsg(0, '[Eventscripts] Loaded:\n')
    for addonname in sorted(addons):
      es.dbgmsg(0, '[Eventscripts] [%sabled] %s' % ('dis' if addons[addonname].disabled else 'en', addonname))
    for addonname in sorted('/'.join(addon.__name__.split('.')[1:]) for addon in es.addons.AddonList):
      es.dbgmsg(0, '[Eventscripts] [enabled] %s' % addonname)
Exemplo n.º 9
0
def decrement(variable, silent=False):
	"""
	Decreases the reference count of an addon by one.
	"""
	if not _addons.has_key(addon):
		raise ReferenceError, name + " has a reference count of 0."

	# Decrease the reference count for the addon.
	_addons[addon]["count"] -= 1
	count = _addons[addon]["count"]
	if 0 == count:
		es.unload(addon)
		del _addons[name]
	else:
		es.load(addon)

	es.dbgmsg(1, 'refcount: Addon "%s" has a reference count of "%d".' % (addon, count))
Exemplo n.º 10
0
def increment(addon):
	"""
	Increases the reference count of an addon by one.
	"""
	count = 1
	if _addons.has_key(addon):
		_addons[addon]["count"] += 1
		count = _addons[addon]["count"]
	else:
		_addons[addon]["count"] = 1
		es.createscriptlist("_refcount_scripts")
		_addons[addon]["oldValue"] = es.exists("key", "_refcount_scripts", addon)
		es.keygroupdelete("_refcount_scripts")

	# Load the addon.
	es.load(addon)

	es.dbgmsg(1, 'refcount: Addon "%s" has a reference count of "%d".' % (addon, count))
Exemplo n.º 11
0
 def toggleAddon(self, userid, choice, popupid):
     """
     This callback function allows us to toggle on / off any active / inactive
     addons
     
     @PARAM userid - the player who toggled the addons
     @PARAM choice - the name of the skill to toggle
     @PARAM popupid - the name of the popup used to access this method
     """
     tokens = {}
     tokens['addon'] = choice
     if choice in sourcerpg.addons:
         tokens['status'] = "disabled"
         es.unload("%s/addons/%s" % (sourcerpg.info.basename, choice))
     else:
         tokens['status'] = "enabled"
         es.load("%s/addons/%s" % (sourcerpg.info.basename, choice))
     gamethread.delayed(0, self.buildAddons, userid)
     tell(userid, 'addon toggled', tokens)
Exemplo n.º 12
0
 def toggleAddon(self, userid, choice, popupid):
     """
     This callback function allows us to toggle on / off any active / inactive
     addons
     
     @PARAM userid - the player who toggled the addons
     @PARAM choice - the name of the skill to toggle
     @PARAM popupid - the name of the popup used to access this method
     """
     tokens = {}
     tokens['addon'] = choice
     if choice in sourcerpg.addons:
         tokens['status'] = "disabled"
         es.unload("%s/addons/%s" % (sourcerpg.info.basename, choice))
     else:
         tokens['status'] = "enabled"
         es.load("%s/addons/%s" % (sourcerpg.info.basename, choice))
     gamethread.delayed(0, self.buildAddons, userid)
     tell(userid, 'addon toggled', tokens)
Exemplo n.º 13
0
def wcsaddons_load(args):
    if len(args) == 1:
        epath = path + "/addons/%s" % args[0]
        if os.path.isdir(epath):
            ppath = epath + "/%s.py" % args[0]
            epath = epath + "/es_%s.txt" % args[0]
            if os.path.isfile(epath) or os.path.isfile(ppath):
                epath = "wcs/wcsaddons/addons/%s" % args[0]
                es.load(epath)
            else:
                es.dbgmsg(
                    0,
                    "Error could not load wcsaddon %s, file was not found." %
                    args[0])
        else:
            es.dbgmsg(
                0,
                "Error could not load wcsaddon %s, directory %s was not found."
                % (args[0], epath))
    else:
        es.dbgmsg(
            0,
            "Error you have too many or too less arguments. Syntax - wcsaddons_load <addon>"
        )
Exemplo n.º 14
0
def load():
    es.dbgmsg(0, "--- WCS Tools loading ---")
    es.load('tools/cmds')
    es.load('tools/commands')
    es.load('tools/console')
    es.load('tools/effect')
    es.load('tools/effects')
    es.load('tools/expand')
    es.load('tools/firefix')
    es.load('tools/getcolor')
    es.load('tools/longjump')
    es.load('tools/nearcoord')
    es.load('tools/pending')
    es.load('tools/randplayer')
    es.load('tools/ultimates')
    es.load('tools/ultimatespy')
    es.load('tools/wcsgroup')
    es.load('tools/wcsgroup_es')
    es.load('tools/xcommands')
    es.load('tools/setfx')
    es.load('tools/myraces')
    es.dbgmsg(0, "--- WCS Tools loaded ---")
def reload(addonname):
    es.unload(addonname)
    es.load(addonname)
Exemplo n.º 16
0
def reload(addonname):
    es.unload(addonname)
    es.load(addonname)