EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Plugins & Mods (https://www.eqemulator.org/forums/forumdisplay.php?f=678)
-   -   BBCode like text parsing (https://www.eqemulator.org/forums/showthread.php?t=37300)

HnathBST 09-17-2013 05:11 AM

BBCode like text parsing
 
I created a little plugin that will parse SOME bbcodes (at the moment I've only been focusing on the popup window, chat will come next.)

text_parse.pl
Code:

sub ParseText
{
        my $text = $_[0];
        $text =~ s!\[color=([0-9a-z]+)\]([^\[\]]+)\[/color]!plugin::PWColor("$1")."$2</c>"!gie;
        $text =~ s!\[color=(#[0-9a-z]{6})\]([^\[\]]+)\[/color\]!<c \"$1\" >$2</c>!gi;
        $text =~ s!\[link=([\w|:|/|\.|\?|#|-]+)\]([^\[\]]+)\[/link\]!<a href=\"$1\">$2</a>!gi;
        $text =~ s!\[br\]!<br />!gi;
        $text =~ s!\[hr\]!plugin::PWBreak()!gie;
        $text =~ s!^\[center\]([^\[\]]+)\[/center\]!plugin::PWAutoCenter($1)."<br />";!gie;
        $text =~ s!\[center\]([^\[\]]+)\[/center\]!plugin::PWAutoCenter($1)."<br />";!gie;
       
        return $text;
}

to use in a quest:
Code:

sub EVENT_SAY
{
    if($text =~ /hail/i){
    my $popup = "[*center]Look ma, I'm centering...[/center] and then the sky went [*color=Red]red[/color] [br] you can see [*color=#FF0066]more[/color] [link=http://google.com]here[/link] [hr]";
    quest::popup("Text Parse Test:",plugin::ParseText($popup));
    }
}

take the * out of the color= box and center ( otherwise it changes the color on the forums >.< )
This would result in:
http://prntscr.com/1rsrpx

Currently supported bbcodes are link,center,color (by name & hex),br & hr

you can change colors inside a center but you can't color a center...

Akkadius 04-18-2014 09:03 PM

This is interesting. You came out with this just a little after I created:

http://wiki.eqemulator.org/p?The_Dia...ster_Reference

Do you want this added?


All times are GMT -4. The time now is 09:51 PM.

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