-
May 27th, 2014, 20:59 #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.FG Wish List - https://fgapp.idea.informer.com/
License: Ultimate [Unlicensed/Free Trial FG users can play in my games]
-
May 27th, 2014, 21:07 #2
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-rulesetsPrivate 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!
-
May 27th, 2014, 21:24 #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.FG Wish List - https://fgapp.idea.informer.com/
License: Ultimate [Unlicensed/Free Trial FG users can play in my games]
-
May 27th, 2014, 21:32 #4
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!
-
May 27th, 2014, 21:33 #5
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!
-
May 27th, 2014, 21:40 #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.
FG Wish List - https://fgapp.idea.informer.com/
License: Ultimate [Unlicensed/Free Trial FG users can play in my games]
-
May 27th, 2014, 21:47 #7
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!
-
May 27th, 2014, 21:51 #8
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,539
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
-
May 27th, 2014, 22:22 #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.FG Wish List - https://fgapp.idea.informer.com/
License: Ultimate [Unlicensed/Free Trial FG users can play in my games]
-
May 27th, 2014, 22:30 #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>
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
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
FG Wish List - https://fgapp.idea.informer.com/
License: Ultimate [Unlicensed/Free Trial FG users can play in my games]
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks