STAR TREK 2d20
  1. #1

    Extentions and Slash Commands

    Hello, all!

    I'm working on modifying a ruleset but have plans of making it into an Extention instead. In the process, I'm updating the chatmanager.lua to include additional chat slash commands.

    So, since I'm updating the onInit() of the Lua file, will this work? If I have my own onInit() in the extention, would this override the original ruleset onInit() and void any of the original slash commands?

    If the above prove to be negative, would there be another way of registering the the slash commands?

    When does the chatmanager.lua onInit() actually kick off? Is it after the Extentions are brought into the load sequence? If so, would it be possible to, somehow, get the contents of the ruleset's onInit() (I think I read that a Lua function is essentially a table) and then append the new slash commands to it?

    Any help is appreciated!

  2. #2
    I believe it depends on the mergerule for the control. But that the default is replace.
    • Trying to find a community Ruleset, Extension or Information on how to complete a process? Try FGRepository.
    • PM Myself if you have new or updated community Rulesets, Extensions or Information that you'd like added to FGRepository.

  3. #3
    just to quote from the help files (recently thoughtfully packaged in pdf by spudmanWP)

    "The process of activating extensions happens in the following order:
    · The ruleset files are parsed and processed.
    · The extension files are parsed and processed, in dependency order.
    · Templates are processed.
    · Controls such as desktop elements are created.
    · Global ruleset script blocks are initialized.
    · Extension script blocks are initialized, in dependency order.
    This means that extensions can override resources such as graphics and window classes. Templates in extensions
    affect the controls using them in the ruleset, due to them being processed before any controls are actually created.
    The ruleset performs any initialization before any of the extensions are initialized. "

    the order of loading of the global scripts is determined by ther order within the base.xml, in d20_JPG chatmanager.lua is the first script loaded but it can still be completely overridden by any chatmanager.lua file within the extention.

    However, slash commands don't have to be placed in the chatmanager.lua onInit(), they can be registered by any function, although the registering itself is done by the registerSlashHandler function in the chatmanager.lua file.

    there are a couple of examples in the d20_jpg ruleset (possibly this code is also in other rulesets)

    the /export command registration is initiated by the exportmanager.lua
    and the /identity & /gmid command registration is initiated by the gmidmanager.lua

    like chatmanager.lua these are both global scripts, and the slash commands are in the onInit() of those files, this means they are up and running from the get go.

    you just need to point FG in the direction of ChatManager when you write the code

    eg. " ChatManager.registerSlashHandler("/gmid", slashCommandHandlerGmId); "

    the 'callback' - slashCommandHandlerGmId() function - is also located in the gmidentity.lua file so once 'handled' chatmanager.lua sends the parameters to this function for processing

  4. #4
    Thanks Sorcerer!

    I was thinking that the onInit() functions kicked off on the load of the file and act more like the sidebar. Glad to see it doesn't

    I'll keep the other references in mind for later as well!

    Thanks everyone!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
DICE PACKS BUNDLE

Log in

Log in