Discretion Module Tutorial

From ASSS Wiki
Revision as of 23:16, 21 February 2007 by BaK (talk | contribs) (content)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Alright, in this topic I will attempt to help you make a module. Making a module is easy pie once you know what to do, so let's get to it.

Windows with MSVC:

First step: make a new VS.net C++ Project.

1. File -> New Project 2. Win32 Console Project 3. Give your project a name ("TestModule" in the picture) 4. Press Ok [disc_module1.PNG]

5. Click on application settings on the left 6. Click DLL from the list of radio buttons 7. Press the Empty Project checkbox 8. Press Finish [disc_module2.PNG]

9. File -> Add New Item 10. Select C++ Source File (.cpp) 11. Name your source file ("testmodule.cpp" in the picture) 12. Press Open [disc_module3.PNG]

13. Paste the following code into your source file [code]// Sample Discretion Module Source File

  1. include "Module.h"

void* getClassInstance(void* _mm, LoadMode lm) { if (lm == LOADMODE_Init) printf("Test Module Initialized\n");

return 0; }

extern "C" { EXPORT void* getInstance(void* mm, LoadMode lm) { return getClassInstance(mm,lm); } }[/code]

14. Right Click your project in the Solution Explorer and go to Properties (You can also access this through the Project Menu, Project -> Properties) [disc_module4.PNG]

15. In the properties window, from the drop down menu select "All Configurations" 16. Select C++, General from the tree view on the left 17. Type the directory to the Modules directory (the one with Module.h in it, not the one with only .dlls!) that comes with the full version of Discretion in the Additional Include Directory property ("E:/client/modules" in the picture) 18. Press Ok [disc_module5.PNG]

19. Go to Buld -> Build <project name> ("TestModule" in the pictue) [disc_module6.PNG]

If all goes well, you code should compile and a .dll should be produced that is a Discretion module! Now let's put the module into Discretion to see it at work.

20. Copy the produced .dll into your Discretion executable's Module folder (the one with the .dlls in it, not the one with Module.h in it). [disc_module7.PNG]

21. Edit conf/MAIN.CONF with a program such as Notepad 22. Add the name of your dll to the Modules::Names setting (it's a comma seperated list of module names, order doesn't matter) 23. Save the file [disc_module8.PNG]

24. Run Discretion, Select Practice Offline 25. Observe your modules initialization in the console window [disc_module9.PNG]

Now you might say, rightfully so, that this module doesn't do anything. The way to do real things in Discretion is by using other modules. Want to react to user key presses? Use the KeyControls module. Want to display some images? Use the Graphics module. I'll gladly write additional tutorials for how to use each of these as needed. Tell me what you want to do and I'll write a tutorial with how to use the existing modules to accomplish what you want to do.