Difference between revisions of "Discretion Module Tutorial"

From ASSS Wiki
Jump to: navigation, search
(images and formatting)
(bullets!)
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
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.
+
This tutorial is divided into a few pieces. If you're completely new to [[Discretion]] development, you can view them in order, otherwise you can skip to the one you're interested in. If you go in order, they assume you have no knowledge and no tools installed.
  
==Windows with MSVC==
 
  
First step: make a new VS.net C++ Project.
+
* [[Obtaining the Discretion Source using Subversion]]
 +
* [[Creating and Testing a Simple Discretion Module]]
 +
* [[Discretion Commands and Displaying Images]] (Also covers listening for callbacks and using interfaces)
 +
* [[Listening for Key Presses, Displaying Text, and Per Player Data]]
  
1. File -> New Project
+
[[Category:Discretion]]
 
+
[[Category:Guides]]
2. Win32 Console Project
 
 
 
3. Give your project a name ("TestModule" in the picture)
 
 
 
4. Press Ok
 
 
 
[[Image: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
 
 
 
[[Image: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
 
 
 
[[Image:disc_module3.PNG]]
 
 
 
13. Paste the following code into your source file
 
<pre>// Sample Discretion Module Source File
 
#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);
 
}
 
}</pre>
 
 
 
14. Right Click your project in the Solution Explorer and go to Properties (You can also access this through the Project Menu, Project -> Properties)
 
 
 
[[Image: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
 
 
 
[[Image:disc_module5.PNG]]
 
 
 
19. Go to Buld -> Build <project name> ("TestModule" in the pictue)
 
 
 
[[Image: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).
 
 
 
[[Image: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
 
 
 
[[Image:disc_module8.PNG]]
 
 
 
24. Run Discretion, Select Practice Offline
 
 
 
25. Observe your modules initialization in the console window
 
 
 
[[Image: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.
 
 
 
==Linux==
 
Let me know if you want a tutorial for this, or write one yourself!
 

Latest revision as of 02:08, 16 March 2008

This tutorial is divided into a few pieces. If you're completely new to Discretion development, you can view them in order, otherwise you can skip to the one you're interested in. If you go in order, they assume you have no knowledge and no tools installed.