[BETA] Dice BBCode Version 0.2.4

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
CancelloCornorosso
Registered User
Posts: 19
Joined: Fri Aug 18, 2006 7:40 pm

Post by CancelloCornorosso »

Hi again craigpierce,

Very nice! The SORT_NUMERIC part and the d100 fix work for me. Let me see if I got the exploded thing right:does 2d6E roll a new d6 only if both the original results are 6 or a new d6 for each 6 originally obtained?
ruelk
Registered User
Posts: 13
Joined: Thu Dec 22, 2005 4:24 am

Re: [BETA] Dice BBCode Version 0.2.4

Post by ruelk »

CancelloCornorosso wrote: Hi again craigpierce,

Very nice! The SORT_NUMERIC part and the d100 fix work for me. Let me see if I got the exploded thing right:does 2d6E roll a new d6 only if both the original results are 6 or a new d6 for each 6 originally obtained?

Typically it is an either or thing. So if 1d6 reaches max it explodes. However, such as E-RPG requires both die in a multiple die roll to max. For instance, a d12+d4 would not get re-rolls if the 4 rolls a 4. Both the 12 and the 4 have to reach max to re-roll. Also, some exploding dice rules limit the number of re-rolls, such as E-RPG.

I think, to put in the number of different options available you would have to have multiple codes, which would suck the end user (post) to have to remember them all, or remember to type in a whole string for a die roll they use for only one system. For instance, it would suck for someone using this in a system with limited exploding die to have to type a tag the looks like "explodingdiecap=3" instead of simply typing "dice".

If it is developed it would have to be customized per board with really easy to instal instructions for people like me, or a control panel for customizing how it works.
ruelk
Registered User
Posts: 13
Joined: Thu Dec 22, 2005 4:24 am

Re: [BETA] Dice BBCode Version 0.2.4

Post by ruelk »

Is there a feature, or could there be, to add text effects (such as colors) to the text output of the results?
User avatar
Alathan
Registered User
Posts: 2
Joined: Thu Jul 12, 2007 5:26 pm
Location: Orange County, CA, USA
Contact:

Re:

Post by Alathan »

CancelloCornorosso wrote:Hi again craigpierce,

Very nice! The SORT_NUMERIC part and the d100 fix work for me. Let me see if I got the exploded thing right:does 2d6E roll a new d6 only if both the original results are 6 or a new d6 for each 6 originally obtained?
The way craigpierce presented his example, each die rolled explodes separately:
craigpierce wrote:...and takes 'exploding' into account like this:

5d6E

6-Sided Dice Results: 10, 8, 5, 1, 1 (Total = 25)
In other words, the original die results would have been (6, 6, 5, 1, 1); the first two dice explode, and their rerolls are (4, 2), which are added to the original die rolls, for the final result given above.
User avatar
Lord_Dekhan
Registered User
Posts: 31
Joined: Fri Jul 13, 2007 6:58 pm
Location: Brazil
Contact:

Re: [BETA] Dice BBCode Version 0.2.4

Post by Lord_Dekhan »

lol

I needed to read all the topic to make it work properly on my forum

i have a forum in 2.0.22, and it's all working: title, explode, etc.

I have 3 sugestions to do here, I dunno if it's possible 'cause i even know php lol:

1 - The Explode feature is Excelent to the Storyteller system, where each 10 rolls another dice, and to the d20 system to make critical confirmation on the saves, but, what about make something to the critical failure (in both d20 or d10, when u takes 1 on the dices is a critical failure with it's own consequences, I know at least 3 more rpg's system that use the same feature)

2 - This is necessarie to implement the last item: When the dices explodes, show the new roll, and not just add to the dice that take the max result, in that way, can show when it's a failure, and the new roll of the failure (for d20 system case)

3 - I dunno if i just do not have the luck to see it (if implemented allready or not), but, on the tests that I did, when the dices explodes, there's just one more roll for each dice, none rolling that i did make it explode twice (example: 1d10 = 23 (10 on first roll, 10 on second roll and 3 on the third roll), is this working? how can i make it roll more? or I just haven't enought luck to see it? lol

I think that's all =D

See ya

I love this mod, I use it for years ago, but, only now I'm looking for improvements.

Anyway, srry for some fail on the English... I'm Brazilian =D...

And... just to Finish: Nice to meet u all =D
Image
Meine Engel

I lov u soooo much... we'll gonna marry \o/ \o/

Para quem curte RPG e é brasileiro ae galera: http://www.wsrpg.com.br

Advanced Dungeons & Rabbits Brazil - Oficial Support Forum
User avatar
isigillum
Registered User
Posts: 1
Joined: Mon Aug 20, 2007 3:41 am
Location: Illinois
Contact:

PHPBB3 ?

Post by isigillum »

Has anyone tried this with PHPBB version 3 yet? I thought I might try it since RC4 is out now ... I'll let you all know how it came out in a few days or so. If anyone has some insights let me know please. thanks. :geek:

iSigillum
God doesn't play dice with the universe ... man does.
anodyzed
Registered User
Posts: 15
Joined: Sun May 14, 2006 10:46 pm
Location: Washington State
Contact:

Re: [BETA] Dice BBCode Version 0.2.4

Post by anodyzed »

Programming is painful for me, so my tale of woe is my way of asking for assistance:

I probably installed phpBB because the Dice Mod was available and working. That was over a year ago, version .21. Someone else installed it for me, he did the phpBB, EasyMod, MultiBBcode, and Dice mod. Has worked for a year flawlessly.

Then spammers discovered my board (http://www.whidbeygamers.net) and I was forced to install the .21 to .22 upgrade, which took me HOURS. Then, before I noticed if there was a problem, I put on the RAC mod, which forces new signups to have an Authorization Code to be able to sign up.

I used EasyMod to install that and shouldn't have. It didn't work, AND, no one could sign up, even if they DID have the right code. So I went in manually and updated the files for RAC and uploaded them. That part now works, BUT

My dice code no longer is correct. The DICE tag in the message header is gone
AND
if you just type the dice tag ([dice] and [/dice]), it will roll a correct result but the display is not quite right.

If I post this:
[dice]d100[/dice]

I get this:

:
: d100
100-Sided Dice Results: 80+9(89)

And it even went back and changed the appearance of ALL rolls almost a year ago to that : thing!

So he's my problem: DO you think it was the .21 to .22 upgrade? The RAC installation? Where would I even begin to start trying to fix this?

John
john.hellmann@gmail.com
i101
Registered User
Posts: 23
Joined: Thu Sep 27, 2007 9:21 pm

Re:

Post by i101 »

CtrlFrk wrote:I needed this mod for a site running phpBB 2.0.21 and the Multiple BBCode MOD version 1.4.0c, so I made the following changes that appear to work:

Code: Select all

################################################################# 
## MOD Title: Dice BBCode 
## MOD Author: Zachary Aerogos < tribalgenesis@hotmail.com > - Zachary Aerogos - http://www.tribalgenesis.no-ip.org
## MOD Original Author: Hades < phpbb@hades.me.uk > - Lee Conlin - http://www.celestialvault.com/blast 
## MOD Description: Adds a Dice Roller BBCode for your Forum - THIS MOD REQUIRES THE MULTI-BBCODE MOD!!!
## MOD Version: 1.2.4 
## 
## Installation Level: Intermediate 
## Installation Time: 10 Minutes 
## Files To Edit: 
## bbcode.php
## posting.ph
## templates/*.*bbcode.tpl
## templates/*.*/posting_body.tpl
## language/*.*/lang_main.php
## language/*.*/lang_bbcode.php 
##
## Included Files: n/a 
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/ 
############################################################## 
## 
## Author Notes: 
## 
##  BASED ON THE DICE MOD BY Jeff Leigh 
## 
##  IMPORTANT: if you are installing manually (without EasyMod) you MUST first 
##        install the Multi BBCode MOD available at http://www.phpbb.com/mods/downloads 
## 
##  For serious use of this MOD, you MUST disable non-moderator editing of posts.. otherwise, users 
##  can simply edit their posts a few times until they get a good roll.  Also, if a post is edited (by a 
##  moderator or user) the word 'Fixed' will appear in the dice roll.  This prevents users from 'fixing' 
##  their results by passing in a result seed they know brings good results... but is nessassary to 
##  allow a post to be edited without changing the results.  I am not quite happy with this, but 
##  it does the job. 
## 
##  The obvious way to avoid the above issues is to use the Post_ID to seed the results.  This, 
##  however, appeared to require changes to phpbb function declarations - a thing I try very 
##  hard to avoid (as it can cause problems for other MODs not expecting these changes). 
##
##  !UPDATED!
##
##  This MOD has been bropught to par with the current phpBB specs. and Multi BBCode MOD. 
############################################################## 
## MOD History: 
## 
##   2004-12-25 - Version 1.2.4 - Zachary took over development.
##      - Updated for phpBB 2.0.7, 2.0.8, 2.0.9, 2.0.10, & 2.0.11
##      - Fixed Install Script & Updated To Meet Multi BBCode 1.4.1 Requirements
##      - Removed Images Which Were Not Supplied With Original Script From FAQ
##
##   2003-09-16 - Version 1.2.3 
##      - Updated for phpBB 2.0.6 
## 
##   2003-08-04 - Version 1.2.2 
##      - Updated to reflect changes in MOD Template.  Dates missing on other version entries due to the fact I can't remember them. 
##      - Updated code for phpBB 2.0.5 
## 
##       1.2.1 - Set limits of number of dice and number of sides to prevent silly people from rolling 
##                    dice that would cause fatal errors for reaching max execution time.  Neat error message displayed 
##                    instead. - Idea by Wooly Spud 
## 
##       1.2.0 - Hades took over development. 
##             - Re-wrote seed generation to give multiple die rolls in the same post different seeds for added randomness. 
##                    This fixed the bug where mutiple occurances of the same roll string within 
##                    a post would all generate identicle results. 
##             - Removed all dice images.  Smaller versions may be added in a later version, but for now they are not needed. 
##             - Brought this MOD in line with Nutzzy's Multi-BBCode MOD. 
##                    This also eliminates the conflict with the multi-BBCode MOD.  =) 
## 
##       1.1.2 - Jeff Leigh's last release. 
## 
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 

# 
#-----[ OPEN ]------------------------------------------ 
# 
   includes/bbcode.php 

# 
#-----[ FIND ]--------------------------------- 
# 
$EMBB_widths = array('') ;
$EMBB_values = array('') ;

# 
#-----[ IN-LINE FIND ]--------------------------------- 
# 
$EMBB_widths = array('' 

# 
#-----[ IN-LINE AFTER, ADD ]--------------------------------- 
# 
,'40' 


# 
#-----[ IN-LINE FIND ]--------------------------------- 
# 
$EMBB_values = array('' 


# 
#-----[ IN-LINE AFTER, ADD ]--------------------------------- 
# 
,'Dice' 

# 
#-----[ FIND ]------------------------------------------ 
# 

$bbcode_tpl['email'] = str_replace('{EMAIL}', '\\1', $bbcode_tpl['email']); 

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 

   // -------------------------------- 
   // DICE MOD CODE 
   // -------------------------------- 
    
   $bbcode_tpl['dice_open2'] = str_replace('{ROLLED}', $lang['Dice_Mod_Rolled'] . " - \\1", $bbcode_tpl['dice_open']); 
   $bbcode_tpl['dice_open'] = str_replace('{ROLLED}', $lang['Dice_Mod_Rolled'], $bbcode_tpl['dice_open']); 
    
   // -------------------------------- 
   // END DICE MOD CODE 
   // -------------------------------- 

# 
#-----[ FIND ]------------------------------------------ 
# 

	// [email]user@domain.tld[/email] code..
	$patterns[] = "#\[email\]([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si";
	$replacements[] = $bbcode_tpl['email'];

	$text = preg_replace($patterns, $replacements, $text);

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 

   // -------------------------------- 
   // BEGIN DICE MOD CODE 
   // -------------------------------- 
    
   // [dice] tags for rolling dice 
   $text = bbencode_second_pass_pda($text, "/\[dice:$uid\]/is", "[/dice:$uid]", 'replace_dice_results', $bbcode_tpl['dice_open'], $bbcode_tpl['dice_close'] ); 
   $text = preg_replace("/\[dice:$uid=(?:\"?([^\"]*)\"?)\]/si",  $bbcode_tpl['dice_open2'] . "[dice:$uid=\"\\1\"]", $text); 
   $text = bbencode_second_pass_pda($text, "/\[dice:$uid=(\\\".*\\\")\]/is", "[/dice:$uid]", 'replace_dice_results', '', $bbcode_tpl['dice_close']); 
    
   // -------------------------------- 
   // END DICE MOD CODE 
   // -------------------------------- 

# 
#-----[ FIND ]------------------------------------------ 
# 
function bbencode_first_pass($text, $uid) 
{ 

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 

// -------------------------------- 
// BEGIN DICE MOD CODE 
// -------------------------------- 

function replace_dice_results($text, $uid) 
{ 
   global $lang; 
   // Take the desired Die string ($text) and generate values for each roll. 

   $Expressions = explode('=', $text); 
   if( (isset($Expressions[0])) && (isset($Expressions[1])) ) 
   { 
      $Dice_Rolls = $Expressions[0]; 
      $MT_Seed = intval($Expressions[1]);//(double)microtime()*1000000; doesn't work as it causes the rolls to be re-rolled every time the topic/post is re-loaded// 
      $Fixed = $Expressions[2]; 
   } 
   else 
   { 
      return; 
   } 

   // Make sure we restore the MT gen to a random state after we are done... 
   $Future_Seed = mt_rand(); 
   mt_srand( $MT_Seed ); 

   $Original_Roll_String = (isset($Fixed)) ? $Dice_Rolls . ' <b><span style="color: #AA0000">' . $lang['Dice_Mod_Fixed'] . '</span></b>': $Dice_Rolls; 
   $Die_Rolls = explode(' ', trim($Dice_Rolls)); 

   while( $Die = array_shift($Die_Rolls)) 
   { 
      $footer = ''; 
      $header = ''; 
      $Die_Count = substr($Die,0,strpos($Die,'d')); 
      $Die_Type = substr($Die,strpos($Die,'d')+1); 
      if( strpos($Die_Type, '+') ) 
      { 
         $Method = 1; 
         $Modifier = substr($Die_Type,strpos($Die_Type,'+')+1); 
         $Die_Type = substr($Die_Type,0,strpos($Die_Type,'+')); 
      } 
      else if( strpos($Die_Type, '-') ) 
      { 
         $Method = 2; 
         $Modifier = substr($Die_Type,strpos($Die_Type,'-')+1); 
         $Die_Type = substr($Die_Type,0,strpos($Die_Type,'-')); 
      } 
      else if( strpos($Die_Type, '*') ) 
      { 
         $Method = 3; 
         $Modifier = substr($Die_Type,strpos($Die_Type,'*')+1); 
         $Die_Type = substr($Die_Type,0,strpos($Die_Type,'*')); 
      } 
      else if( strpos($Die_Type, 'x') ) 
      { 
         $Method = 3; 
         $Modifier = substr($Die_Type,strpos($Die_Type,'x')+1); 
         $Die_Type = substr($Die_Type,0,strpos($Die_Type,'x')); 
      } 
      else if( strpos($Die_Type, '/') ) 
      { 
         $Method = 4; 
         $Modifier = substr($Die_Type,strpos($Die_Type,'/')+1); 
         $Die_Type = substr($Die_Type,0,strpos($Die_Type,'/')); 
      } 
      else 
      { 
         $Method = 0; 
         $Modifier = 0; 
      } 
      $header = '<b>' . $lang['Dice_Mod_Roll_String'] . '</b>: ' . $Original_Roll_String . '<br /><b>' . $Die_Type . '-Sided Dice Results: </b>'; 
      $footer = ''; 
      $Die_Count = intval($Die_Count); 
      if( $Die_Count == 0 ) $Die_Count = 1; 
      $total = 0; 

      if( $Method ) 
      { 
         $footer = $footer . "("; 
      } 

      // Loop Limit to prevent 500000d500000 sort of dice due to max. execution time limit 
      if($Die_Count <= 200 && $Die_Type <= 100) 
      { 
         for( $i = 0; $i < $Die_Count; $i++ ) 
         { 
            if( $Die_Type == 100 ) 
            { 
               $value1 = (integer)(((double)mt_rand()/(double)mt_getrandmax()) * 10) * 10; 
               $value2 = (integer)(((double)mt_rand()/(double)mt_getrandmax()) * 10); 
               $total = $total + ($value1 + $value2); 
               $footer = ($i != $Die_Count - 1) ? $footer . $value1 . '+' . $value2 . '(' .($value1 + $value2) . '<b></b>), ' : $footer .  $value1 . '+' . $value2 . '(' . ($value1 + $value2) . '<b></b>)'; 
            } 
            else 
            { 
               $value = (integer)(((double)mt_rand()/(double)mt_getrandmax()) * $Die_Type) + 1; 
               $total = $total + $value; 
               $footer = ($i != $Die_Count - 1) ? $footer . $value . ', ' : $footer . $value . ''; 
            } 
         } 
      } // Loop limit 
      else 
      { 
         $total = 0; 
         $Modifier = 0; 
         $footer = 'Too many dice and/or too many sides'; 
      } 

      switch( $Method ) 
      { 
      case 1: 
         $footer =  $footer . '<b></b>) + ' . $Modifier . ' '; 
         $total = $total + $Modifier; 
         break; 
      case 2: 
         $footer =  $footer . '<b></b>) - ' . $Modifier . ' '; 
         $total = $total - $Modifier; 
         break; 
      case 3: 
         $footer =  $footer . '<b></b>) * ' . $Modifier . ' '; 
         $total = $total * $Modifier; 
         break; 
      case 4: 
         $footer =  $footer . '<b></b>) / ' . $Modifier . ' '; 
         $total = $total / $Modifier; 
         break; 
      } 
      // I do b - /b on purpose...  kills out some smilies that crop up. 
      if( ($Die_Count > 1) || ($Method != 0) ) 
      { 
         $footer=  $footer . ' (<b>Total =</b> ' . $total . '<b></b>)<BR>'; 
      } 
      else 
      { 
         $footer =  $footer . '<BR>'; 
      } 
      $footer = $footer. ""; 
      $results = $results . $header . $footer; 
   } 
   // Restore MT randomness 
   mt_srand($Future_Seed); 

   return $results; 
} 

// -------------------------------- 
// END DICE MOD CODE 
// -------------------------------- 

# 
#-----[ FIND ]------------------------------------------ 
# 

// [img]image_url_here[/img] code..
$text = preg_replace("#\[img\]((http|ftp|https|ftps)://)([^ \?&=\#\"\n\r\t<]*?(\.(jpg|jpeg|gif|png)))\[/img\]#sie", "'[img:$uid]\\1' . str_replace(' ', '%20', '\\3') . '[/img:$uid]'", $text);

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 

   // -------------------------------- 
   // BEGIN DICE MOD CODE 
   // -------------------------------- 
    
   $occurances = preg_match_all("#\[dice=?.*\]([-\s\w+/*]*?)\[/dice\]#i", $text, $temp); 
   //list($usec,$sec)=explode(" ",microtime()); 
   mt_srand((double)microtime()*1000000);//$sec * $usec); 

   // Loop to fix randomness problem of results when multiple die rolls are made in a single post - Hades 
   for($i=0;$i<=$occurances;$i++) 
   { 
      $dice_seed = mt_rand(); 
      $text = preg_replace("#\[dice\]([-\s\w+/*]*?)\[/dice\]#i", "[dice:$uid]\\1 = $dice_seed [/dice:$uid] $limit", $text, 1); 
      $dice_seed = mt_rand(); 
      $text = preg_replace("#\[dice=\\\\"(.*?)\\\\"\]([-\s\w+/*]*?)\[/dice\]#i", "[dice:$uid=\\\"\\1\\\"]\\2 = $dice_seed [/dice:$uid] $limit", $text, 1); 
   } 
   $text = preg_replace("#\[dice\]([-\s\w+/*]*?)=([\s\d]*?)\[/dice\]#i", "[dice:$uid]\\1 = \\2 = Fixed[/dice:$uid]", $text); 
   $text = preg_replace("#\[dice\]([-\s\w+/*]*?)=([\s\d]*?)=\s*?Fixed\s*?\[/dice\]#i", "[dice:$uid]\\1 = \\2 = Fixed[/dice:$uid]", $text); 
   $text = preg_replace("#\[dice=\\\\"(.*?)\\\\"\]([-\s\w+/*]*?)=([\s\d]*?)\[/dice\]#i", "[dice:$uid=\\\"\\1\\\"]\\2 = \\3 = Fixed[/dice:$uid]", $text); 
   $text = preg_replace("#\[dice=\\\\"(.*?)\\\\"\]([-\s\w+/*]*?)=([\s\d]*?)=\s*?Fixed\s*?\[/dice\]#i", "[dice:$uid=\\\"\\1\\\"]\\2 = \\3 = Fixed[/dice:$uid]", $text);
   // -------------------------------- 
   // END DICE MOD CODE 
   // -------------------------------- 

# 
#-----[ FIND ]------------------------------------------ 
# 

	return $text;

} // bbencode_first_pass_pda()

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 

// -------------------------------- 
// BEGIN DICE MOD CODE 
// -------------------------------- 
function bbencode_second_pass_pda($text, $open_tag, $close_tag,$func,$open_template, $close_template) 
{ 
   $open_tag_count = 0; 

   $close_tag_length = strlen($close_tag); 

   $use_function_pointer = ($func && ($func != '')); 

   $stack = array(); 
   if (is_array($open_tag)) 
   { 
      if (0 == count($open_tag)) 
      { 
         // No opening tags to match, so return. 
         return $text; 
      } 
      $open_tag_count = count($open_tag); 
   } 
   else 
   { 
      // only one opening tag. make it into a 1-element array. 
      $open_tag_temp = $open_tag; 
      $open_tag = array(); 
      $open_tag[0] = $open_tag_temp; 
      $open_tag_count = 1; 
   } 
    
   $open_is_regexp = true; 
    
   // Start at the 2nd char of the string, looking for opening tags. 
   $curr_pos = 1; 
   while ($curr_pos && ($curr_pos < strlen($text))) 
   { 
      $curr_pos = strpos($text, "[", $curr_pos); 

      // If not found, $curr_pos will be 0, and the loop will end. 
      if ($curr_pos) 
      { 
         // We found a [. It starts at $curr_pos. 
         // check if it's a starting or ending tag. 
         $found_start = false; 
         $which_start_tag = ""; 
         $start_tag_index = -1; 
         for ($i = 0; $i < $open_tag_count; $i++) 
         { 
            // Grab everything until the first "]"... 
            $possible_start = substr($text, $curr_pos, strpos($text, "]", $curr_pos + 1) - $curr_pos + 1); 

            // 
            // We're going to try and catch usernames with "[' characters. 
            // 
            if( preg_match('/\[quote\=\\\\"/si', $possible_start) && !preg_match('/\[quote=\\\\"[^"]*\\\\"\]/si', $possible_start) ) 
            { 
               // 
               // OK we are in a quote tag that probably contains a ] bracket. 
               // Grab a bit more of the string to hopefully get all of it.. 
               // 
               $possible_start = substr($text, $curr_pos, strpos($text, "\"]", $curr_pos + 1) - $curr_pos + 2); 
            } 
            // 
            // Now compare, either using regexp or not. 
             
            $match_result = array(); 
            // PREG regexp comparison. 
            if (preg_match($open_tag[$i], $possible_start, $match_result)) 
            { 
               $found_start = true; 
               $which_start_tag = $match_result[0]; 
               $start_tag_index = $i; 
               break; 
            } 
         } 

         if ($found_start) 
         { 
            // We have an opening tag. 
            // Push its position, the text we matched, and its index in the open_tag array on to the stack, and then keep going to the right. 
            $match = array("pos" => $curr_pos, "tag" => $which_start_tag, "index" => $start_tag_index); 
            bbcode_array_push($stack, $match); 
            ++$curr_pos; 
         } 
         else 
         { 
            // check for a closing tag.. 
            $possible_end = substr($text, $curr_pos, $close_tag_length); 
            if (0 == strcasecmp($close_tag, $possible_end)) 
            { 
               // We have an ending tag. 
               // Check if we've already found a matching starting tag. 
               if (sizeof($stack) > 0) 
               { 
                  // There exists a starting tag. 
                  $curr_nesting_depth = sizeof($stack); 
                  // We need to do 2 replacements now. 
                  $match = bbcode_array_pop($stack); 
                  $start_index = $match['pos']; 
                  $start_tag = $match['tag']; 
                  $start_length = strlen($start_tag); 
                  $start_tag_index = $match['index']; 

                  // everything before the opening tag. 
                  $before_start_tag = substr($text, 0, $start_index); 

                  // everything after the opening tag, but before the closing tag. 
                  $between_tags = substr($text, $start_index + $start_length, $curr_pos - $start_index - $start_length); 

                  // Run the given function on the text between the tags.. 
                  if ($use_function_pointer) 
                  { 
                     $between_tags = $func($between_tags, $uid); 
                  } 

                  // everything after the closing tag. 
                  $after_end_tag = substr($text, $curr_pos + $close_tag_length); 

                  // Mark the lowest nesting level if needed. 
                  $text = $before_start_tag . $open_template . $between_tags . $close_template . $after_end_tag; 

                  // Now.. we've screwed up the indices by changing the length of the string. 
                  // So, if there's anything in the stack, we want to resume searching just after it. 
                  // otherwise, we go back to the start. 
                  if (sizeof($stack) > 0) 
                  { 
                     $match = bbcode_array_pop($stack); 
                     $curr_pos = $match['pos']; 
                     bbcode_array_push($stack, $match); 
                     ++$curr_pos; 
                  } 
                  else 
                  { 
                     $curr_pos = 1; 
                  } 
               } 
               else 
               { 
                  // No matching start tag found. Increment pos, keep going. 
                  ++$curr_pos; 
               } 
            } 
            else 
            { 
               // No starting tag or ending tag.. Increment pos, keep looping., 
               ++$curr_pos; 
            } 
         } 
      } 
   } // while 

   return $text; 

} // bbencode_second_pass_pda() 
// -------------------------------- 
// END DICE MOD CODE 
// -------------------------------- 

# 
#-----[ OPEN ]------------------------------------------ 
# 
posting.php 

# 
#-----[ FIND ]--------------------------------- 
# 
# NOTE: the full line to look for is: 
#   'L_BBCODE_F_HELP' => $lang['bbcode_f_help'], 
# 
   'L_BBCODE_F_HELP' => 


# 
#-----[ AFTER, ADD ]-------------------------------- 
# 

   'L_BBCODE_D_HELP' => $lang['bbcode_help'][Dice], 

# 
#-----[ OPEN ]------------------------------------------ 
# 
templates/subSilver/bbcode.tpl 

# 
#-----[ FIND ]------------------------------------------ 
# 

<!-- BEGIN email --><a href="mailto:{EMAIL}">{EMAIL}</a><!-- END email --> 

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 

<!-- BEGIN dice_open --> 
<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center"> 
<tr> 
     <td><span class="genmed"><b>{ROLLED}:</b></span></td> 
   </tr> 
   <tr> 
     <td class="quote"><!-- END dice_open --> 

<!-- BEGIN dice_close --></td> 
   </tr> 
</table> 
<span class="postbody"><!-- END dice_close --> 

# 
#-----[ OPEN ]------------------------------------------ 
# 
templates/ca_aphrodite/bbcode.tpl 

# 
#-----[ FIND ]------------------------------------------ 
# 

<!-- BEGIN email --><a href="mailto:{EMAIL}">{EMAIL}</a><!-- END email --> 

# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 

<!-- BEGIN dice_open --> 
<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center"> 
<tr> 
     <td><span class="genmed"><b>{ROLLED}:</b></span></td> 
   </tr> 
   <tr> 
     <td class="quote"><!-- END dice_open --> 

<!-- BEGIN dice_close --></td> 
   </tr> 
</table> 
<span class="postbody"><!-- END dice_close --> 

# 
#-----[ OPEN ]------------------------------------------ 
# 
templates/subSilver/posting_body.tpl 

# 
#-----[ FIND ]--------------------------------- 
# 
# NOTE: the full line to look for is: 
#f_help = "{L_BBCODE_F_HELP}"; 
# 
f_help = 


# 
#-----[ AFTER, ADD ]--------------------------------- 
# 

d_help = "{L_BBCODE_D_HELP}"; 

# 
#-----[ FIND ]--------------------------------- 
# 
# NOTE: the actual line to find is MUCH longer, containing all the bbcode tags 
# 
bbtags = new Array( 


# 
#-----[ IN-LINE FIND ]--------------------------------- 
# 
'[url]','[/url]' 


# 
#-----[ IN-LINE AFTER, ADD ]--------------------------------- 
# 
,'[dice]','[/dice]' 

# 
#-----[ OPEN ]------------------------------------------ 
# 
templates/ca_aphrodite/posting_body.tpl 

# 
#-----[ FIND ]--------------------------------- 
# 
# NOTE: the full line to look for is: 
#f_help = "{L_BBCODE_F_HELP}"; 
# 
f_help = 


# 
#-----[ AFTER, ADD ]--------------------------------- 
# 

d_help = "{L_BBCODE_D_HELP}"; 

# 
#-----[ FIND ]--------------------------------- 
# 
# NOTE: the actual line to find is MUCH longer, containing all the bbcode tags 
# 
bbtags = new Array( 


# 
#-----[ IN-LINE FIND ]--------------------------------- 
# 
'[url]','[/url]' 


# 
#-----[ IN-LINE AFTER, ADD ]--------------------------------- 
# 
,'[dice]','[/dice]' 

# 
#-----[ OPEN ]------------------------------------------ 
# 
language/lang_english/lang_main.php 

# 
#-----[ FIND ]------------------------------------------ 
# 

//
// That's all, Folks!
// -------------------------------------------------

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 

// -------------------------------- 
// BEGIN DICE MOD CODE 
// -------------------------------- 
$lang['Dice_Mod_Rolled'] ='Dice Roll'; 
$lang['Dice_Mod_Fixed'] ='Fixed'; 
$lang['Dice_Mod_Roll_String'] = 'Original Roll String'; 
$lang['bbcode_d_help'] = 'Roll Dice: [dice]dice string[/dice] (alt-d) Tip: Use the (#)d(Sides) convention.'; 
// -------------------------------- 
// END DICE MOD CODE 
// -------------------------------- 

# 
#-----[ OPEN ]------------------------------------------ 
# 
language/lang_english/lang_bbcode.php 

# 
#-----[ FIND ]------------------------------------------ 
# 

$faq[] = array("--", "Other matters");
$faq[] = array("Can I add my own tags?", "No, I am afraid not directly in phpBB 2.0. We are looking at offering customisable BBCode tags for the next major version.");

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 

// -------------------------------- 
// BEGIN DICE MOD CODE 
// -------------------------------- 
$faq[] = array("--", "Roleplaying Features"); 
$faq[] = array("Rolling dice in a post", "Posts and private messages can also include dice rolls.  Using the [dice]...[/dice] tags you can specify one or more rolls to be displayed in your message.<br><span style=\"font-weight: bold\">Dice Command Syntax:</span><ul><li>[dice](<span style=\"font-style: italic\">Dice Strings</span>)[/dice]<li>[dice=\"Roll Title\"](<span style=\"font-style: italic\">Dice Strings</span>)[/dice]</ul>The Dice String parameter can include mutliple dice strings in the standard throw syntax.<br /><br /><span style=\"font-weight: bold\">Throw Syntax:</span><ul><li>(<span style=\"font-style: italic\">Number of Dice</span>)d(<span style=\"font-style: italic\">Type of Dice</span>)<li>(<span style=\"font-style: italic\">Number of Dice</span>)d(<span style=\"font-style: italic\">Type of Dice</span>)(<span style=\"font-style: italic\">+,-,x,*,/</span>)(<span style=\"font-style: italic\">Modifier</span>)</ul>It may look complicated if you've never seen this sytem before, but it is actually quite easy to understand.<br /><br />Optionally, you can specify an operation and modifier for each throw, as shown above.  Supported operations are addition (+), subtraction (-), multiplication (* or x), and division (/).<br /><br /><span style=\"font-weight: bold\">Some Examples:</span><ul><li>d6 - Throw a single 6-sided die.<li>d20 - Throw a single 20-sided die.<li>2d20 - Throw two 6-sided dice.<li>d100 - Somewhat special, throws two 10 sided die, and multiplies one by 10.. resulting in a range of 100<li>d20+5 - Throw a 20-sided die and add 5 to the result.<li>4d20+10 - Throw four 20-sided dice and add 10 to the total.</ul>Hopefully you understand.<br /><br /><span style=\"font-weight: bold\">Output Examples:</span><br /><br />Here are a few instances of the 'Die' code in action, with the code above.   <br />Totals are provided for convience, but obviously are not relevent to all throws.<br /><br /><span style=\"font-weight: bold\">Code:</span> [dice]d20[/dice]<br /><table width=\"90%\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr>      <td><span class=\"genmed\"><b>Dice Roll:</b></span></td></tr><tr><td class=\"quote\"><b>Original Roll String:</b> <font color=\"#000088\">d20</font><BR><BR><b>20-Sided Dice Results: </b>6<BR><div align=\"center\"><center><table border=\"0\" width=\"80%\" bgcolor=\"#FFFFFF\" cellspacing=\"0\"><tr><td width=\"100%\"></td></tr></table></center></div></td></tr></table><span class=\"postbody\"><br /><span style=\"font-weight: bold\">Code:</span> [dice=\"Fire Save\"]2d20+10[/dice]<br /><table width=\"90%\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><span class=\"genmed\"><b>Dice Roll - Fire Save:</b></span></td></tr><tr><td class=\"quote\"><b>Original Roll String:</b> <font color=\"#000088\">2d20+10</font><BR><BR><b>20-Sided Dice Results: </b>(4, 1<b></b>) + 10  (<b>Total =</b> 15<b></b>)<BR><div align=\"center\"><center><table border=\"0\" width=\"80%\" bgcolor=\"#FFFFFF\" cellspacing=\"0\"><tr><td width=\"100%\"></td></tr></table></center></div></td></tr></table><span class=\"postbody\"><br /><span style=\"font-weight: bold\">Code:</span> [dice=\"Statistic Generation\"]4d4+10 3d6x2 2d100 4d4+10[/dice]<br /><table width=\"90%\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\" align=\"center\"><tr><td><span class=\"genmed\"><b>Dice Roll - Statistic Generation:</b></span></td></tr><tr><td class=\"quote\"><b>Original Roll String:</b> <font color=\"#000088\">d4+10 3d6x2 2d100 4d4+10</font><BR><BR><b>4-Sided Dice Results: </b>(2<b></b>) + 10  (<b>Total =</b> 12<b></b>)<BR><div align=\"center\"><center><table border=\"0\" width=\"80%\" bgcolor=\"#FFFFFF\" cellspacing=\"0\"><tr><td width=\"100%\"><img src=\"./images/dice/white/dice_4_sided_2.jpg\"></td></tr></table></center></div><b>6-Sided Dice Results: </b>(1, 4, 3<b></b>) * 2  (<b>Total =</b> 16<b></b>)<BR><div align=\"center\"><center><table border=\"0\" width=\"80%\" bgcolor=\"#FFFFFF\" cellspacing=\"0\"><tr><td width=\"100%\"></td></tr></table></center></div><b>100-Sided Dice Results: </b>60+1(61<b></b>), 30+1(31<b></b>) (<b>Total =</b> 92<b></b>)<BR><div align=\"center\"><center><table border=\"0\" width=\"80%\" bgcolor=\"#FFFFFF\" cellspacing=\"0\"><tr><td width=\"100%\"></td></tr></table></center></div><b>4-Sided Dice Results: </b>(1, 3, 4, 1<b></b>) + 10  (<b>Total =</b> 19<b></b>)<BR><div align=\"center\"><center><table border=\"0\" width=\"80%\" bgcolor=\"#FFFFFF\" cellspacing=\"0\"><tr><td width=\"100%\"></td></tr></table></center></div></td></tr></table><span class=\"postbody\"><br /><br />In case you are wondering, the numbers you see when you 'preview' will probably change when you go to post.<BR><BR><i>Dice Mod (version 1.1.0) by Jeff Leigh.</i>"); 
// -------------------------------- 
// END DICE MOD CODE 
// -------------------------------- 

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM
Somehow this doenst work for me. If I use your code instead of the original one EasyMod even doesnt find the mod. If I use the original one I get this crappy error message all the time:
Critical Error

FIND FAILED: In file [includes/bbcode.php] could not find:

// user@domain.tld code..
$patterns[] = "#\[email\]([a-z0-9\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si";
$replacements[] = $bbcode_tpl['email'];
$text = preg_replace($patterns, $replacements, $text);
My installed Mods are EasyMod Version 0.3.0 and Multiple BBCode Mod Version 1.4.0.c.

Any advices how to fix this problem?
i101
Registered User
Posts: 23
Joined: Thu Sep 27, 2007 9:21 pm

Re: [BETA] Dice BBCode Version 0.2.4

Post by i101 »

Come on guys ... Is there really nobody that can give me a helping hand on this problem?
:(
hoaxx
Registered User
Posts: 5
Joined: Thu Nov 22, 2007 7:17 am

Re: [BETA] Dice BBCode Version 0.2.4

Post by hoaxx »

The downloads on the first page do not seem to be working at all, does anyone have an alternative link?

I already downloaded the file from phpbbhacks.com referred on page 10 of this thread, but the version there does not seem to be the newest one, as I cannot find anything about the most interesting part (as for me):
1.0.0 Special ADMIN | MOD | GM Version
[...]
- Only ADMIN | MOD | GM may view the roll and GM RP accordingly
I intended to add this to the [mod][/mod] bbcode so my moderators could edit user postings and leave the original text there visible only to other moderators.

Does anyone know how to do that - make text in a bbcode visible only to mods/admins (and left out of a quote of course)?
Post Reply

Return to “[2.0.x] MODs in Development”