STAR TREK 2d20
Page 1 of 2 12 Last
  1. #1

    Comm function to post a chat command...

    Hi -

    Is there an example or simple explanation somewhere for how to use the Comm API to send an extension command that will be executed by the chat command parser, rather than just sending it as message text (not executed)?

    Thx.

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    You mean for a slash command? If so: https://www.fantasygrounds.com/refdo...erSlashHandler

    Look in CoreRPG desktop\scripts\manager_chat.lua for examples.

    Or look at the languages extension as an example of an extension that uses slash commands. https://www.fantasygrounds.com/forum...G-3-0-rulesets
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  3. #3
    I want to intercept a custom slash command and use it as a macro to execute other default chat functions. I was expecting to see a command in the chat API along the lines of: Comm.sendChatCmd

    The Language plugin doesn't appear to send commands, just parse them and display messages and I can't find anything in the API that would let me send a slash command back to the window.

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    I don't think you can send a slashcommand to the chat window through scripting.

    Slash handlers generally run functions within FG code (although there are some built in slash commands). If it is not a built in slash command then you can call the slash handler event directly.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  5. #5
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    I don't think you can send a slashcommand to the chat window through scripting.

    Slash handlers generally run functions within FG code (although there are some built in slash commands). If it is not a built in slash command then you can call the slash handler event handler function directly.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  6. #6
    I see onSlashCommand under chatentry but what is the runtime class hierarchy? Also, parenthetically, I would suggest adding this function to the Comm class, assuming there are no re-entrancy issues.

  7. #7
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    As mentioned above, look at desktop\scripts\manager_chat.lua for examples of registering slash handlers and the functions they call when the slash handler event triggers - you could call the specific slash handler function.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  8. #8
    I would just call the command handler directly for the command you want to call.

    Ex:
    /die 1d6 Die Test
    ---->
    ChatManager.processDie("die", "1d6 Die Test")

    Regards,
    JPG

  9. #9
    OK - I found my error. I had originally done exactly what you said and was calling directly into Interface.setLighting, but it wasn't working. The screen was turning black. So, then I went on a path wanting to just send macros to the chat window for execution, which I thought would be incredibly simple and useful...but couldn't find the function, hence this thread. I just re-read the Interface API and the problem was that I was passing hex RGB instead of string RGB. And, as an example, what I was looking for was in utility_misc.xml.

    I would strongly encourage the addition of a Comm macro member so that scripts could send commands through the top-level chat API with Comm.doChatCmd or something similar. It is incredibly useful and probably not the best approach to call into lower level APIs that could be subject to change. To implement this change would take very little code/minimal risk and make accessing other chat commands at the script level much safer and easier for all concerned.

  10. #10
    For those who are interested in controlling the lighting - the templatized form from utility_misc.xml from CoreRPG looks like this:

    Code:
    <lightingselection name="night">
        <anchored to="day" position="below" height="100" />
        <icon><normal>lighting_night</normal></icon>
        <light><window>FFB8A4</window></light>
    </lightingselection>
    In this case, for night lighting, the markup sets up the window BGR value as a hex string "FFB8A4".

    Programmatically, and per the Interface API documentation here: https://www.fantasygrounds.com/refdo...cp#setLighting , setting the lighting looks like this: function setLighting( systemcolor, windowcolor, controlcolor, contentcolor )

    or, specifically in the example above (in ABGR Format):

    Code:
    function doNightLighting()
        Interface.setLighting( "ffffffff", "FFFFB8A4", "ffffffff", "ffffffff" );
    end
    So, it helps to RTFM and not pass hex instead of strings. Also, if you want to control ambient lighting, you should only change the window parameter, as stated in the docs.

    I hope this is useful to someone. It's kind of a fun command and allows you to extend the lighting for all kinds of adventure scenarios besides just the default 4.

    ps. The default window lighting param values are (in ABGR Format):
    Day: "FFFFFFFF"
    Night: "FFFFB8A4"
    Fire: "FFB1C6F4"
    Forest: "FFE0FDE6"

    ...and I do believe I have just made my first FG extension! Well...now that it #$#%@#$@# works, I can move forward. My previous concept barrier was zipping the xml/script as a folder. Haha! Ummm...if you are making your first extension, make sure you're just zipping the files and sub-directories.

    Edit: NOTE: when using the chat command /lighting [value], the format must be RGB. When using the API call, the format must be BGR or ABGR.
    Last edited by HoloGnome; May 29th, 2014 at 17:02. Reason: api inconsistency

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
  •  
FG Spreadshirt Swag

Log in

Log in