### Nanos World Server Startup Output Source: https://docs.nanos-world.com/docs/getting-started/quick-start Example output shown in the Nanos World server console after starting, indicating successful server initialization, package loading, and script execution. ```text INFO nanos world (C) Copyright nanos. All Rights Reserved. INFO Starting Server at Port: 7777. Version: 0.0.0. Map: 'default-blank-map'. INFO Loading Package 'my-awesome-package'... SCRIPT Loading some Props =D INFO Package 'my-awesome-package' loaded. INFO Loading Package 'default-blank-map'... INFO Package 'default-blank-map' loaded. ``` -------------------------------- ### Start Server with Auto-Download (Windows) Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-configuration Starts the server with configurations and enables auto-download for packages and assets if they are missing. ```bash ./NanosWorldServer.exe --name "nanos world Amazing Sandbox" --description "Awesome Sandbox Server" --map "nanos-world::TestingMap" --game_mode "sandbox" --packages "battlefield-kill-ui,ts-fireworks-tools" --port 7777 --query_port 7778 --max_players 32 --auto_download 1 --logo "https://i.imgur.com/vnB8CB5.jpg" ``` -------------------------------- ### Install Packages via CLI (Windows) Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-configuration Installs all necessary packages and assets for the server using the Windows executable. ```bash ./NanosWorldServer.exe --cli install package sandbox battlefield-kill-ui ts-fireworks-tools ``` -------------------------------- ### Start Server with Auto-Download (Linux) Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-configuration Starts the server with configurations and enables auto-download for packages and assets if they are missing using the Linux shell script. ```bash ./NanosWorldServer.sh --name "nanos world Amazing Sandbox" --description "Awesome Sandbox Server" --map "nanos-world::TestingMap" --game_mode "sandbox" --packages "battlefield-kill-ui,ts-fireworks-tools" --port 7777 --query_port 7778 --max_players 32 --auto_download 1 --logo "https://i.imgur.com/vnB8CB5.jpg" ``` -------------------------------- ### Start Development Server Source: https://docs.nanos-world.com/docs/getting-started/tutorials-and-examples/basic-hud-react Command to start the React development server, allowing you to view the HUD in your web browser. ```bash npm start ``` -------------------------------- ### Start Server with Configurations (Windows) Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-configuration Starts the server with specified configurations including name, description, map, game mode, packages, ports, player count, and logo. ```bash ./NanosWorldServer.exe --name "nanos world Amazing Sandbox" --description "Awesome Sandbox Server" --map "nanos-world::TestingMap" --game_mode "sandbox" --packages "battlefield-kill-ui,ts-fireworks-tools" --port 7777 --query_port 7778 --max_players 32 --logo "https://i.imgur.com/vnB8CB5.jpg" ``` -------------------------------- ### Subscribe to Start Event Source: https://docs.nanos-world.com/docs/scripting-reference/static-classes/server Subscribes to the 'Start' event, which is called when the server has started. ```lua Server.Subscribe("Start", function() -- Start was called end) ``` -------------------------------- ### Start Server with Configurations (Linux) Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-configuration Starts the server with specified configurations including name, description, map, game mode, packages, ports, player count, and logo using the Linux shell script. ```bash ./NanosWorldServer.sh --name "nanos world Amazing Sandbox" --description "Awesome Sandbox Server" --map "nanos-world::TestingMap" --game_mode "sandbox" --packages "battlefield-kill-ui,ts-fireworks-tools" --port 7777 --query_port 7778 --max_players 32 --logo "https://i.imgur.com/vnB8CB5.jpg" ``` -------------------------------- ### Install Packages via CLI (Linux) Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-configuration Installs all necessary packages and assets for the server using the Linux shell script. ```bash ./NanosWorldServer.sh --cli install package sandbox battlefield-kill-ui ts-fireworks-tools ``` -------------------------------- ### Get Server Packages Source: https://docs.nanos-world.com/docs/scripting-reference/static-classes/server Returns a list of packages currently running on the server. Optionally, it can return all installed packages, but this is a slow operation. ```lua local ret = Server.GetPackages(only_loaded?, package_type_filter?) ``` -------------------------------- ### Start Sound Playback Source: https://docs.nanos-world.com/docs/scripting-reference/classes/sound Starts or resumes playback of the sound from a specified start time. ```lua my_sound:Play(start_time?) ``` -------------------------------- ### One-liner Server Install (Windows, Public) Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-installation Installs or updates the Nanos World dedicated server from the public branch using a single SteamCMD command on Windows. ```bash steamcmd.exe +force_install_dir C:/nanos-world-server +login anonymous "+app_update 1936830 -beta public" validate +quit ``` -------------------------------- ### Install and Use Default Weapons Package Source: https://docs.nanos-world.com/docs/scripting-reference/classes/weapon This snippet shows how to install the 'default-weapons' package via the server CLI and then load it in a server script to spawn and give an AK47 to a character. ```bash # install the default-weapons package ./NanosWorldServer.exe --cli install package default-weapons ``` ```lua -- Loads the default-weapons (note: it's recommended to add it to your Package's packages_requirements instead) Server.LoadPackage("default-weapons") -- Spawning the AK47 from default-weapons package local my_ak47 = AK47(Vector(1035, 154, 300), Rotator()) -- Giving the Weapon to a Character my_character:PickUp(my_ak47) ``` -------------------------------- ### Start CLI in Interactive Mode (Windows) Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/command-line-interface Run the Nanos World server with the --cli argument to start the interactive command line interface on Windows. ```bash ./NanosWorldServer.exe --cli ``` -------------------------------- ### Install SteamCMD on Debian Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-installation Updates package lists, installs software-properties-common, adds the non-free repository, enables i386 architecture, and updates again for SteamCMD installation on Debian. ```bash sudo apt update; sudo apt install software-properties-common; sudo apt-add-repository non-free; sudo dpkg --add-architecture i386; sudo apt update ``` -------------------------------- ### C Module Example Implementation Source: https://docs.nanos-world.com/docs/core-concepts/packages/c-module This C code defines a function 'test' that pushes a 'Hello World' string onto the Lua stack and an 'example' library that exposes this function. It's the core of a C module for nanos world. ```c // Needed includes to reference the Lua SDK extern "C" { #include "lua.h" #include "lauxlib.h" } // Definition of your custom functions int test(lua_State *L) { // This will push 'Hello World' into the stack // Which can be obtained as the returning value from Lua lua_pushliteral(L, "Hello World"); // Amount of values returned // (lua will get our string in the stack and pass as a return value) return 1; } // Definition of your custom library extern "C" int luaopen_example (lua_State *L) { // List of all custom functions struct luaL_Reg functions[] = { {"test", test}, {NULL, NULL}, }; // Creates the library with the functions array luaL_newlib(L, functions); return 1; } ``` -------------------------------- ### One-liner Server Install (Linux, Public) Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-installation Installs or updates the Nanos World dedicated server from the public branch using a single SteamCMD command on Linux. ```bash steamcmd +force_install_dir ~/nanos-world-server +login anonymous "+app_update 1936830 -beta public" validate +quit ``` -------------------------------- ### Install SteamCMD on Ubuntu Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-installation Enables the multiverse repository, adds i386 architecture, and updates package lists for SteamCMD installation on Ubuntu. ```bash sudo add-apt-repository multiverse; sudo dpkg --add-architecture i386; sudo apt update ``` -------------------------------- ### Subscribe to Server Events Source: https://docs.nanos-world.com/docs/scripting-reference/static-classes/server This snippet demonstrates how to subscribe to the 'Start', 'Stop', and 'Tick' events of the server. Use 'Start' for initialization logic, 'Stop' for cleanup, and 'Tick' for recurring tasks, passing the delta time. ```lua -- prints "Server started" when the server is starting Server.Subscribe("Start", function() Console.Log("Server started") end) -- prints "Server stopped" when the server stops / shutdown Server.Subscribe("Stop", function() Console.Log("Server stopped") end) -- prints the delta time about every 33 ms Server.Subscribe("Tick", function(delta_time) Console.Log("Tick: " .. delta_time) end) ``` -------------------------------- ### Install ARMHF Architecture and Libraries Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-linux-arm Add the armhf architecture and install necessary libraries for Box86 compatibility on 64-bit ARM systems. ```bash sudo dpkg --add-architecture armhf sudo apt update sudo apt install libc6:armhf libncurses5:armhf libstdc++6:armhf ``` -------------------------------- ### Start CLI in Interactive Mode (Linux) Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/command-line-interface Run the Nanos World server with the --cli argument to start the interactive command line interface on Linux. ```bash ./NanosWorldServer.sh --cli ``` -------------------------------- ### Start Nanos World Server with Docker Compose Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-docker Starts the Nanos World server in detached mode using Docker Compose. Ensure the 'docker-compose.yml' file is in the current directory. ```bash docker-compose up -d ``` -------------------------------- ### Set SteamCMD Install Directory Source: https://docs.nanos-world.com/docs/getting-started/tutorials-and-examples/hosting-server-4free-gcp Configures SteamCMD to use a specific directory for installing the nanos world server files. ```steamcmd Steam> force_install_dir ./nanos-world-server ``` -------------------------------- ### Example Object Profile (Prop Placeholder) Source: https://docs.nanos-world.com/docs/assets-modding/forge/advanced/lua-profile This example illustrates formatting an object, specifically a prop placeholder, as a Lua constructor call. It maps properties like position, rotation, and asset ID to arguments of the 'Prop' Lua function. ```lua Prop(Vector(340, 720, 0), Rotator(0, 0, 0), "my-asset-pack::Cube") ``` -------------------------------- ### Install SteamCMD on Ubuntu Source: https://docs.nanos-world.com/docs/getting-started/tutorials-and-examples/hosting-server-4free-gcp Installs SteamCMD and its dependencies on an Ubuntu virtual machine. This is required to download and manage the nanos world server files. ```bash sudo add-apt-repository multiverse sudo dpkg --add-architecture i386 sudo apt update sudo apt install lib32gcc1 steamcmd ``` -------------------------------- ### Install Default Weapons Package Source: https://docs.nanos-world.com/docs/getting-started/tutorials-and-examples/fireworks Installs the default-weapons package using the Nanos World server CLI. It's recommended to add this to your package's requirements instead. ```bash ./NanosWorldServer.exe --cli install package default-weapons ``` -------------------------------- ### Define SteamCMD Installation Directory (Windows) Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-installation Sets the target directory for installing Nanos World server files on a Windows system using SteamCMD. ```bash force_install_dir C:/nanos-world-server/ ``` -------------------------------- ### Example Struct Profile (Vector as Constructor) Source: https://docs.nanos-world.com/docs/assets-modding/forge/advanced/lua-profile This example demonstrates formatting an FVector struct as a Lua constructor call. It specifies the Lua function name and the properties to be used as arguments. ```lua Vector(100.0, 200.0, 50.0) ``` -------------------------------- ### Define SteamCMD Installation Directory (Linux) Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-installation Sets the target directory for installing Nanos World server files on a Linux system using SteamCMD. ```bash force_install_dir /home//nanos-world-server/ ``` -------------------------------- ### One-liner Server Install (Windows, Bleeding-Edge) Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-installation Installs or updates the Nanos World dedicated server from the bleeding-edge branch using a single SteamCMD command on Windows. ```bash steamcmd.exe +force_install_dir C:/nanos-world-server +login anonymous "+app_update 1936830 -beta bleeding-edge" validate +quit ``` -------------------------------- ### Trigger Constructor Example Source: https://docs.nanos-world.com/docs/scripting-reference/classes/trigger This example shows the basic syntax for creating a Trigger instance using its default constructor, illustrating the parameters for location, rotation, extent, type, visibility, color, and overlap filtering. ```lua local my_trigger = Trigger(location, rotation, extent, trigger_type?, is_visible?, color?, overlap_only_classes?) ``` -------------------------------- ### One-liner Server Install (Linux, Bleeding-Edge) Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-installation Installs or updates the Nanos World dedicated server from the bleeding-edge branch using a single SteamCMD command on Linux. ```bash steamcmd +force_install_dir ~/nanos-world-server +login anonymous "+app_update 1936830 -beta bleeding-edge" validate +quit ``` -------------------------------- ### Get Attached Actor at Cable Start Source: https://docs.nanos-world.com/docs/scripting-reference/classes/cable Retrieves the actor that the start of the cable is currently attached to. Returns nil if the start is not attached. ```lua local attached_actor = my_cable:GetAttachedStartTo() ``` -------------------------------- ### Get Substring with `sub` Source: https://docs.nanos-world.com/docs/scripting-reference/standard-libraries/string Extracts a portion of a string between specified start and end positions. The end position can be negative to count from the end of the string. ```lua local ret = my_string:sub(string, StartPos, EndPos) ``` -------------------------------- ### Server.Start Event Source: https://docs.nanos-world.com/docs/scripting-reference/static-classes/server Event triggered when the server has been started. ```APIDOC ## Server.Start Event ### Description Server has been started. ### Event Handler Signature Server.Subscribe("Start", function()) ``` -------------------------------- ### Make Server Script Executable and Run Source: https://docs.nanos-world.com/docs/getting-started/tutorials-and-examples/hosting-server-4free-gcp Grants execute permissions to the server startup script and then runs it to start the nanos world server. ```bash chmod +x ./NanosWorldServer.sh ./NanosWorldServer.sh ``` -------------------------------- ### Example Server Configuration File Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-configuration This TOML file outlines the complete server configuration, covering network settings, player limits, game modes, asset loading, debugging options, and network optimization parameters. ```toml # discover configurations [discover] # server name name = "nanos world server" # server description (max 200 characters) description = "" # language (country code) language = "global" # server IP - we recommend leaving it 0.0.0.0 for default ip = "0.0.0.0" # server port (TCP and UDP) port = 7777 # query port (UDP) query_port = 7778 # announce server in the master server list announce = true # true if should run as dedicated server or false to run as P2P - dedicated server requires port forwarding and provides the fastest connection - P2P will provide a fake IP to be used to connect but connection can be slower as it uses Steam Datagram Relay service dedicated_server = true # general configurations [general] # max players max_players = 64 # leave it blank for no password password = "" # nanos world server authentication token token = "" # banned nanos account IDs banned_ids = [ ] # game configurations [game] # default startup map map = "default-blank-map" # game-mode package to load (set the main game-mode package to load - you can load only one 'game-mode' package type at once) game_mode = "" # packages list (set the packages you want to load) packages = [ ] # asset packs list (additionally loads the asset packs you define here) assets = [ ] # loading-screen package to load (the loading screen will be displayed when players join your server) loading_screen = "" # custom settings values # those values can be accessed through Server.GetCustomSettings() method from any package [custom_settings] # my_setting_01 = "value" # my_setting_02 = 123 # debug configurations [debug] # log Level - (1) normal, (2) debug or (3) verbose log_level = 1 # if to use async or sync logs (async provides better performance, disabling async logs can help debugging crashes) async_log = true # enables performance profiling logs for debugging profiling = false # optimization configurations [optimization] # server max tick rate in Hz (ticks per second) - higher is more responsive but uses more CPU - 30 Hz = 33ms per tick (default and recommended) - use with caution max_tick_rate = 30 # max sync rate in Hz (syncs per second) (1 - 30) - controls the location/rotation/velocity actors synchronization rate from and to players - naturally limited by the tick rate max_sync_rate = 30 # max network send rate per client in KB/s (128 - 16.384) - recommended setting to the lowest needed value as higher rates may negatively impact the server performance when having players with bad connections - this only affects Dedicated Servers as P2P is naturally limited to 1.024 KB/s by Steam Datagram Relay service max_send_rate = 512 # max file transfer rate per client in KB/s (128 - max_send_rate) - limits file transfer bandwidth for each connected player - this will be limited by 'max_send_rate' setting max_file_transfer_rate = 512 # compression level to use in some networking operations (0 - 9) - (0) disables it, (1) is the fastest and already provides a good compression, (9) is the slowest but has the highest compression ratio compression = 1 # distance optimization level to improve network usage by reducing sync from distant actors (0 - 9) - (0) disables it, (4) is a good middle term, (9) is the most aggressive distance_optimization = 4 ``` -------------------------------- ### Detach Cable Start Source: https://docs.nanos-world.com/docs/scripting-reference/classes/cable Detaches the start of the cable from its current attachment. ```lua my_cable:DetachStart() ``` -------------------------------- ### Spawn and Configure a Decal Source: https://docs.nanos-world.com/docs/scripting-reference/classes/decal This example demonstrates how to spawn a new Decal on the client side, specifying its location, rotation, material, size, lifespan, and fade screen size. It also shows how to set a texture parameter for the decal's material. ```lua local my_decal = Decal( Vector(100, 200, 0), -- location Rotator(0, 90, 90), -- rotation "nanos-world::M_Default_Translucent_Lit_Decal", -- material Vector(128, 256, 256), -- size 60, -- lifespan 0.01 -- fade screen size ) my_decal:SetMaterialTextureParameter("Texture", "package://my_package/Client/image.jpg") ``` -------------------------------- ### Example Struct Profile (Transform as Table) Source: https://docs.nanos-world.com/docs/assets-modding/forge/advanced/lua-profile This example shows how to format an FTransform struct as a Lua table. It maps the struct's properties (Location, Rotation, Scale) to corresponding Lua values, which can themselves be constructor calls. ```lua { Location = Vector(100.0, 200.0, 50.0), Rotation = Rotator(0.0, 90.0, 0.0), Scale = Vector(1.0, 1.0, 1.0) } ``` -------------------------------- ### Quat Constructor Example Source: https://docs.nanos-world.com/docs/scripting-reference/structs/quat Shows the basic syntax for constructing a Quat object with optional components. ```lua local my_quat = Quat(X?, Y?, Z?, W?) ``` -------------------------------- ### Play Source: https://docs.nanos-world.com/docs/scripting-reference/classes/sound Starts or resumes playback of the sound. Optionally, you can specify a start time. ```APIDOC ## Play ### Description Starts the sound. ### Method Signature `my_sound:Play(start_time?) ### Parameters #### Parameters - **`start_time`** (float) - Optional - The time at which to start playback (default is 0.0). ``` -------------------------------- ### Install SteamCMD Package Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-installation Installs the SteamCMD package on Debian-based systems after repository configuration. ```bash sudo apt install steamcmd ``` -------------------------------- ### WebUI Constructor Example Source: https://docs.nanos-world.com/docs/scripting-reference/classes/web-ui Illustrates the basic constructor for the WebUI class, showing the required and optional parameters for initializing a WebUI instance. ```lua local my_webui = WebUI(name, path, visibility?, is_transparent?, auto_resize?, width?, height?) ``` -------------------------------- ### Creating and Attaching a Cable Source: https://docs.nanos-world.com/docs/scripting-reference/classes/cable This example demonstrates how to create a Cable instance and attach it between two Prop actors. Ensure the 'nanos-world::SM_Cube' asset is available. ```lua local my_cable = Cable(Vector()) local cube_01 = Prop(Vector(100, 100, 100), Rotator(), "nanos-world::SM_Cube") local cube_02 = Prop(Vector(200, 0, 100), Rotator(), "nanos-world::SM_Cube") my_cable:AttachStartTo(cube_01) my_cable:AttachEndTo(cube_02) ``` -------------------------------- ### Start Nanos World Server (Windows) Source: https://docs.nanos-world.com/docs/getting-started/quick-start Launch the Nanos World server on Windows by double-clicking the executable or running it from the terminal. ```bash ./NanosWorldServer.exe ``` -------------------------------- ### Get Rotator Representation of Quaternion Source: https://docs.nanos-world.com/docs/scripting-reference/structs/quat Demonstrates how to get the Rotator representation of a Quat. The result is stored in a local variable. ```lua local ret = my_quat:Rotator() ``` -------------------------------- ### Reading and Parsing a Configuration File Source: https://docs.nanos-world.com/docs/scripting-reference/classes/file Demonstrates how to create a File object for a configuration file and read its content, then parse it as JSON. Paths are relative to the server executable. ```lua local configuration_file = File("my_awesome_configuration.json") local configuration_file_json = JSON.parse(configuration_file:Read()) ``` -------------------------------- ### Get Current Text Source: https://docs.nanos-world.com/docs/scripting-reference/classes/text-render Retrieves the current text content. Use this to get the text string currently displayed. ```lua local text = my_textrender:GetText() ``` -------------------------------- ### Show and Hide Tutorials UI Source: https://docs.nanos-world.com/docs/explore/sandbox-game-mode/extra-features Use these functions to display and dismiss the Tutorials UI, which can show a title, description, and key bindings. ```lua -- Shows the Tutorials UI ---@param title string Tutorials title ---@param description string Description ---@param keys_data table Table of keys in the format ---@ { { key = "KeyName", description = "What it does" }, ... } function Sandbox.Tutorials.Show(title, description, keys_data) -- Hides the Tutorials UI function Sandbox.Tutorials.Hide() ``` -------------------------------- ### Get Vector Size Squared Source: https://docs.nanos-world.com/docs/scripting-reference/structs/vector Use `SizeSquared` to get the squared length of a vector. This can be more efficient than `Size` if only comparing magnitudes. ```lua local ret = my_vector:SizeSquared() ``` -------------------------------- ### Create and Draw on a Canvas Source: https://docs.nanos-world.com/docs/scripting-reference/classes/canvas This example demonstrates how to spawn a Canvas, subscribe to its 'Update' event to perform drawing operations like text and lines, and then apply the canvas to a prop. The 'Update' event is crucial for drawing and is triggered by 'Repaint'. ```lua -- Spawns a Canvas local my_canvas = Canvas( true, Color.TRANSPARENT, 0, true ) -- Subscribes for Update, we can only Draw inside this event my_canvas:Subscribe("Update", function(self, width, height) -- Draws a Text in the middle of the screen self:DrawText("Hello World!", Vector2D(width / 2, height / 2)) -- Draws a red line Horizontally self:DrawLine(Vector2D(0, height / 2), Vector2D(width, height / 2), 10, Color.RED) end) -- Forces the canvas to repaint, this will make it trigger the Update event my_canvas:Repaint() -- Applies the Canvas material into a Prop any_prop:SetMaterialFromCanvas(my_canvas) ``` -------------------------------- ### Start Nanos World Server (Linux) Source: https://docs.nanos-world.com/docs/getting-started/quick-start Launch the Nanos World server on Linux by running the script from the terminal. ```bash ./NanosWorldServer.sh ``` -------------------------------- ### Configure Auto Engine Start Source: https://docs.nanos-world.com/docs/scripting-reference/classes/vehicle-wheeled Determines if the vehicle's engine should automatically start when a driver enters. The `auto_start` parameter is required. ```lua my_vehiclewheeled:SetAutoStartEngine(auto_start) ``` -------------------------------- ### Connect to SQLite, Create Table, Insert, and Select Data Source: https://docs.nanos-world.com/docs/scripting-reference/classes/database Demonstrates creating a SQLite database connection, defining a table, inserting values, and selecting data with and without filters. ```lua -- Creates a SQLite connection, using a local file called 'database_filename.db' local sqlite_db = Database(DatabaseEngine.SQLite, "db=database_filename.db timeout=2") -- Creates a table sqlite_db:Execute([[ CREATE TABLE IF NOT EXISTS test ( id INTEGER, name VARCHAR(100) ) ]]) -- Insert values in the table local affected_rows = sqlite_db:Execute("INSERT INTO test VALUES (1, 'amazing')") Console.Log("Affected Rows: " .. tostring(affected_rows)) -- Will output: 1 -- Selects the data local rows = sqlite_db:Select("SELECT * FROM test") Console.Log(NanosTable.Dump(rows)) -- Will output a table with all data from 'test' -- Selects the data with filter local rows_filter = sqlite_db:Select("SELECT * FROM test WHERE name = :0", "amazing") Console.Log(NanosTable.Dump(rows_filter)) -- Will output a table with all data from 'test' where name matches 'amazing' ``` -------------------------------- ### Get Unix Epoch Time Source: https://docs.nanos-world.com/docs/scripting-reference/static-classes/client Gets the current Unix Epoch Time in milliseconds. This provides a high-resolution timestamp for events or calculations. ```lua local ret = Client.GetTime() ``` -------------------------------- ### Install libstdc++6 from Testing Repository Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-linux-arm Install the libstdc++6 package specifically from the testing repository to resolve compatibility issues on older Debian systems. ```bash sudo apt-get --target-release testing install libstdc++6 ``` -------------------------------- ### File Constructor Example Source: https://docs.nanos-world.com/docs/scripting-reference/classes/file Illustrates the basic usage of the File constructor, which takes a file path and an optional truncate flag. The path's relativity depends on whether it's used on the client or server. ```lua local my_file = File(file_path, truncate?) ``` -------------------------------- ### Get Key Code by Name Source: https://docs.nanos-world.com/docs/scripting-reference/static-classes/input Gets the integer key code associated with a given key name. This is useful for low-level input handling. ```lua local ret = Input.GetKeyCode(key_name) ``` -------------------------------- ### Loading WebUI Content Source: https://docs.nanos-world.com/docs/scripting-reference/classes/web-ui Demonstrates how to spawn a WebUI by loading local HTML files from the current or other packages, or by loading a remote web URL. ```lua -- Loading a local file local my_ui = WebUI( "Awesome UI", -- Name "file://UI/index.html", -- Path relative to this package (Client/) WidgetVisibility.Visible -- Is Visible on Screen ) -- Loading a Web URL local my_browser = WebUI( "Awesome Site", -- Name "https://nanos-world.com", -- Web's URL WidgetVisibility.Visible -- Is Visible on Screen ) -- Loading a local file from other package local my_ui = WebUI( "Awesome Other UI", -- Name "file://other-package/Client/UI/index.html", WidgetVisibility.Visible -- Is Visible on Screen ) ``` -------------------------------- ### Sound Constructor with All Parameters Source: https://docs.nanos-world.com/docs/scripting-reference/classes/sound Demonstrates the full signature of the Sound constructor, including optional parameters for location, asset, 2D/3D status, auto-destroy, sound type, volume, pitch, and 3D-specific properties like radius, falloff, and loop mode. ```lua local my_sound = Sound(location, asset, is_2D_sound?, auto_destroy?, sound_type?, volume?, pitch?, inner_radius?, falloff_distance?, attenuation_function?, keep_playing_when_silent?, loop_mode?, auto_play?) ``` -------------------------------- ### Get Current Word Size Source: https://docs.nanos-world.com/docs/scripting-reference/classes/text-render Retrieves the current size of the words in the text. Use this to get the float value representing the word size. ```lua local word_size = my_textrender:GetWordSize() ``` -------------------------------- ### Get Current Text Color Source: https://docs.nanos-world.com/docs/scripting-reference/classes/text-render Retrieves the current color of the text. Use this to get the Color object representing the text's color. ```lua local text_color = my_textrender:GetTextColor() ``` -------------------------------- ### Spawn Widget3D from Widget Source: https://docs.nanos-world.com/docs/scripting-reference/classes/widget-3d Demonstrates how to spawn a Widget3D from an existing Widget instance on the client side. ```lua -- Spawns a Widget local my_text = Widget(NativeWidget.Text) my_text:CallBlueprintEvent("SetText", "Hello World!") -- Spawns the Widget3D directly from a Widget local my_widget_3d = my_text:SpawnWidget3D() ``` -------------------------------- ### Set Engine State Source: https://docs.nanos-world.com/docs/scripting-reference/classes/vehicle-wheeled Manually starts or stops the vehicle's engine. This affects lights, sounds, and the ability to accelerate. The `started` parameter is required. ```lua my_vehiclewheeled:SetEngineStarted(started) ``` -------------------------------- ### Client/Server Synchronization Example Source: https://docs.nanos-world.com/docs/core-concepts/scripting/inheriting-classes Illustrates how to define an entity class on both the client and server sides to ensure synchronized behavior. The 'Spawn' event is logged on the server. ```lua MyNewClass = Prop.Inherit("MyNewClass") MyNewClass.Subscribe("Spawn", function(self) -- It was spawned on server and will spawn on Client as a MyNewClass properly Console.Log("Spawned MyNewClass: %s", tostring(self)) end) -- Will output: -- Spawned MyNewClass: MyNewClass ``` -------------------------------- ### Interactive Object Transformation with Gizmo Source: https://docs.nanos-world.com/docs/scripting-reference/classes/gizmo This example demonstrates how to spawn a mesh, activate a Gizmo to transform it, and handle mouse input to control the Gizmo's interaction. It requires disabling default input and enabling the mouse cursor. ```lua -- Disable input and enable mouse cursor Input.SetInputEnabled(false) Input.SetMouseEnabled(true) -- Spawn a mesh to interact with local my_entity = StaticMesh(Vector(0, 0, 100), Rotator(), "nanos-world::SM_Cube") -- Spawn the gizmo local my_gizmo = Gizmo() -- Activate the gizmo, at the location of the mesh my_gizmo:Activate(my_entity:GetLocation(), my_entity:GetRotation(), my_entity:GetScale()) -- Subscribes on Gizmo updates my_gizmo:Subscribe("Transform", function(self, location, rotation, scale) my_entity:TranslateTo(location, 0.02) my_entity:RotateTo(rotation, 0.02) my_entity:SetScale(scale) end) -- When Mouse click, trigger Gizmo inputs Input.Subscribe("MouseDown", function(key) if (key == "LeftMouseButton") then my_gizmo:PressPointer() end end) -- When Mouse release, trigger Gizmo inputs Input.Subscribe("MouseUp", function (key, b, c) if (key == "LeftMouseButton") then my_gizmo:ReleasePointer() end end) ``` -------------------------------- ### Create a Basic Text3D Object Source: https://docs.nanos-world.com/docs/scripting-reference/classes/text-3d This example demonstrates how to create a Text3D object with essential parameters like location, text content, scale, color, font, and camera alignment. It's useful for displaying dynamic 3D text in the game world. ```lua local my_text_3d = Text3D( Vector(-100, 200, 300), Rotator(), "My Awesome Text", Vector(1, 1, 1), -- Scale Color(1, 0, 0), -- Red Color FontType.OpenSans, Text3DAlignCamera.FaceCamera ) ``` -------------------------------- ### Package Folder Structure Example Source: https://docs.nanos-world.com/docs/core-concepts/packages/packages-guide Illustrates the typical directory layout for a Nanos World package, including Server, Client, Shared folders, and the Package.toml configuration file. ```toml NanosWorldServer.exe Packages/ ├── my-package-01/ │ ├── Server/ │ │ ├── Index.lua │ │ └── *.lua │ ├── Client/ │ │ └── *.lua │ ├── Shared/ │ │ └── *.lua │ └── Package.toml ├── my-package-02/ │ ├── Package.toml │ └── ... ├── my-package-loading-screen-01/ │ ├── Index.html │ ├── Package.toml │ └── ... Assets/ Config.toml ``` -------------------------------- ### Install Nanos World Server (Public Branch) Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-installation Downloads and validates the Nanos World dedicated server files from the public branch using SteamCMD. ```bash app_update 1936830 validate ``` -------------------------------- ### Spawning and Configuring a VehicleWheeled Source: https://docs.nanos-world.com/docs/scripting-reference/classes/vehicle-wheeled This example demonstrates how to spawn a VehicleWheeled, configure its engine, aerodynamics, steering wheel, headlights, wheels, and doors. It's crucial to call RecreatePhysics() after setting up the vehicle's components for optimal performance. ```lua -- Spawns a Pickup Vehicle local vehicle = VehicleWheeled(location or Vector(), rotation or Rotator(), "nanos-world::SK_Pickup", CollisionType.Normal, true, false, true, "nanos-world::A_Vehicle_Engine_10") -- Configure it's Engine power and Aerodynamics vehicle:SetEngineSetup(700, 5000) vehicle:SetAerodynamicsSetup(2500) -- Configure it's Steering Wheel and Headlights location vehicle:SetSteeringWheelSetup(Vector(0, 27, 120), 24) vehicle:SetHeadlightsSetup(Vector(270, 0, 70)) -- Configures each Wheel vehicle:SetWheel(0, "Wheel_Front_Left", 27, 18, 45, Vector(), true, true, false, false, false, 1500, 3000, 1000, 1, 3, 20, 20, 250, 50, 10, 10, 0, 0.5, 0.5) vehicle:SetWheel(1, "Wheel_Front_Right", 27, 18, 45, Vector(), true, true, false, false, false, 1500, 3000, 1000, 1, 3, 20, 20, 250, 50, 10, 10, 0, 0.5, 0.5) vehicle:SetWheel(2, "Wheel_Rear_Left", 27, 18, 0, Vector(), false, true, true, false, false, 1500, 3000, 1000, 1, 4, 20, 20, 250, 50, 10, 10, 0, 0.5, 0.5) vehicle:SetWheel(3, "Wheel_Rear_Right", 27, 18, 0, Vector(), false, true, true, false, false, 1500, 3000, 1000, 1, 4, 20, 20, 250, 50, 10, 10, 0, 0.5, 0.5) -- Adds 6 Doors/Seats vehicle:SetDoor(0, Vector( 50, -75, 105), Vector( 8, -32.5, 95), Rotator(0, 0, 10), 70, -150) vehicle:SetDoor(1, Vector( 50, 75, 105), Vector( 25, 50, 90), Rotator(0, 0, 0), 70, 150) vehicle:SetDoor(2, Vector( -90, -75, 130), Vector( -90, -115, 155), Rotator(0, 90, 20), 60, -150) vehicle:SetDoor(3, Vector( -90, 75, 130), Vector( -90, 115, 155), Rotator(0, -90, 20), 60, 150) vehicle:SetDoor(4, Vector(-195, -75, 130), Vector(-195, -115, 155), Rotator(0, 90, 20), 60, -150) vehicle:SetDoor(5, Vector(-195, 75, 130), Vector(-195, 115, 155), Rotator(0, -90, 20), 60, 150) -- Make it ready (so clients only create Physics once and not for each function call above) vehicle:RecreatePhysics() ``` -------------------------------- ### Spawn Light and StaticMesh Entities Source: https://docs.nanos-world.com/docs/getting-started/essential-concepts Demonstrates how to spawn a Light and a StaticMesh entity in the game world by providing their initial position, rotation, and properties. ```lua local my_light = Light(Vector(0, 100, 100), Rotator(), Color.RED) local my_static_mesh = StaticMesh(Vector(0, 0, 100), Rotator(), "nanos-world::SM_Cube_VR_01") ``` -------------------------------- ### Server Assets Folder Structure Example Source: https://docs.nanos-world.com/docs/core-concepts/assets Illustrates the typical directory structure for an Asset Pack within a nanos world server's `Assets/` directory. Each Asset Pack folder contains exported Unreal Engine assets and an `Assets.toml` configuration file. ```text NanosWorldServer.exe Assets/ ├── my-asset-pack-01/ │ ├── MyAssetPack01/ │ │ ├── MyProp.uasset │ │ ├── MyProp.ubulk │ │ ├── MyProp.uexp │ │ ├── MyBigMap.umap │ │ ... │ └── Assets.toml ├── awesome-weapons/ │ ├── MyWeapons/ │ │ ├── BigFuckingGun.uasset │ │ ... │ └── Assets.toml Packages/ Config.toml ``` -------------------------------- ### Creating a Directory Source: https://docs.nanos-world.com/docs/scripting-reference/classes/file Shows how to use the static CreateDirectory function to create a new directory. This function returns a boolean indicating success. ```lua local ret = File.CreateDirectory(path) ``` -------------------------------- ### Get Inherited Classes Source: https://docs.nanos-world.com/docs/scripting-reference/classes/base-classes/entity Retrieves a list of all classes that directly inherit from the current class. This can be used to understand the class hierarchy. The 'recursively' parameter can be set to true to get all descendants. ```lua local ret = Entity.GetInheritedClasses(recursively?) ``` -------------------------------- ### Create and Apply SceneCapture to a Prop Source: https://docs.nanos-world.com/docs/scripting-reference/classes/scene-capture This example demonstrates how to create a SceneCapture actor and then use its output to set the material of a Prop. Ensure the SceneCapture is spawned on the client. ```lua local scene_capture = SceneCapture( Vector(0, 0, 200), Rotator(-15, 0, 0), 256, 256, 0, 5000, 100 ) -- Paints the Prop with the SceneCapture output local my_prop = Prop(Vector(200, 200, 100), Rotator(), "nanos-world::SM_Cube") my_prop:SetMaterialFromSceneCapture(scene_capture) ``` -------------------------------- ### Build React Application Source: https://docs.nanos-world.com/docs/getting-started/tutorials-and-examples/basic-hud-react Execute this command in your React app's root folder to build the application for deployment. The output will be in the ./build folder. ```bash npm run build ``` -------------------------------- ### Client: Initialize Variables and Set Highlight Color Source: https://docs.nanos-world.com/docs/getting-started/tutorials-and-examples/gravity-gun Initializes global variables for object tracking and sets a custom highlight color for objects. This code runs on the client side. ```lua -- Global Variables picking_object = nil distance_trace_object = nil distance = 200 -- Sets the color of Highlighing at index 1 Client.SetHighlightColor(Color(0, 20, 20, 1.5), 1, HighlightMode.OnlyVisible) ``` -------------------------------- ### AttachStartTo Source: https://docs.nanos-world.com/docs/scripting-reference/classes/cable Attaches the beginning of this cable to another Actor at a specific bone or relative location. It's recommended to attach the start first if you wish to attach both start and end, to avoid double calculations. ```APIDOC ## AttachStartTo ### Description Attaches the beginning of this cable to another Actor at a specific bone or relative location. For optimization, it is recommended attaching start first if you wish to attach both start and end, to avoid double calculations. Returns boolean (if it was attached successfully). ### Method Signature `my_cable:AttachStartTo(other, relative_location?, bone_name?) ### Parameters #### Path Parameters - **other** (Base Actor) - Required - No description provided - **relative_location** (Vector) - Optional - Default: `Vector(0, 0, 0)` - No description provided - **bone_name** (string) - Optional - Default: `""` - Which bone to attach to. If empty, it will be attached to the Actor, otherwise to the Mesh at the bone/socket. ``` -------------------------------- ### Install nanos world Server using SteamCMD Source: https://docs.nanos-world.com/docs/getting-started/tutorials-and-examples/hosting-server-4free-gcp Downloads and installs the nanos world server files using SteamCMD. The app ID 1936830 is specific to the nanos world dedicated server. ```steamcmd Steam> app_update 1936830 ``` -------------------------------- ### Create React App Source: https://docs.nanos-world.com/docs/getting-started/tutorials-and-examples/basic-hud-react Use npx to create a new React application for your UI. This command initializes a project with the necessary structure and dependencies. ```bash npx create-react-app basic-hud ``` -------------------------------- ### Using Default Asset Pack Key Source: https://docs.nanos-world.com/docs/assets-modding/default-asset-pack/default-assets-list Demonstrates the syntax for referencing assets from the default asset pack. This key is required to access any asset within the pack. ```text nanos-world::SM_Cube ``` -------------------------------- ### Attach Cable Start to Actor Source: https://docs.nanos-world.com/docs/scripting-reference/classes/cable Attaches the beginning of a cable to another actor at a specified bone or relative location. It's recommended to attach the start first if both ends will be attached, to prevent redundant calculations. ```lua local attached_successfully = my_cable:AttachStartTo(other, relative_location?, bone_name?) ``` -------------------------------- ### Nanos World CLI Help Output Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/command-line-interface Display available commands in the Nanos World CLI by typing 'help' after starting the interactive mode. ```text INFO Starting nanos world CLI - Command Line Interface (beta) nanos world cli> help INFO Available commands: - stop - help - update [package|assets] NAME1, NAME2... - install [package|assets] NAME1, NAME2... - upload [package|assets] NAME - add [package|assets] NAME - check nanos world cli> ``` -------------------------------- ### Install Nanos World Server (Bleeding-Edge Branch) Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/server-installation Downloads and validates the Nanos World dedicated server files from the bleeding-edge beta branch using SteamCMD. ```bash app_update 1936830 -beta bleeding-edge validate ``` -------------------------------- ### Install/Update Multiple Packages/Assets Source: https://docs.nanos-world.com/docs/core-concepts/server-manual/command-line-interface Install or update multiple packages or assets in a single command by separating their names with spaces. ```bash install package sandbox battlefield-kill-ui ``` -------------------------------- ### DetachStart Source: https://docs.nanos-world.com/docs/scripting-reference/classes/cable Detaches the start of this cable. ```APIDOC ## DetachStart ### Description Detaches the Start of this Cable. ### Method Signature `my_cable:DetachStart()` ``` -------------------------------- ### Using WebUI as a Mesh Material Source: https://docs.nanos-world.com/docs/scripting-reference/classes/web-ui Shows how to spawn a WebUI with specific properties and then use it as a material for a StaticMesh, allowing the WebUI content to be rendered on the mesh. ```lua -- Spawns a WebUI with is_visible = false, is_transparent = false, auto_resize = false and size of 500x500 local my_ui = WebUI("Awesome Site", "https://nanos-world.com", false, false, false, 500, 500) -- Spawns a StaticMesh (can be any mesh) local static_mesh = StaticMesh(Vector(0, 0, 100), Rotator(), "nanos-world::SM_Cube") -- Sets the mesh material to use the WebUI static_mesh:SetMaterialFromWebUI(my_ui) ``` -------------------------------- ### GetRPM Source: https://docs.nanos-world.com/docs/scripting-reference/classes/vehicle-wheeled Gets the current RPM. ```APIDOC ## GetRPM ### Description Gets the current RPM. ### Method Not specified (assumed to be a function call within the scripting environment). ### Endpoint Not applicable. ### Parameters None explicitly documented. ### Request Example ```lua local currentRPM = vehicle.GetRPM() ``` ### Response #### Success Response - **Name** (integer) - Description not specified. - **Description** (string) - Description not specified. ``` -------------------------------- ### GetGear Source: https://docs.nanos-world.com/docs/scripting-reference/classes/vehicle-wheeled Gets the current Gear. ```APIDOC ## GetGear ### Description Gets the current Gear. ### Method Not specified (assumed to be a function call within the scripting environment). ### Endpoint Not applicable. ### Parameters None explicitly documented. ### Request Example ```lua local currentGear = vehicle.GetGear() ``` ### Response #### Success Response - **Name** (integer) - Description not specified. - **Description** (string) - Description not specified. ``` -------------------------------- ### Add a New Package using CLI (Windows) Source: https://docs.nanos-world.com/docs/getting-started/quick-start Use the NanosWorldServer.exe CLI tool to add a new package to your server. This command initiates an interactive process to define your package's name, author, and type. ```bash ./NanosWorldServer.exe --cli add package my-awesome-package ``` -------------------------------- ### GetName Source: https://docs.nanos-world.com/docs/scripting-reference/classes/web-ui Gets the name of this WebUI. ```APIDOC ## GetName ### Description Gets this WebUI name. ### Method None (Method is called on the object instance) ### Endpoint None ### Parameters None ### Request Example ```lua local name = my_webui:GetName() ``` ### Response #### Success Response (200) - **name** (string) - The name of the WebUI. ``` -------------------------------- ### GetText Source: https://docs.nanos-world.com/docs/scripting-reference/classes/text-render Gets the current Text. ```APIDOC ## GetText ### Description Gets the current Text. ### Method (Not specified, likely a function call) ### Returns * **text** (string) - The current text. ``` -------------------------------- ### IsBoneHidden Source: https://docs.nanos-world.com/docs/scripting-reference/classes/base-classes/pawn Gets if a bone is hidden. ```APIDOC ## IsBoneHidden ### Description Gets if a bone is hidden. ### Method `IsBoneHidden(bone_name) ### Parameters #### Path Parameters - **bone_name** (string) - Required - Bone to check ### Returns - boolean (if the bone is hidden). ### See Also UnHideBone, HideBone ``` -------------------------------- ### GetPlayer Source: https://docs.nanos-world.com/docs/scripting-reference/classes/base-classes/pawn Gets the possessing Player. ```APIDOC ## GetPlayer ### Description Gets the possessing Player. ### Returns - Player or nil (possesser). ### See Also Possess, UnPossess ```