Difference between revisions of "How to write Ackis Modules in D"
From Makers Local 256
(→Retrieving Dependent Libraries: added example code) |
(→Development: added example code) |
||
Line 27: | Line 27: | ||
Here is an example piece of code: | Here is an example piece of code: | ||
− | // Hello World Module | + | // Hello World Module |
− | module mod_helloWorld; | + | module mod_helloWorld; |
− | + | ||
− | import libackis.ackiscomponent; | + | import libackis.ackiscomponent; |
− | import std.stdio; | + | import std.stdio; |
− | import std.regexp; | + | import std.regexp; |
− | import std.string; | + | import std.string; |
− | import std.random; | + | import std.random; |
− | import std.file; | + | import std.file; |
− | import kxml.xml; | + | import kxml.xml; |
− | import libdjson.json; | + | import libdjson.json; |
− | + | ||
− | char[]combdesc = "roll #D#, decide option 1( or option 2)*, trans lang1|lang2 text, track #, ddate"; | + | char[]combdesc = "roll #D#, decide option 1( or option 2)*, trans lang1|lang2 text, track #, ddate"; |
− | int main (char[][]argc) { | + | int main (char[][]argc) { |
− | + | AckisComponent ackis = new AckisComponent("mod_misc"); | |
− | + | ackis.register("^helloWorld.*",&helloWorld); | |
− | + | ackis.regHelp("helloWorld","Have bot say hi to you."); | |
− | + | ||
− | + | ackis.runProtocol(); | |
− | + | return 0; | |
− | } | + | } |
− | + | ||
− | void helloWorld() | + | void helloWorld() |
− | { | + | { |
− | + | ||
− | } | + | } |
Revision as of 12:12, 25 January 2010
Contents
[hide]Description
This page is meant as a how to guide for the beginner Ackis D Module Programmer. The intention is to write this from a beginner level. No claims are made that this is the only way to approach writing an ackis Module.
Setup
- Have a flavor of linux running
- Install build-essential, libmpfr-dev, and libgmp3-dev (required to build gdc)
- Install gdc 4.3.1 via the instructions on goshawk's gdc page.
- Install dsss (a D program requiring GDC to be built)
- Install svn
About each development component
- D is a programming language very similar to C++.
- For example code see Ackis2.0#D_Implementation_by_Opticron
- GDC is a front end D interface for GCC. This will translate the D syntax into something the GCC compiler can understand.
- DSSS is a simple way to build your files. It will read through all of your 'import' lines in your code so that all you'll need to do is type "dsss build" in the same directory as your D program, and it will output your compiled program
- svn is a source control system. svn makes it easy to retrieve the libraries that others have written that you'll need in order to compile an ackis module.
Retrieving Dependent Libraries
- svn
- In order for a D Ackis Module to compile, you're going to need some dependent libraries. The folders containing these libraries should be in the same directory as your D program's source code. You can retrieve these directories utilizing svn
- svn co {link} {local directory}
- Example Usage: svn co http://svn.dsource.org/projects/scrapple/trunk/tools/tools/ /myStuff/myDProgram/tools
- All but one of the libraries needed to compile a D Ackis Module can be found at opticron's repository
- The remaining library needed to compile a D Ackis Module is located here
- In order for a D Ackis Module to compile, you're going to need some dependent libraries. The folders containing these libraries should be in the same directory as your D program's source code. You can retrieve these directories utilizing svn
Development
Here is an example piece of code:
// Hello World Module module mod_helloWorld; import libackis.ackiscomponent; import std.stdio; import std.regexp; import std.string; import std.random; import std.file; import kxml.xml; import libdjson.json; char[]combdesc = "roll #D#, decide option 1( or option 2)*, trans lang1|lang2 text, track #, ddate"; int main (char[][]argc) { AckisComponent ackis = new AckisComponent("mod_misc"); ackis.register("^helloWorld.*",&helloWorld); ackis.regHelp("helloWorld","Have bot say hi to you."); ackis.runProtocol(); return 0; } void helloWorld() { }