Requirements
All that is required to use the DRCSL is a normal PHP 5 installation. This installation needs to have cURL turned on to do the fetching. Also, the current version uses UNIXy paths so until that's changed Windows servers may not work.
TopInstallation
Installation of DRCSL is rather easy. Download the
latest release,
unzip it inside the folder you want your character viewer in (bearing
in mind that the zip doesnt' contain an internal folder) and do a simple
include() or require_once() of drcsl.php.
The result of unzipping will give you the class files (such as Character.php)
inside your working directory, the config/include file (drcsl.php),
as well as an example viewer (character_example.php) that you can edit
however you want. drcsl.php is the file to edit for any configuration
changes (in the future), and to include since it includes all required
classes.
Functions
System Functions
"Setter" Functions
"Getter" Functions
- get_char_attribute($attr)
- get_char_bonus($attr)
- get_char_defense()
- get_char_info($type)
- get_char_item($slot)
- get_char_resist($attr)
- get_char_skill($slot)
- get_char_weapon($hand)
"Cheat" Functions
- get_char_skills()
- get_char_items()
- get_char_bonuses()
- get_char_resistances()
Usage
Basic usage involves including drcsl.php, creating a new Character,
then displaying information from it. No cleanup is required.
<?php
include("drcsl.php");
$billy = new Character("Segfault");
echo $billy->get_char_info('Name');
?>
Examples
Basic usage example, as shown above.
Output:
<?php
include("drcsl.php");
$billy = new Character("Segfault");
echo $billy->get_char_info('Name');
?>
Printing the names of a character's items.
Output:
<?php
include("drcsl.php");
$billy = new Character("Segfault");
foreach($billy->get_char_items() as $item) {
echo "$item[Name]<br />";
}
?>
Warning: Invalid argument supplied for foreach() in /home/snarky/threeplanetssoftware.com/software/php_dr_library/documentation.php on line 215
MediaWiki Extension (MWE)
The MediaWiki extension grew out of a request from the maintainer
of TheTownstons to me to put
a character viewer into his wiki. At the time I didn't want to drop
all the code from my character sheet viewer
into an extension. After creating the DRCSL a few days ago, however,
I realized how easy it would be, and thus the MediaWiki Extension was
created.
At its core, the MWE is one php file that registers a parser hook. When
a user enters {{ #drcsl: charname }} on a page this hook
creates a Character object, and spits out some data. Since this is one
file, it is easy for a MediaWiki maintainer to edit the function to
their liking.
To install the MWE, download the latest release, and unzip it into your
mediawiki/extensions folder. It will create the CharacterSheetExtension
folder, with CharacterSheetExtension.php inside of it. Now, download the
latest version of DRCSL,
and put the class (Character.php, etc) files
and drcsl.php inside the CharacterSheetExtension folder. Finally, to
enable the MWE, open your LocalSettings.php, and add the line:
require_once("$IP/extensions/CharacterSheetExtension/CharacterSheetExtension.php");
anywhere inside the file.
To use the MWE, use the drcsl hook that was created.
{{ #drcsl: Segfault}}
The above hook will display stats for Segfault, replace his name with
any other to see their stats. Many characters can be included on the same
page, but this will increase page load time and, if you put enough characters on,
might make the Dungeon Runners' admins angry.