Joshua Stream Pre
Page 4 of 4 First ... 234
  1. #31
    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
    This example shows setting up a step3 and a step4. You would also need to still register the step4 command like you did the step3 command. Also, please note, that I have not tested this code, so it may not be perfect.

  2. #32

Thread Information

Users Browsing this Thread

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
DMsGuild

Log in

Log in