EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Plugins & Mods (https://www.eqemulator.org/forums/forumdisplay.php?f=678)
-   -   Slight modification to plugin::PWAutoCenter (https://www.eqemulator.org/forums/showthread.php?t=37301)

HnathBST 09-17-2013 05:38 AM

Slight modification to plugin::PWAutoCenter
 
I modified PWAutoCenter to not count html & bbcode tags when centering

Code:

sub PWAutoCenter{
        $Cent = $_[0];
        $len = $_[0];
        $len =~ s!<(?:[^>]+)>([^<]+)</(?:[^>]+)>!$1!gi;
        $len =~ s!\[(?:[\]]+)\]([^\[]+)\[/(?:[\]]+)\]!$1!gi;
        $SendCharLength = $_[1];
        if($SendCharLength != 2){
                $CentLength = length($len);
                $IC = (53 - ($CentLength * .80) - 4);
        }
        else{
                $IC = $Cent;
        }
        my $n = 0;
        my $Result = "";
        while ($n < $IC){
                $Result .= "&nbsp;";
                $n++;
        }
        if(!$SendCharLength){
                return "$Result $Cent";
                my $CentLength = 0;
        }
                elsif($SendCharLength == 2){
                        return "$Result";
                }
                        else{
                                return "There are $IC characters in this phrase, use this arguement for Option 2 in Arguement 2";
                        }
        my $SendCharLenghth = undef;
        my $CentLenght = undef;
}

if you don't need the BBCode [..]..[/..] remove the third $len. This will center links.

hope this helps someone :)


All times are GMT -4. The time now is 10:08 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.