skip to content
Frictional Game Wiki
User Tools
Register
Log In
Site Tools
Search
Tools
Show page
Old revisions
Backlinks
Recent Changes
Media Manager
Sitemap
Log In
Register
>
Recent Changes
Media Manager
Sitemap
Trace:
hpl2:resources:preprocess
<h1>Script Pre-Processer</h1> <div class="level1"> <p> The C pre-processer is a powerful tool that allows programers many options when writing their code - among these options are commands such as #include ””, which allows the user to include the contents from one code file into another. </p> <p> <a href="http://www.frictionalgames.com/forum/thread-12023.html" class="urlextern" title="http://www.frictionalgames.com/forum/thread-12023.html" rel="nofollow">Original Post</a> </p> </div> <h2>Setting Up</h2> <div class="level2"> <p> In the below ZIP-File a copy of <a href="http://mcpp.sourceforge.net/" class="urlextern" title="http://mcpp.sourceforge.net/" rel="nofollow">MCPP </a> is included as the pre-processor. I have also written a batch script which will call the pre-processor with the appropriate arguments as well as a display error messages & log them into a text file. </p> <p> <a href="http://dl.dropbox.com/u/64805489/HpsPreProcessFixed.zip" class="urlextern" title="http://dl.dropbox.com/u/64805489/HpsPreProcessFixed.zip" rel="nofollow">Zip File Download</a> </p> <p> The next thing to do is set up notepad++ to use the batch file and MCPP. Extract the contents of the zip file to a safe place (For example in a new folder in the amnesia directory). Open up notepad++ and go into the “run” menu and click “run” (or press F5). Into this dialogue box put the following: </p> <pre class="code">[FOLDER]\PreProcess.bat $(CURRENT_DIRECTORY) $(FILE_NAME) $(NAME_PART).hps </pre><p> </p> <p> Replace [FOLDER] with the folder the batch file is in. For example: </p> <pre class="code">C:\Program Files (x86)\Amnesia\HPS_PREPROCESSOR\PreProcess.bat $(CURRENT_DIRECTORY) $(FILE_NAME) $(NAME_PART).hps </pre><p> </p> <p> It is recommended that you then click save and bind the command to something like F6 - otherwise you will have to enter this every time you start notepad++ . </p> <p> <u><b>Warning: Do not press “run” (or F6 if you bound it) on a script file which ends in ”.hps”! This will wipe the script file!!! Give your script files which use the pre-processor a different extension (E.g .phps or .lhps). </b> </u> </p> </div> <h2>Usage</h2> <div class="level2"> <p> The files that exist before pre-processing will have to have a different extension to the one after pre-processing. The simplest way to do this is to call your script files something like “level.phps” so that the pre-processor writes “level.hps”. Consider the following test code: </p> <pre class="code"> //level.phps// #include "inclusion_test.phps" void OnEnter() { AddDebugMessage("File 1",false); } //inclusion_test.phps// void OnStart() { AddDebugMessage("File 2",false); } </pre><p> </p> <p> Running the script from test.phps (F6 if you followed the instructions above) should create “test.hps”: </p> <pre class="code">void OnStart() { AddDebugMessage("File 2",false); } void OnEnter() { AddDebugMessage("File 1",false); } </pre><p> </p> <p> Which is what the game will see from test.map and run. When you distribute your custom stories only this exported file is required. Obviously, since we are now using a C pre-processor there is a whole <a href="http://en.wikipedia.org/wiki/C_preprocessor" class="urlextern" title="http://en.wikipedia.org/wiki/C_preprocessor" rel="nofollow">host of other things you can do.</a> </p> </div> <h2>Reccomended Extra Installation Setup</h2> <div class="level2"> <p> You may notice that stuff like #include isn't color coded - and that your new script files ”.phps” aren't automatically recognised as HPS files! I Have updated the notepad++ files to fix this (Note that these are updated versions of the <a href="http://www.frictionalgames.com/forum/thread-9783.html" class="urlextern" title="http://www.frictionalgames.com/forum/thread-9783.html" rel="nofollow">overhauled notepad++ files</a>, which provide a fixed function list, folding regions and a new color scheme) </p> <p> <a href="http://www.mediafire.com/?yx2nb2zdgdswg4e" class="urlextern" title="http://www.mediafire.com/?yx2nb2zdgdswg4e" rel="nofollow">Download</a> </p> <p> Installation (Steps 1→4 are optional but recommended): </p> <ol> <li class="level1"> Close notepad++</li> <li class="level2"> Go to where you installed notepad (Probably C:\Program Files\Notepad++ or C:\Program Files (X86)\Notepad++\)</li> <li class="level2"> Go to the folder "Plugins" Then to the folder "APIs"</li> <li class="level2"> Copy across the downloaded version of "hps.xml" into this folder. If you a prompted to overwrite, say yes.</li> </ol> <ol> <li class="level1"> Start notepad++</li> <li class="level2"> Go into view→ User-Defined Dialogue</li> <li class="level2"> On the drop-down box, if there is the option to select "HPS", select it and and click "Remove"</li> <li class="level2"> Click import, and import "UserDefinedDialogue.xml"</li> </ol> <p> <br/> <br/> You will now a fixed functions list for amnesia (Adds missing functions & keywords, removes non-existing ones), as well as a new color scheme, folding regions (<em>+ </em>- /<nowiki>*</nowiki><nowiki>*</nowiki> <nowiki>*</nowiki><nowiki>*</nowiki>/ <em>Begin </em> End) etc. ”.hps, .phps, .lhps” are now detected, and ”#…” are coloured correctly. </p> </div>
hpl2/resources/preprocess.txt
· Last modified: 2012/06/06 20:37 by
apjjm
Page Tools
Show page
Old revisions
Backlinks
Export to PDF
Back to top