• Please note: In an effort to ensure that all of our users feel welcome on our forums, we’ve updated our forum rules. You can review the updated rules here: http://forums.wolflair.com/showthread.php?t=5528.

    If a fellow Community member is not following the forum rules, please report the post by clicking the Report button (the red yield sign on the left) located on every post. This will notify the moderators directly. If you have any questions about these new rules, please contact support@wolflair.com.

    - The Lone Wolf Development Team

Example - Die Rolling Procedure

TCArknight

Well-known member
Howdy!

So many games involve die rolls, I thought that I would share this procedure.

Code:
  <!-- Procedure DieRoll
        Determine the total of a dice roll.

        Outbound parameter: total
        Inbound parameter: NumOfDice  : for 3d6 would be 3, 1d20+2 would be 1, etc.
        Inbound parameter: SizeOfDice : for 3d6 would be 6, 1d20+2 would be 20, etc.
  -->
  <procedure id="DieRoll" scripttype="none"><![CDATA[
    ~declare variables that are used to communicate with our caller
    var NumOfDice as number
    var SizeOfDice as number
    var total as number

	var i as number
	
	total = 0
	
    for i = 0 to NumOfDice
	  total += random(SizeOfDice)
	  next
	
    ]]></procedure>
 
Back
Top