Difference between revisions of "HPL3/Scripting/Scripting Guide/Setting up CodeLite"

From Frictional Wiki
Jump to navigation Jump to search
Line 26: Line 26:
 
#[https://downloads.codelite.org/ReleaseArchive.php Download CodeLite version 12.0.0.]
 
#[https://downloads.codelite.org/ReleaseArchive.php Download CodeLite version 12.0.0.]
 
#'''Launch CodeLite and configure:'''
 
#'''Launch CodeLite and configure:'''
##<code>Settings → Code Completion → General</code>:
+
##<span style="font-family: monospace,monospace;">'''Settings → Code Completion → General'''</span>:
##*Add <code>;*.hps</code> at the end of the <code>Additional file extensions to parse</code> list.
+
##*Add <span style="font-family: monospace,monospace;">''';*.hps'''</span> at the end of the <span style="font-family: monospace,monospace;">'''Additional file extensions to parse'''</span> list.
##*Enable <code>Keep function signature un-formatted.</code>
+
##*Enable <span style="font-family: monospace,monospace;">'''Keep function signature un-formatted'''</span>.
##*Enable <code>Re-parse on workspace loaded</code>.
+
##*Enable <span style="font-family: monospace,monospace;">Re-parse on workspace loaded<span>.
##<code>Settings → Code Completion → Colouring</code>: Enable <code>Apply context aware colouring</code>.
+
##<span style="font-family: monospace,monospace;">Settings → Code Completion → Colouring<span>: Enable <span style="font-family: monospace,monospace;">Apply context aware colouring<span>.
##<code>Settings → Code Completion → CTags → Search Paths</code>: Click <code>Add...</code>, navigate to the game folder and select the <code>script</code> folder.
+
##<span style="font-family: monospace,monospace;">Settings → Code Completion → CTags → Search Paths<span>: Click <span style="font-family: monospace,monospace;">Add...<span>, navigate to the game folder and select the <span style="font-family: monospace,monospace;">script<span> folder.
##<code>Settings → Colours and Fonts...</code>: Click on <code>Import settings from a zip archive</code> and select the <code>CodeLiteColorSettings.zip</code> file.
+
##<span style="font-family: monospace,monospace;">Settings → Colours and Fonts...<span>: Click on <span style="font-family: monospace,monospace;">Import settings from a zip archive<span> and select the <span style="font-family: monospace,monospace;">CodeLiteColorSettings.zip<span> file.
 
##Configure the rest of CodeLite to your liking.
 
##Configure the rest of CodeLite to your liking.
#'''Create a new workspace:''' Create a folder inside your game directory and name it <code>_src</code>. Go to the <code>Workspace</code> menu and click on <code>New Workspace...</code>. Save the workspace inside the <code>_src</code> folder.
+
#'''Create a new workspace:''' Create a folder inside your game directory and name it <span style="font-family: monospace,monospace;">_src<span>. Go to the <span style="font-family: monospace,monospace;">Workspace<span> menu and click on <span style="font-family: monospace,monospace;">New Workspace...<span>. Save the workspace inside the <span style="font-family: monospace,monospace;">_src<span> folder.
#'''Create a new project:''' <code>Right click on the workspace → New → New Project</code>. Select <code>Others → Non-code project</code>. Give the project a name (For example: "soma"). Leave the rest as default.
+
#'''Create a new project:''' <span style="font-family: monospace,monospace;">Right click on the workspace → New → New Project<span>. Select <span style="font-family: monospace,monospace;">Others → Non-code project<span>. Give the project a name (For example: "soma"). Leave the rest as default.
#'''Add a folder to the project:''' Right-click on the project and choose <code>New Virtual Folder</code>. Name it <code>_api</code>.
+
#'''Add a folder to the project:''' Right-click on the project and choose <span style="font-family: monospace,monospace;">New Virtual Folder<span>. Name it <span style="font-family: monospace,monospace;">_api<span>.
 
#'''Add the game script files:'''  
 
#'''Add the game script files:'''  
##Right-click on <code>_api → Add An Existing File...</code>, add the file <code>hps_api.hps</code> from the game folder (If the file does not appear in your game folder, launch the game, and the file will appear).
+
##Right-click on <span style="font-family: monospace,monospace;">_api → Add An Existing File...<span>, add the file <span style="font-family: monospace,monospace;">hps_api.hps<span> from the game folder (If the file does not appear in your game folder, launch the game, and the file will appear).
##Right-click on the project and choose <code>Import Files From Directory</code>. Navigate to the game folder and select it. In the next window, check the boxes for the folders: <code>maps, script, mods</code> and click ok.
+
##Right-click on the project and choose <span style="font-family: monospace,monospace;">Import Files From Directory<span>. Navigate to the game folder and select it. In the next window, check the boxes for the folders: <span style="font-family: monospace,monospace;">maps, script, mods<span> and click ok.
  
'''Lastly, go to <code>Workspace</code> and click on <code>Parse Workspace</code>.'''
+
'''Lastly, go to <span style="font-family: monospace,monospace;">Workspace<span> and click on <span style="font-family: monospace,monospace;">Parse Workspace<span>.'''
  
 
That should be it, you should now have three top folders in your project and a lot of sub-folders with various script files.
 
That should be it, you should now have three top folders in your project and a lot of sub-folders with various script files.
Line 47: Line 47:
  
 
{{note|If the list disappears, you can make it re-appear again by pressing <code>ctrl-space</code>. If you want to bring up hints when inside the () of a function, press <code>ctrl-shift-space</code>.}}
 
{{note|If the list disappears, you can make it re-appear again by pressing <code>ctrl-space</code>. If you want to bring up hints when inside the () of a function, press <code>ctrl-shift-space</code>.}}
 +
 +
==Launching the Game From CodeLite==
 +
 +
One additional thing you can do is to launch the game or your mod in dev mode through CodeLite itself.
 +
 +
To do this, right click on your project and go to settings. Then Click on <code>Customize → Custom Build</code>.
 +
Turn on <code>Enable Custom Build</code>. In the working directory, select the game folder.
 +
 +
Now we will need to add the command that launches the game or our mod. For this video I will show how to launch my sample mod in dev mode.
 +
 +
Rebirth.exe -user Dev -cfg config/main_init_dev.cfg
 +
  
 
==Issues & Info==
 
==Issues & Info==

Revision as of 19:26, 8 August 2020

This is a quick guide on how to set-up the third party scripting tool - CodeLite.

CodeLite - Introduction

As mentioned Scripting in HPL3 can look a lot like regular programming, but less complicated.

Because of that, we need tools that will be able to aid us when we write our code. For HPL2, Notepad++ or even Notepad were enough for that. This time around, something more powerful is needed.

CodeLite is very much like a text editor, but much more programming-oriented than Notepad++. It is the tool used officially by Frictional Games to develop their HPL3 games. Here are some of the relevant features of CodeLite:

  • Code documentation on the fly
  • Code autocompletion and smart code suggestion
  • Fast and easy way to navitgate through large script files
  • The ability to run the game from CodeLite

For the scripting guide, CodeLite 12.0.0 will be used, which is the latest stable release that can work with HPL3 without any errors or bugs.

CodeLite with a scripting workspace for SOMA (click to view full size).

Setting-up CodeLite

This section explains how to configure CodeLite so it can be suitable for HPL3 scripting, how to create a workspace and a project, and how to import the script files.

Note icon.png You must install CodeLite on the same disk as the game you want to mod. For example, if Amnesia: Rebirth is installed on disk C:, you have to install CodeLite on C: as well.
  1. Download the optimized color theme
  2. Download CodeLite version 12.0.0.
  3. Launch CodeLite and configure:
    1. Settings → Code Completion → General:
      • Add ;*.hps at the end of the Additional file extensions to parse list.
      • Enable Keep function signature un-formatted.
      • Enable Re-parse on workspace loaded.
    2. Settings → Code Completion → Colouring: Enable Apply context aware colouring.
    3. Settings → Code Completion → CTags → Search Paths: Click Add..., navigate to the game folder and select the script folder.
    4. Settings → Colours and Fonts...: Click on Import settings from a zip archive and select the CodeLiteColorSettings.zip file.
    5. Configure the rest of CodeLite to your liking.
  4. Create a new workspace: Create a folder inside your game directory and name it _src. Go to the Workspace menu and click on New Workspace.... Save the workspace inside the _src folder.
  5. Create a new project: Right click on the workspace → New → New Project. Select Others → Non-code project. Give the project a name (For example: "soma"). Leave the rest as default.
  6. Add a folder to the project: Right-click on the project and choose New Virtual Folder. Name it _api.
  7. Add the game script files:
    1. Right-click on _api → Add An Existing File..., add the file hps_api.hps from the game folder (If the file does not appear in your game folder, launch the game, and the file will appear).
    2. Right-click on the project and choose Import Files From Directory. Navigate to the game folder and select it. In the next window, check the boxes for the folders: maps, script, mods and click ok.

Lastly, go to Workspace and click on Parse Workspace.

That should be it, you should now have three top folders in your project and a lot of sub-folders with various script files. Start typing something, for example Entity_ and a list should appear showing all the functions that begin with Entity_ and the documentation for each selected function.

Note icon.png If the list disappears, you can make it re-appear again by pressing ctrl-space. If you want to bring up hints when inside the () of a function, press ctrl-shift-space.

Launching the Game From CodeLite

One additional thing you can do is to launch the game or your mod in dev mode through CodeLite itself.

To do this, right click on your project and go to settings. Then Click on Customize → Custom Build. Turn on Enable Custom Build. In the working directory, select the game folder.

Now we will need to add the command that launches the game or our mod. For this video I will show how to launch my sample mod in dev mode.

Rebirth.exe -user Dev -cfg config/main_init_dev.cfg


Issues & Info

  • Write Class@ object and not Class @object, the latter will screw up coloring.
  • If you lose coloring / code completion and can't get it back, re-parse the workspace: Parse Workspace.
  • Parameters with &in might break the coloring of function parameters, but will have no other side-effects.