BeBot - An Anarchy Online and Age Of Conan chat automaton

Development => Coding and development discussion => Topic started by: Shelly on October 10, 2009, 08:15:53 pm

Title: creating a chatcmd that references another chatcmd - need help
Post by: Shelly on October 10, 2009, 08:15:53 pm
I am trying to create a module that will interface with the current Loot.php module.

I want to be able to supply a referenced item via a clickable link that then calls a chatcmd to add the item to the loot list.

I can do it so that the text is displayed, but can't seem to get a link setup so someone can see the details of the item. Neither of the $addlink methods below seen to work correctly.

Here is a snippit of my code:
Code: [Select]
        function show_loot($name, $boss)
        {
                if(!empty($boss))
                {
                        //List all loot for a given boss.
                        $query = "SELECT id, name, ref, img FROM #___Loot WHERE boss = '$boss'";
                        $loots = $this -> bot -> db -> select($query, MYSQL_ASSOC);
                        if(!empty($ploots))
                        {
                                $num = 0;

                                $window = "<header>##highlight##::::: BOSS Loot :::::##end##<end>\n\n\n";
                                $window .= "##highlight##$boss##end##\n\n";
                                foreach($loots as $ploot)
                                {
                                        $num++;
                                        $ref = $ploot[ref];
                                        $img = $ploot[img];
                                        $pname = $ploot[name];
                                        $addlink = $this -> bot -> core("tools") -> chatcmd("loot add [<a href=\'itemref://{$ref}/{$ref}/300\'></a>]", "Add to Loot List", 0);
                                        //$addlink = "<a href='chatcmd:///tell ".$this -> bot -> botname." <pre> loot add [<a href=\'itemref://{$ref}/{$ref}/300\'></a>] . '>' . "Add to Loot List" . '</a>";
                                        $window .= "<a href='itemref://{$ref}/{$ref}/300><img src=rdb://{$img}></a>\nItem: <highlight><a href='itemref://{$ref}/{$ref}/300'>$pname</a><end>\n".$addlink."\n";
                                        $window .= "\n";

                                }
                                return $this -> bot -> core("tools") -> make_blob("Availible BOSS loot for $boss", $window);
                        }
 
I am running the 0.6.5 BeBot and PHP 5.2.6
Title: Re: creating a chatcmd that references another chatcmd - need help
Post by: Shelly on October 12, 2009, 01:05:54 am
Update to the code:
Code: [Select]
                                $window = "<header>##highlight##::::: $command BOSS Loot :::::##end##<end>\n\n\n";
                                $window .= "##highlight##\t\t$boss##end##\n\n";
                                //echo "found pande loot";
                                foreach($rloots as $rloot)
                                {
                                        $num++;
                                        $addt = "Add above to Loot Roll";
                                        $ref = $rloot[ref];
                                        $img = $rloot[img];
                                        $pname = $rloot[name];
                                        $pref  = "<a href='itemref://{$ref}/{$ref}/300";

                //Works Text Mode ->    $addlink = $this -> bot -> core("tools") -> chatcmd("loot \"$pname\"", "Add to Loot List", 0);
                                        //$addlink = $this -> bot -> core("tools") -> chatcmd("loot \"$pname\"", "Add to Loot List", 0);
                //works sorta ->        $addlink = $this -> bot -> core("tools") -> chatcmd("loot <a href=\\\'itemref://{$ref}/{$ref}/300>", "$pname", 0);
                                        //$addlink = $this -> bot -> core("tools") -> chatcmd("loot <a href=itemref://{$ref}/{$ref}/300", "$pname", 0);
                //Informational ->      "<a href='itemref://257964/257964/1'>Visible Light Remodulation Device</a> "
                /* Active */            $addlink = "<a href='chatcmd:///tell ".$this -> bot -> botname." loot <a href=itemref://{$ref}/{$ref}/300>Add $pname to loot roll</a>'</a><br><br>";
/*Testing Code ->*/                     echo "$num = $addlink\n";

                //Works Text Mode ->    $window .= $this -> bot -> core("tools") -> chatcmd("loot <a href='itemref://{$ref}/{$ref}/300", "$pname", 0);
                //Basic Works ->        $window .= "<a href='itemref://{$ref}/{$ref}/300><img src=rdb://{$img}></a>\nItem: <highlight><a href='itemref://{$ref}/{$ref}/300'>$pname</a><end>\n".$addlink."\n";
                //Works Mode Text ->    $window .= "<a href='itemref://{$ref}/{$ref}/300><img src=rdb://{$img}></a>\nItem: <highlight><a href='itemref://{$ref}/{$ref}/300'>$pname</a><end>\n\t\tAdd ".$addlink."\n";
                /* Active */            $window .= "<a href='itemref://{$ref}/{$ref}/300><img src=rdb://{$img}></a><highlight><a href='itemref://{$ref}/{$ref}/300'>$pname</a><end>\n";
                /* Active */            $window .= $addlink;
                /* Active */            $window .= "\n\n";
/*Testing Code ->*/                     echo "$num = $window\n";

                                }
                //Works ->      return $this -> bot -> core("tools") -> make_blob("Availible $command loot for $boss", $window);
                //Informational -> return "<a href=\"text://" . $content . "\">" . $title . "</a>";
                /* Active */    return "<a href=\"text://" . $window . "\">Availible $command loot for $boss</a>";
Title: Re: creating a chatcmd that references another chatcmd - need help
Post by: Alreadythere on October 13, 2009, 01:37:41 pm
I haven't really checked your 2nd post, but if you want working item references and a link to add the item to loot you need to use two seperate links.

First create the item reference as always, and afterwards but completely seperated create the ADD link offering the chat command. I don't think the parser can seperate the links otherwise.

Something like (extremely shortened):
Code: [Select]
<a href='itemref:...'>Itemname</a> <a href='chatcmd=...'>[ADD]</a>
Title: Re: creating a chatcmd that references another chatcmd - need help
Post by: Shelly on October 21, 2009, 02:43:24 am
Thanks,

I did try to do that and really got a lot of mixed results... examples are in the 2nd code snippet.

I still have not figured out a way to do what I want to do... But I keep searching and testing.  :D
SimplePortal 2.3.7 © 2008-2024, SimplePortal