Thread: Extension Loading Issue
-
August 14th, 2020, 05:58 #31
- Join Date
- Jun 2020
- Posts
- 28
You could actually choose from several options. Which would be best would depend on what you need to do.
1) You could register different slash handlers for each command. (Useful IF the set-up for the rolls varies greatly.)
2) You could use if then elseif end statements to emulate a switch.
3) You could set up a table with the needed information for each type of command and use it to set up the roll so that all code is the same. This would probably be best if setup is similar across the different commands.
4) You could use a table to store functions that would be called based upon the command, but this is really not any different and probably worse than #1.
#3 could look like:
Code:rolls = {}; step3roll = {}; step3roll.aDice = { "d4" }; step3roll.nMod = 0; step3roll.sDesc = "[Step3]"; step3roll.nTarget = 2; rolls["step3"] = step3roll; step4roll = {}; step4roll.aDice = { "d4", "d6" }; step4roll.nMod = 0; step4roll.sDesc = "[Step4]"; step4roll.nTarget = 5; rolls["step4"] = step4roll; --Then what I wrote before would change to: function processStep3(sCommand, sParams) local rRoll = rolls[sCommand]; rRoll.sType = "step_action"; -- the type for the roll (Should match what is defined above! --Optional 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
-
August 14th, 2020, 10:06 #32
- Join Date
- Aug 2014
- Posts
- 77
Thanks!
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks