Skip to content

Commit

Permalink
Squirrel Lexer for code-block syntax highlighting. (R2Northstar#160)
Browse files Browse the repository at this point in the history
better than nothing, maybe not perfect
  • Loading branch information
laundmo authored Mar 30, 2023
1 parent b8d5ce7 commit c6522a4
Show file tree
Hide file tree
Showing 32 changed files with 495 additions and 164 deletions.
3 changes: 3 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"sphinx_design",
"sphinxcontrib.youtube",
"sphinx_copybutton",
"sphinx_rsquirrel",
]

intersphinx_mapping = {
Expand Down Expand Up @@ -58,3 +59,5 @@

# -- Options for EPUB output
epub_show_urls = "footnote"

highlight_language = "squirrel"
2 changes: 1 addition & 1 deletion docs/source/guides/gettingstarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ configuration file.
When starting a match, ``Northstar.CustomServers`` mod will retrieve the configuration
variable value, or its default value if it hasn't been specified in configuration file:

.. code-block:: javascript
.. code-block::
// start countdown
SetUIVar( level, "gameStartTime", Time() + GetConVarFloat( "ns_private_match_countdown_length" ) )
Expand Down
6 changes: 3 additions & 3 deletions docs/source/guides/keyvalue/localisation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ translation keys, preceded by a ``#``.
For example, to translate the "Launch Northstar" button on main menu, instead of
calling:

.. code-block:: javascript
.. code-block::
AddComboButton( comboStruct, headerIndex, buttonIndex++, "Launch Northstar" )
We'll use:

.. code-block:: javascript
.. code-block::
AddComboButton( comboStruct, headerIndex, buttonIndex++, "#MENU_LAUNCH_NORTHSTAR" )
You can also use the ``Localize`` method client-side:

.. code-block:: javascript
.. code-block::
Localize( "#MENU_LAUNCH_NORTHSTAR" )
Expand Down
18 changes: 9 additions & 9 deletions docs/source/guides/scripting/gamemodemods.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Shared functions
----------------
Let's begin the process by first creating the file ``sh_gamemode_simplerandomiser.nut`` and making the core components of the gamemode, which is to define the gamemode properties.

.. code-block:: javascript
.. code-block::
global function simplerandomiser_init // initializing functions
global const string GAMEMODE_SIMPLERANDOMISER = "rand"
Expand Down Expand Up @@ -194,7 +194,7 @@ Server-side function
--------------------
Now that we're down with defining the gamemode, its time to focus on the component on what makes the gamemode function in-game. For this, it will be mostly handled by the server scripts, so head into ``_gamemode_simplerandomiser.nut`` to begin writing the randomizing script.

.. code-block:: javascript
.. code-block::
global function GamemodeRand_Init
Expand All @@ -214,7 +214,7 @@ Now that our initial function is created, we now have the game triggering `GiveR
Firstly, we need to know what weapons we can equip.
For this we define an array:

.. code-block:: javascript
.. code-block::
array<string> pilotWeapons = ["mp_weapon_alternator_smg",
"mp_weapon_autopistol",
Expand All @@ -228,7 +228,7 @@ Randomise function
As we already know its going to call the function ``GiveRandomGun`` when a player respawns, let's define that now.
First we strip any existing weapons:

.. code-block:: javascript
.. code-block::
void function GiveRandomGun(entity player)
{
Expand All @@ -239,22 +239,22 @@ This iterates through each weapon (that being the primary, secondary and anti-ti

Then lets give them a new, random weapon by selecting a random item from our previous array:

.. code-block:: javascript
.. code-block::
player.GiveWeapon( pilotWeapons[ RandomInt( pilotWeapons.len() ) ] )
Now, remember the server callback that we defined earlier in ``sh_gamemode_simplerandomiser.nut``? Let's put that to use.
We are going to make it so the player receives an announcement whenever they have their weapons randomized.

.. code-block:: javascript
.. code-block::
// checks if the toggle option is set to enabled
if ( GetCurrentPlaylistVarInt( "rand_enableannouncements", 1 ) == 1 )
Remote_CallFunction_NonReplay( player, "ServerCallback_Randomiser" ) // call the function that will be used client-side
Overall, the server script should look like this.

.. code-block:: javascript
.. code-block::
global function GamemodeRand_Init
Expand Down Expand Up @@ -291,7 +291,7 @@ Client-side functions
------------------
Lastly, for your ``cl_gamemode_simplerandomiser.nut``, we are going to utilize the callback functions from earlier, as well as add some music to play during the gamemode.

.. code-block:: javascript
.. code-block::
global function ClGamemodeRand_Init
global function ServerCallback_Randomiser
Expand Down Expand Up @@ -370,7 +370,7 @@ Yes, you will need to create a folder called ``keyvalues`` which is separate fro

Next, inside this ``playlist_v2.txt``, we will need to allow/disallow what maps can the gamemode be played on.

.. code-block::
.. code-block:: text
playlists
{
Expand Down
12 changes: 7 additions & 5 deletions docs/source/guides/tools/VTFModding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ Creating VMT
In the same folder you extracted your mdl's. Make a ``materials`` folder next to the ``models`` folder.

Example:
::
.. code-block:: text
models
materials
Recreate the path you changed in the ``materials`` folder, such that the last section is a .vmt file:

::
.. code-block:: text
materials
└─ models
Expand All @@ -91,7 +91,7 @@ Recreate the path you changed in the ``materials`` folder, such that the last se
└─ car_ctm.vmt
Inside your .vmt paste:
::
.. code-block:: text
"UnlitTwoTexture"
{
Expand Down Expand Up @@ -141,7 +141,7 @@ Final VPK folder

Your root folder should look somewhat like this

::
.. code-block:: text
root
├─ materials
Expand Down Expand Up @@ -172,7 +172,8 @@ To add animation functionality, all we need to do is add a Proxie; which is just
You need to create a .vtf texture with multiple frames imported to a single .vtf texture, that's your animated texture. You can do this with `VTFEdit`_. Then assign the texture in ``$basetexture``.

At the bottom of your vmt but before the ``}``, add this:
::
.. code-block:: text
"Proxies"
{
AnimatedTexture
Expand All @@ -183,4 +184,5 @@ At the bottom of your vmt but before the ``}``, add this:
}
}
To change the fps of the texture, change the value after ``animatedTextureFrameRate``, and you'll be done making your texture animated!
4 changes: 2 additions & 2 deletions docs/source/guides/tools/rpakmodding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Once it has been downloaded, it is recommended to set up your file structure as

Depending on the version of RePak, some of these folders and files might be already there for you

.. code-block::
.. code-block:: text
RePak
├── RePak.exe
Expand Down Expand Up @@ -241,7 +241,7 @@ The file structure of your ``paks`` folder should be similar to this:

|PaksStructure|

.. code-block::
.. code-block:: text
paks
├── example.rpak
Expand Down
2 changes: 1 addition & 1 deletion docs/source/guides/tools/soundmodding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ When you successfully identified your event and have the audio file/s
ready it's time to set up the folder structure.
Assuming the event name is ``pilot_grapple_fire``, the folder structure of your mod should look like this:

.. code-block::
.. code-block:: text
author.mod/
├── audio/
Expand Down
22 changes: 11 additions & 11 deletions docs/source/reference/northstar/chathooks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The client chat callbacks allow you to intercept chat messages and modify or blo

**Example:**

.. code-block:: javascript
.. code-block::
ClClient_MessageStruct function MyChatFilter(ClClient_MessageStruct message)
{
Expand Down Expand Up @@ -87,7 +87,7 @@ players, they only display them locally.

**Example:**

.. code-block:: javascript
.. code-block::
void function OnGameStarted()
{
Expand All @@ -101,7 +101,7 @@ players, they only display them locally.

**Example:**

.. code-block:: javascript
.. code-block::
void function InitialiseHEVSuit()
{
Expand All @@ -122,7 +122,7 @@ players, they only display them locally.

**Example:**

.. code-block:: javascript
.. code-block::
void function MyModInit()
{
Expand All @@ -136,7 +136,7 @@ players, they only display them locally.

**Example:**

.. code-block:: javascript
.. code-block::
void function OnButtonPressed()
{
Expand Down Expand Up @@ -193,7 +193,7 @@ The server chat callbacks allow you to intercept incoming chat messages and modi

**Example:**

.. code-block:: javascript
.. code-block::
ClServer_MessageStruct function MyChatFilter(ClServer_MessageStruct message)
{
Expand Down Expand Up @@ -230,7 +230,7 @@ With custom messages you can send chat messages at any time, to all players or t

**Example:**

.. code-block:: javascript
.. code-block::
void function OnSayRedCommand(entity player, string text)
{
Expand All @@ -252,7 +252,7 @@ With custom messages you can send chat messages at any time, to all players or t

**Example:**

.. code-block:: javascript
.. code-block::
void function OnSendToFriendsCommand(entity fromPlayer, string text)
{
Expand All @@ -275,7 +275,7 @@ With custom messages you can send chat messages at any time, to all players or t

**Example:**

.. code-block:: javascript
.. code-block::
void function RestartServerThread()
{
Expand Down Expand Up @@ -308,7 +308,7 @@ With custom messages you can send chat messages at any time, to all players or t

**Example:**

.. code-block:: javascript
.. code-block::
void function OnBanCommand(entity player, array<string> args)
{
Expand All @@ -330,7 +330,7 @@ ANSI Escape Codes
All messages support ANSI escape codes for customising text color. These are commands in strings that have special
meaning. For example, the string:

.. code-block::
.. code-block:: text
Hello world, \x1b[31mthis text is red\x1b[0m. And \x1b[34mthis text is blue\x1b[0m.
Expand Down
10 changes: 5 additions & 5 deletions docs/source/reference/northstar/dependencyconstants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ Contditons you can check for are

These conditions can also be combined with the regular squirrel boolean expressions

.. code-block:: javascript
.. code-block::
#if SERVER
Chat_ServerBroadcast("Message from the server VM")
#endif
.. code-block:: javascript
.. code-block::
#if (CLIENT && MP) || DEV
...
Expand All @@ -40,7 +40,7 @@ loaded, these use the Compiler directives syntax.

Inside your ``mod.json`` define a constant as:

.. code-block:: javascript
.. code-block::
{
// mod.json stuff
Expand All @@ -52,14 +52,14 @@ Inside your ``mod.json`` define a constant as:
For Example:

.. code-block:: javascript
.. code-block::
"PLAYER_HAS_ROGUELIKE_MOD": "TF|Roguelike"
Will define a constant ``PLAYER_HAS_ROGUELIKE_MOD`` that is set to ``0`` or ``1``
depending if the mod is enabled. It then can be used as a constant/compiler flag.

.. code-block:: csharp
.. code-block::
#if PLAYER_HAS_ROGUELIKE_MOD
print("player has roguelike mod")
Expand Down
6 changes: 3 additions & 3 deletions docs/source/reference/northstar/httprequests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Functions
Lambdas are particularly useful as they let you capture local variables of the functions to re-use later
such as ``callback`` in this example.

.. code-block:: javascript
.. code-block::
HttpRequest request
request.method = HttpRequestMethod.GET
Expand Down Expand Up @@ -239,7 +239,7 @@ Functions

This is the same example as NSHttpRequest()'s example. However, it uses this function instead.

.. code-block:: javascript
.. code-block::
table<string, array<string> > params
params[ "id" ] <- [ id.tostring() ]
Expand Down Expand Up @@ -302,7 +302,7 @@ Functions

In this example, we'll convert a table to JSON, and send it over to a web API.

.. code-block:: javascript
.. code-block::
table myData = {}
myData[ "uid" ] <- player.GetUID()
Expand Down
Loading

0 comments on commit c6522a4

Please sign in to comment.