Thread: Extension Loading Issue
-
August 3rd, 2020, 23:02 #21
- Join Date
- Aug 2014
- Posts
- 77
Another simple question: does Comm.registerSlashHandler() allow one to add new slash commands? I found several lines of code like:
Comm.registerSlashHandler("r", processReply);
But my attempts to add a new command by simply switch "r" with something else, but leaving the rest unchanged have been unsuccessful.
-
August 4th, 2020, 01:50 #22
/r is already used by /reply /rollon and /reload
-
August 4th, 2020, 10:05 #23
- Join Date
- Aug 2014
- Posts
- 77
I should have been clearer. Below is what I tried to do, but /step3 doesn't do the same thing as /r
Code:-- Initialization function onInit() Comm.registerSlashHandler("step3", processReply); end
-
August 4th, 2020, 14:24 #24
the processReply function has to exist. when you are registering the slash command, you have to tell it what function to call when that command is issued. So somewhere you would need to have a function defined to handle it.
Code:-- Initialization function onInit() Comm.registerSlashHandler("step3", processReply); end function processReply(sCommand, sParams) do something; end
For support with any of my extensions, visit my #mattekure-stuff channel on Rob2e's discord https://discord.gg/rob2e
-
August 4th, 2020, 14:32 #25
- Join Date
- Aug 2014
- Posts
- 77
I have so much to learn.
I really want step3 to do "/die 1d4e", and want to extend it to other stepX values which have a variety of dice combinations. Any recommendations for the best direction to head?
-
August 8th, 2020, 14:04 #26
- Join Date
- Aug 2014
- Posts
- 77
Bumping this since I still haven't figured out how to roll dice. I have my slash handler working though.
-
August 9th, 2020, 06:04 #27
- Join Date
- Jun 2020
- Posts
- 28
Okay, to roll a die AND do something afterwards, you can do the following: (This is for CoreRPG, it may be slightly different in other rulesets...)
Code:-- Initialization function onInit() Comm.registerSlashHandler("step3", processStep3); --Register our new action GameSystem.actions["step_handler"] = { bUseModStack = false }; --Register the result handler ActionsManager.registerResultHandler("step_action", onRoll); end function processStep3(sCommand, sParams) local rRoll = {}; -- Required rRoll.sType = "step_action"; -- the type for the roll (Should match what is defined above! rRoll.aDice = { "d4" }; -- die to roll, 2d4 would be { "d4", "d4" } rRoll.nMod = 0; -- the modifier rRoll.sDesc = "[Step Slash]"; --Optional rRoll.nTarget = 2; -- The target (DC) for the roll (Optional, and YOU must handle checking it later...) rRoll.bSecret = true; -- True for secret GM roll, otherwise, false ActionsManager.performAction(nil, nil, rRoll); --This can take parameters such as WHO rolled which can be used to look up info, WHO is being targetted to apply damage, etc... end function onRoll(rSource, rTarget, rRoll) local rMessage = ActionsManager.createActionMessage(rSource, rRoll); local bSuccess = false; if rRoll.nTarget then local nTotal = ActionsManager.total(rRoll); local nTarget = tonumber(rRoll.nTarget) or 0; rMessage.text = rMessage.text .. " (vs. DC " .. nTarget .. ")"; if nTotal >= nTarget then rMessage.text = rMessage.text .. " [SUCCESS]"; bSuccess = true; else rMessage.text = rMessage.text .. " [FAILURE]"; end end --rMessage.icon = "ICON_NAME"; Comm.deliverChatMessage(rMessage); end
Trenloe posted a great explanation on rolling dice here -> https://www.fantasygrounds.com/forum...ns)-in-CoreRPG
-
August 9th, 2020, 11:38 #28
- Join Date
- Aug 2014
- Posts
- 77
Thanks!
I searched the forums repeatedly to try to find examples and the Trenloe post never came up; guess I didn't choose the correct search criteria.
-
August 9th, 2020, 12:31 #29bmos' extensions
he/them
-
August 9th, 2020, 15:12 #30
- Join Date
- Aug 2014
- Posts
- 77
I was using the magnifying glass because that seemed to be a search function...
A best practice question, I will have multiple steps (e.g. step3, step4, etc.) with different dice combinations; what is the best way to handle that in Lua? (I read that Lua doesn't have switch statements.)
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks