### Git tag for actual release example Source: https://docs.northstar.tf/Wiki/development/releases?q= Example of tagging a final release with version v1.8.0. ```bash git tag v1.8.0 git push origin v1.8.0 ``` -------------------------------- ### Example workflow for PR from NachosChipeados Source: https://docs.northstar.tf/Wiki/development/repositories/northstarmods Complete example of configuring the PR branch, fetching it, checking out the branch, merging main with the 'ours' strategy, and pushing the changes back to the PR branch. ```bash # After pushing vanilla files to main, configure PR branch git remote add NachosChipeados git@github.com:NachosChipeados/NorthstarMods.git git fetch NachosChipeados # Move to the PR branch git checkout NachosChipeados/global_precacheres # Merge main into the PR branch git merge --strategy=ours main # Push modification to the PR branch git push -u NachosChipeados HEAD:global_precacheres ``` -------------------------------- ### Git tag for release candidate example Source: https://docs.northstar.tf/Wiki/development/releases?q= Example of tagging a release candidate with version v1.8.0-rc1. ```bash git tag v1.8.0-rc1 git push origin v1.8.0-rc1 ``` -------------------------------- ### Full dialog example Source: https://docs.northstar.tf/Modding/reference/respawn/dialog Complete example that sets header, message with newlines, message color, spinner, PC back button, and adds a button before opening the dialog. The message color is RGBA [0,200,0,100]. ```unknown DialogData dialog dialog.header = "This is the header" dialog.message = "this is the body, it is green \n \n Hello There \n \n General Kenobi" dialog.messageColor = [0,200,0,100] dialog.showSpinner = true dialog.showPCBackButton = true AddDialogButton( dialog, "Button 1 %%$r2_ui/menus/loadout_icons/primary_weapon/primary_kraber%%", ButtonOnePressed ) OpenDialog( dialog ) ``` -------------------------------- ### Start Docker container with docker-compose up Source: https://docs.northstar.tf/Wiki/hosting-a-server-with-northstar/dedicated-server/hosting-on-linux Starts the Northstar server container defined in the docker-compose.yml file. Run this command from the directory containing the compose file. ```bash docker-compose up ``` -------------------------------- ### rpak.json example Source: https://docs.northstar.tf/Modding/guides/tools/rpakmodding?q= Example rpak.json configuration for a mod. Preload controls early loading, Aliases replaces a target RPak with another, and Postload specifies load-after dependencies. ```json { "Preload": { "example.rpak": false }, "Aliases": { "camo_skin04_col.rpak": "example.rpak" }, "Postload": { } } ``` -------------------------------- ### Delayed position setting example Source: https://docs.northstar.tf/Modding/squirrel/async?q= A practical example showing how to use wait to delay entity property changes. ```squirrel void function SetPositionDelayed( entity ent, vector pos, float delay ) { wait delay ent.SetOrigin( pos ) } SetPositionDelayed( player, <0, 0, 100>, 5.0 ) SetPositionDelayed( player, <0, 0, 50>, 2.5 ) // this will finish sooner. ``` -------------------------------- ### Client Command Callback Registration Example Source: https://docs.northstar.tf/Modding/squirrel/networking Registers a client command callback serverside. The callback receives the player entity and command arguments. The example registers a callback for the 'PrivateMatchLaunch' command. ```squirrel void function init(){ AddClientCommandNotifyCallback("PrivateMatchLaunch", started) } void function started(entity player, array args){ print(player + " started the match") } ``` -------------------------------- ### Allow duplicate accounts when starting server Source: https://docs.northstar.tf/Wiki/development/testing Allow duplicate accounts when starting a server. By default duplicate accounts are blocked by the server. Use this flag to allow multiple clients on the same account to connect. ```console -allowdupeaccounts ``` -------------------------------- ### Repak main map example Source: https://docs.northstar.tf/Modding/repak Example JSON map used to build an .rpak file with Repak. Includes options like keepDevOnly, version, name, streamFileMandatory, assetsDir, outputDir, compressLevel, compressWorkers, hasDynamicLibrary, and files array. ```json { "keepDevOnly": true, "version": 7, "name": "placeholdername", "streamFileMandatory": "placeholdername.starpak", "assetsDir": "bal", "outputDir": "build", "compressLevel": 0, "compressWorkers": 16, "hasDynamicLibrary": true, "files": [ ] } ``` -------------------------------- ### Preinstall Source: https://docs.northstar.tf/Modding/reference/respawn/native_server/misc?q= Functions for checking game installation status and trial version. ```APIDOC ## Preinstall ### Description Functions for checking game installation status and trial version. ### Functions #### bool IsGameFullyInstalled() - **Description**: Returns true if the full game is installed. You can't start mp or any sp map but sp_training and sp_crashsite if this is false. #### bool IsGamePartiallyInstalled() - **Description**: Returns true if the game is partially installed. You can't start sp training this is false. #### float GetGameFullyInstalledProgress() - **Description**: Returns fraction 0.0 to 1.0 of downloading of full game progress. #### bool Script_IsRunningTrialVersion() - **Description**: Only call when we have an active user. ``` -------------------------------- ### Directory Structure Example Source: https://docs.northstar.tf/Modding/guides/tools/VTFModding The required folder structure for models and materials. ```text models materials ``` -------------------------------- ### Example of +setplaylistvaroverrides argument Source: https://docs.northstar.tf/Wiki/hosting-a-server-with-northstar/server-settings/playlistvar Shows how to pass playlist overrides in the `ns_startup_args_dedi.txt` file. The list must be quoted and separated by spaces. ```text +setplaylistvaroverrides "run_epilogue 0 featured_mode_amped_tacticals 1" ``` -------------------------------- ### SpawnPoints_GetDropPodStart Source: https://docs.northstar.tf/Modding/reference/respawn/native_server/spawnpoints?q= Gets droppod start spawn points for a team. ```APIDOC ## SpawnPoints_GetDropPodStart ### Description Gets droppod start spawn points for a team. ### Method array ### Signature `array SpawnPoints_GetDropPodStart( int team )` ### Parameters - **team** (int) - Required - The team identifier. ### Returns - **array** - The droppod start spawn points. ``` -------------------------------- ### RePak file structure Source: https://docs.northstar.tf/Modding/guides/tools/rpakmodding?q= Recommended file structure for RePak first-time setup. Place RePak.exe, repak_map.json, and an assets folder in the RePak base folder. ```text RePak ├── RePak.exe ├── repak_map.json └── assets ``` -------------------------------- ### SpawnPoints_GetTitanStart Source: https://docs.northstar.tf/Modding/reference/respawn/native_server/spawnpoints?q= Gets titan start spawn points for a team. ```APIDOC ## SpawnPoints_GetTitanStart ### Description Gets titan start spawn points for a team. ### Method array ### Signature `array SpawnPoints_GetTitanStart( int team )` ### Parameters - **team** (int) - Required - The team identifier. ### Returns - **array** - The titan start spawn points. ``` -------------------------------- ### SpawnPoints_GetPilotStart Source: https://docs.northstar.tf/Modding/reference/respawn/native_server/spawnpoints?q= Gets pilot start spawn points for a team. ```APIDOC ## SpawnPoints_GetPilotStart ### Description Gets pilot start spawn points for a team. ### Method array ### Signature `array SpawnPoints_GetPilotStart( int team )` ### Parameters - **team** (int) - Required - The team identifier. ### Returns - **array** - The pilot start spawn points. ``` -------------------------------- ### Chat_GameWriteLine example Source: https://docs.northstar.tf/Modding/reference/northstar/chathooks?q= Writes a line to local game chat panels using Chat_GameWriteLine, supporting ANSI escape codes. Called when a game starts. ```Squirrel void function OnGameStarted() { Chat_GameWriteLine("You got this, " + GetLocalClientPlayer().GetPlayerName() + "!") } ``` -------------------------------- ### Declare a class with methods and instantiate it Source: https://docs.northstar.tf/Modding/squirrel/class?q= Defines a class `ExampleClass` with a `variable` field and `setV`/`getV` methods. Instantiates it and demonstrates setting and getting the field. Functions must return `var`. ```squirrel global var ExampleClass; void function initClassF(){ class ExampleClass { variable = "default value" // Set field 'variable' of this instance to passed parameter function setV( pV ){ this.variable = pV } // Return field 'variable' of this instance function getV(){ return this.variable; // return value can be of any type } } var inst = ExampleClass(); print(inst.getV()); // -> default value inst.setV("new value"); print(inst.getV()); // -> new value } ``` -------------------------------- ### Thread and coroutine timer example in Squirrel Source: https://docs.northstar.tf/Modding/squirrel/intro?q= Shows how to use threads and coroutines in Squirrel. The main function starts a thread that runs the timer function, which waits n seconds in a loop and calls the callback with an incrementing iteration count. The callback prints the iteration. This demonstrates the wait statement and function references (functionref). ```squirrel void main() { thread timer( 1.0, timercallback ) } void function timercallback( int iteration ) { print( iteration ) } // call the callback function every n seconds void function timer( float n, void functionref( int ) callback ) { int iterations while ( true ) { wait n iterations += 1 callback( iterations ) } } ``` -------------------------------- ### Example mod.json for sound.go Source: https://docs.northstar.tf/Modding/guides/tools/soundmodding?q= Provides a basic mod.json file needed for a Northstar mod. The Name, Description, and Version must be set, LoadPriority is optional. ```json { "Name": "MOD_NAME_HERE", "Description": "DESCRIPTION_HERE", "Version": "0.1.0", "LoadPriority": 2 } ``` -------------------------------- ### Copy PipeWire configuration files Source: https://docs.northstar.tf/Wiki/steamdeck-and-linux/linux-troubleshooting Create the local configuration directory and copy the default PipeWire and media-session configuration files to the user directory. ```bash mkdir -p ~/.config/pipewire/media-session.d/ && cp /usr/share/pipewire/media-session.d/alsa-monitor.conf ~/.config/pipewire/media-session.d && cp /usr/share/pipewire/pipewire.conf ~/.config/pipewire/ ``` -------------------------------- ### Localize token example Source: https://docs.northstar.tf/Modding/reference/northstar/usefulfuncs?q= Returns a localized string for the given token. The example assigns the result to a variable named 'localized'. ```squirrel string localized = Localize( token ) ``` -------------------------------- ### Perform an HTTP GET request with NSHttpGet Source: https://docs.northstar.tf/Modding/reference/northstar/httprequests A shortcut wrapper for NSHttpRequest that simplifies GET requests by accepting parameters directly. ```Squirrel table > params params[ "id" ] <- [ id.tostring() ] void functionref( HttpRequestResponse ) onSuccess = void function ( HttpRequestResponse response ) : ( callback ) { SpyglassApi_OnQuerySanctionByIdSuccessful( response, callback ) } void functionref( HttpRequestFailure ) onFailure = void function ( HttpRequestFailure failure ) : ( callback ) { SpyglassApi_OnQuerySanctionByIdFailed( failure, callback ) } return NSHttpGet( "https://my.spyglass.api/sanctions/get_by_id", params, onSuccess, onFailure ) ``` -------------------------------- ### Instantiating a Class Source: https://docs.northstar.tf/Modding/squirrel/class Demonstrates defining a class with a constructor and instantiating it, followed by property manipulation. ```squirrel class ExampleClass { property = null constructor( var parameter ) { this.property = expect int(parameter); } } var exampleObject = ExampleClass(1); int n = exampleObject.property // n = 1 exampleObject.property++; n = exampleObject.property // n = 2 ``` -------------------------------- ### Generate Shader GUIDs with RePak Source: https://docs.northstar.tf/Modding/guides/tools/ShaderModding Use this command to retrieve the GUID for a shader file. Replace with the shader name without the file extension. ```bash .\RePak.exe -pakguid shader/.rpak ``` -------------------------------- ### Pushing and setting global constants Source: https://docs.northstar.tf/Modding/squirrel/cpp_api/objecthandling?q= Demonstrates how to retrieve the constants table, push key-value pairs, and register them as global constants. ```cpp getConstants(sqvm); pushstring(sqvm, "MY_CONSTANT"); pushstring(sqvm, "MY_VALUE"); newslot(sqvm, -3, false); removeFromStack(sqvm); // don't forget this! ``` -------------------------------- ### Server to UI Remote Call Example Source: https://docs.northstar.tf/Modding/squirrel/networking Calls a function in the UI VM from the server VM. The example shows calling a function named 'ScriptCallback_UnlockAchievement' with an achievement ID. ```squirrel Remote_CallFunction_UI( player, "ScriptCallback_UnlockAchievement", achievementID ) ``` -------------------------------- ### mod.json - Complete example Source: https://docs.northstar.tf/Modding/guides/scripting/gamemodemods The full mod.json file combining metadata, scripts, and localisation. ```json { "Name" : "SimpleRandomiser", "Description" : "SimpleRandomiser", "Version": "0.1.0", "LoadPriority": 1, "Scripts": [ { "Path": "gamemodes/_gamemode_simplerandomiser.nut", "RunOn": "SERVER && MP" }, { "Path": "gamemodes/cl_gamemode_simplerandomiser.nut", "RunOn": "CLIENT && MP" }, { "Path": "sh_gamemode_simplerandomiser.nut", "RunOn": "MP", "ClientCallback": { "Before": "simplerandomiser_init" }, "ServerCallback": { "Before": "simplerandomiser_init" } } ], "Localisation": [ "resource/simplerandomiser_localisation_%language%.txt" ] } ``` -------------------------------- ### Example dependency constant: PLAYER_HAS_ROGUELIKE_MOD Source: https://docs.northstar.tf/Modding/reference/northstar/dependencyconstants?q= Example of a dependency constant definition in mod.json. It defines a constant that is set to 0 or 1 depending on whether the mod 'TF|Roguelike' is enabled. ```json "PLAYER_HAS_ROGUELIKE_MOD": "TF|Roguelike" ``` -------------------------------- ### Create and populate a table with newtable and newslot Source: https://docs.northstar.tf/Modding/squirrel/cpp_api/objectmanipulation Creates a table and populates it with three slots, including a nested table. Uses newtable, pushstring, pushasset, pushinteger, and newslot to set key-value pairs. ```cpp newtable(sqvm); // slot 1 pushstring(sqvm, "key"); pushstring(sqvm, "value"); newslot(sqvm, -3); // slot 2 pushstring(sqvm, "key2"); pushasset(sqvm, "value2"); newslot(sqvm, -3); // slot 3 pushstring(sqvm, "key3"); newtable(sqvm); pushstring(sqvm, "sub"); pushinteger(sqvm, 13); newslot(sqvm, -3); newslot(sqvm, -3); /* The table on the stack now looks like this: { key = "value" key2 = $"value2" key3 = { sub = 13 } } */ ``` -------------------------------- ### Implement CreateInterface Source: https://docs.northstar.tf/Modding/plugins/interfaces Example implementation of the CreateInterface function to expose specific plugin interfaces. ```cpp void* CreateInterface(char* name, int* status) { if(strcmp(name, "IPluginId001") == 0) { if(status) *status = 0; return g_IPluginId; } if(strcmp(name, "IPluginCallbacks001") == 0) { if(status) *status = 0; return g_IPluginCallbacks; } // repeat for every interface you expose ... if(status) *status = 1; return 0; } ``` -------------------------------- ### HUD topology example with RuiTopology_CreatePlane Source: https://docs.northstar.tf/Modding/reference/respawn/topology?q= Creates a HUD topology covering the top left quadrant of the screen and draws a basic image on it. The topology dimensions are derived from the screen size; RUIs scale with the topology, so use correct dimensions. ```unknown // Cover the top left quadrant of the screen with a basic image float[2] s = GetScreenSize() var topo = RuiTopology_CreatePlane( <0,0,0>, , , true ) // RUIs scale with the topology they are being drawn on so make sure to use the correct dimensions RuiCreate( $"ui/basic_image.rpak", topo, RUI_DRAW_HUD, 0 ) ``` -------------------------------- ### ruiDataStruct_gamemode_coliseum_tickets Source: https://docs.northstar.tf/Modding/reference/respawn/rui_args Defines the RUI data structure for coliseum tickets. Contains start time, ticket fade start, duration, and number of tickets. Use when implementing or inspecting the gamemode_coliseum_tickets RUI. ```c struct ruiDataStruct_gamemode_coliseum_tickets { BYTE gap_0[36]; float startTime; float startTicketFade; float duration; int numTickets; BYTE gap_34[28]; }; ``` -------------------------------- ### AddDialogButton example Source: https://docs.northstar.tf/Modding/reference/respawn/dialog Shows how to add a button to a dialog with AddDialogButton, including a callback that prints when pressed. The button text uses an asset path with %% markers. ```unknown void function SendDialogWithButton() { DialogData dialog dialog.message = "Hello there" AddDialogButton(dialog, "Button 1 %%$r2_ui/menus/loadout_icons/primary_weapon/primary_kraber%%", void function(): { print( "pressed button 1" ) }) OpenDialog( dialog ) } ``` -------------------------------- ### MenuCallbacks_Init Source: https://docs.northstar.tf/Modding/reference/northstar/callbacks Initializes menu callbacks. ```APIDOC ## MenuCallbacks_Init ### Description Initializes menu callbacks. ### Method void MenuCallbacks_Init() ### Parameters None ### Returns void ``` -------------------------------- ### Get titan soul from player Source: https://docs.northstar.tf/Modding/reference/respawn/titan?q= Use to obtain the titan entity associated with a player, handling both cases where the player is in a titan or not. The ternary checks player.IsTitan() and selects the appropriate method to get the titan soul. ```unknown entity soul = player.IsTitan() ? player.GetTitanSoul() : player.GetPetTitan().GetTitanSoul() // getting the titan depends on wether the player is in the titan or not ``` -------------------------------- ### ANSI escape code example for colored text Source: https://docs.northstar.tf/Modding/reference/northstar/chathooks?q= Example string showing how to use ANSI escape codes to color text red and blue. The \x1b sequence is replaced by a reserved ASCII character (referred to as ESC). ```plaintext Hello world, \x1b[31mthis text is red\x1b[0m. And \x1b[34mthis text is blue\x1b[0m. ``` -------------------------------- ### SpawnPoints_GetDropPod Source: https://docs.northstar.tf/Modding/reference/respawn/native_server/spawnpoints?q= Gets droppod spawn points. ```APIDOC ## SpawnPoints_GetDropPod ### Description Gets droppod spawn points. ### Method array ### Signature `array SpawnPoints_GetDropPod()` ### Returns - **array** - The droppod spawn points. ``` -------------------------------- ### HUD Topology example Source: https://docs.northstar.tf/Modding/reference/respawn/topology Covers the top left quadrant with a basic image. RUIs scale with topology dimensions, so correct screen size must be used. ```squirrel // Cover the top left quadrant of the screen with a basic image float[2] s = GetScreenSize() var topo = RuiTopology_CreatePlane( <0,0,0>, , <0,s[1] / 2,0>, true ) // RUIs scale with the topology they are being drawn on so make sure to use the correct dimensions RuiCreate( $"ui/basic_image.rpak", topo, RUI_DRAW_HUD, 0 ) ``` -------------------------------- ### SpawnPoints_GetTitan Source: https://docs.northstar.tf/Modding/reference/respawn/native_server/spawnpoints?q= Gets titan spawn points. ```APIDOC ## SpawnPoints_GetTitan ### Description Gets titan spawn points. ### Method array ### Signature `array SpawnPoints_GetTitan()` ### Returns - **array** - The titan spawn points. ``` -------------------------------- ### SpawnPoints_GetPilot Source: https://docs.northstar.tf/Modding/reference/respawn/native_server/spawnpoints?q= Gets pilot spawn points. ```APIDOC ## SpawnPoints_GetPilot ### Description Gets pilot spawn points. ### Method array ### Signature `array SpawnPoints_GetPilot()` ### Returns - **array** - The pilot spawn points. ``` -------------------------------- ### ClientCommandCallback_PrivateMatchLaunch Source: https://docs.northstar.tf/Modding/reference/northstar/callbacks Handles a client command to launch a private match. Returns a boolean indicating success. ```APIDOC ## ClientCommandCallback_PrivateMatchLaunch ### Description Handles a client command to launch a private match. Returns a boolean indicating success. ### Method bool ClientCommandCallback_PrivateMatchLaunch( entity player, array args ) ### Parameters - **player** (entity) - Required - The player entity. - **args** (array) - Required - The command arguments. ### Returns bool ``` -------------------------------- ### StatusEffect_GetAll Source: https://docs.northstar.tf/Modding/reference/respawn/native_server/statuseffects?q= Gets all status effects on an entity. ```APIDOC ## StatusEffect_GetAll ### Description Gets all status effects on an entity. ### Signature ```cpp array StatusEffect_GetAll( entity ent ) ``` ### Parameters - **ent** (entity) - Required - The entity to query. ### Returns - **array** - An array of status effect data. ``` -------------------------------- ### GetCriticalScaler Source: https://docs.northstar.tf/Modding/reference/respawn/native_server/damageinfo Gets the critical scaler. Server only. ```APIDOC ## GetCriticalScaler ### Description Gets the critical scaler. Server only. ### Parameters - **ent** (entity) - Required - The entity. - **damageInfo** (var) - Required - The damage info handle. ### Returns float ``` -------------------------------- ### Folder structure example: models and materials folders Source: https://docs.northstar.tf/Modding/guides/tools/VTFModding?q= Shows the required folder structure after extracting .mdl files: a 'models' folder and a 'materials' folder side by side. ```text models materials ``` -------------------------------- ### Flag Synchronization Example Source: https://docs.northstar.tf/Modding/squirrel/async Demonstrates initializing a flag, threading a ticker function, and waiting for the flag to be set to trigger a print statement. ```squirrel void function FlagExample() { FlagInit( "BombHasExploded" ) thread BombTicker() FlagWait( "BombHasExploded" ) print( "bomb just exploded" ) } void function BombTicker() { Assert( IsNewThread(), "BombTicker must be threaded off" ) wait RandomFloatRange( 3, 9 ) FlagSet( "BombHasExploded" ) } ``` -------------------------------- ### GetImpactEffectTable Source: https://docs.northstar.tf/Modding/reference/respawn/native_server/weapons?q= Gets the impact effect table for a weapon. ```APIDOC ## GetImpactEffectTable( string weapon ) ### Description Returns the impact effect table for a given weapon. ### Parameters - **weapon** (string) - Required - The weapon name. ### Returns int - The impact effect table identifier. ``` -------------------------------- ### newtable Source: https://docs.northstar.tf/Modding/squirrel/cpp_api/objectmanipulation?q= Creates a new table and pushes it onto the stack. ```APIDOC ## newtable ### Description Creates a new table and pushes it onto the stack. ### Signature `SQRESULT newtable(HSquirrelVM* sqvm)` ### Parameters - `HSquirrelVM* sqvm` - The target VM. ### Returns `SQRESULT` ``` -------------------------------- ### Create and Manipulate RUI Source: https://docs.northstar.tf/Modding/reference/respawn/rui?q= Demonstrates how to create an RUI instance, set its properties, and destroy it. ```Squirrel // To create one, do: rui = RuiCreate( $"ui/assetname.rpak", topology, drawGroup, sortKey ) // sortkey = int to prevent z-fighting. higher -> in front // You can then manipulate it using the following: RuiSetDrawGroup( rui, drawGroup ) RuiSetString( rui, argName, value ) RuiSetBool( rui, argName, value ) RuiSetInt( rui, argName, value ) RuiSetFloat( rui, argName, value ) RuiSetFloat2( rui, argName, value ) // value is a vector; only x and y are used RuiSetFloat3( rui, argName, value ) RuiSetColorAlpha( rui, argName, color, alpha ) // color is a vector // To destroy it, just do: RuiDestroy( rui ) ```