Preprocessor directives

List of preprocessor directives

List

--@autoupdate path Marks the entity to automatically update its files.
--@class classes Sets what type of entity is allowed to run this script.
--@dependency steamID, path, modifier, mode Add a dependency on a shared file or folder.
--@highres  Sets whether the screen should be high resolution.
--@include path Mark a file to be included in the upload.
--@includeasync path Mark a file to be included in the upload but not downloaded to clients until executed by require() or dofile().
--@includedir path Mark a folder to be included in the upload.
--@includedirasync path Mark a folder to be included in the upload but not downloaded to clients until each file is executed by require() or dofile().
--@includesv path Mark a file to be included in the upload, but not sent to clients for download.
--@mainfile  Marks the script as only runnable as the main file.
--@model path Sets the model of a processor entity only.
--@name name Set the name of the script.
--@precache paths Precaches a sound or model file.
--@require path Mark a file to be included in the upload and then required on both the server and the client.
--@requirecl path Mark a file to be included in the upload and then required on the client only.
--@requiresv path Mark a file to be included in the upload and then required on the server only.
--@resolution width, height Sets the screen resolution in pixels.
--@shared  For screens, HUDs and emitters, make the script run on the server alongside the client.
--@updater steamID Sets the Steam ID of the shared area folder to check for updates against.
--@widescreen  Sets whether the screen should be widescreen.


--@autoupdate path
Marks the entity to automatically update its files. If --@updater is set, the newest version in the shared area will be used both after spawning normally and from the duplicator if it is available (with read access). Otherwise, the newest version stored in the owner's local files will be used.

Parameters:

  • path: An optional path to the file in the shared area that this file should be updated with on upload. This can be used to create a local alias for a shared file at a different path.
--@class classes
Sets what type of entity is allowed to run this script. Attempting to spawn the script on an entity that is not in the list will result in an error message. Valid classes are: processor, screen, hud, emitter. In addition, if the value is set to "none", the script will be blocked from spawning with any type. This can be useful for library files.

Parameters:

  • classes: A list of comma separated classes to allow to run this script.

Usage:

    --@class screen, hud
--@dependency steamID, path, modifier, mode
Add a dependency on a shared file or folder. Files will be pulled in from the shared area belonging to the specified Steam ID, or your own if no Steam ID is given. Note that if you do not have permission to read a file, you'll get an error. When requesting folders, only 'async' and 'sv' are applicable to configure how the files are networked, all files must be manually executed. Also note that folders are not included recursively.

Parameters:

  • steamID: Steam ID whose shared folder the file/folder should be pulled from.
  • path: The path to the file/folder you want to include.
  • modifier: Optional modifier to determine how a file is loaded or a folder's files are networked. One of 'sv', 'sh', 'cl' or 'async' for server auto-require, shared auto-require, client auto-require and asynchronous include respectively.
  • mode: Optional mode to resolve the dependency with. Specify 'dev' to first attempt to load a local file with the given name. By default, local files are ignored.

Usage:

    --@dependency lib/myServerLibrary.txt sv 
    --@dependency STEAM_0:0:1234 lib/theirUsefulLib.txt sh 
    --@dependency coolstuff/requiredlater.txt 
    --@dependency morestuff/in/a/folder sv 
    --@dependency secret/example.txt async dev 
     
    -- lib/myServerLibrary.txt is loaded on the server 
    -- lib/theirUsefulLib.txt is loaded shared from STEAM_0:0:1234's shared folder. 
    -- coolstuff/requiredlater.txt is included but not loaded yet. 
    -- All files directly inside 'morestuff/in/a/folder' are included on the server only, but not loaded. 
    -- secret/example.txt is included but not downloaded by clients until required, and will be uploaded from local 
    -- files if available. 
    if SERVER then 
    	require( "coolstuff/requiredlater.txt" ) 
    elseif ents.owner() == ents.player() then 
    	require( "secret/example.txt" ) 
    end
--@highres 
Sets whether the screen should be high resolution. High resolution screens are 1024 x 1024, while normal resolution screens are 512 x 512.
--@include path
Mark a file to be included in the upload. This is required to use the file in require() and dofile()

Parameters:

  • path: Path to the file.

Usage:

    --@include lib/someLibrary.txt 
     
    require( "lib/someLibrary.txt" ) 
    -- CODE
--@includeasync path
Mark a file to be included in the upload but not downloaded to clients until executed by require() or dofile().

Parameters:

  • path: Path to the file.

Usage:

    --@includeasync example.txt 
     
    if ents.player() == ents.owner() then 
    	print( time.curTime(), "Loading example file asynchronously..." ) 
     
    	-- This will yield until the file has been downloaded. 
    	require( "example.txt" ) 
     
    	print( time.curTime(), "Example file loaded." ) 
    end 
    -- CODE
--@includedir path
Mark a folder to be included in the upload. This is not recursive.

Parameters:

  • path: Path to the folder.

Usage:

    --@includedir lib 
     
    require( "lib/someLibrary.txt" ) 
    require( "lib/someOtherLibrary.txt" ) 
    -- CODE
--@includedirasync path
Mark a folder to be included in the upload but not downloaded to clients until each file is executed by require() or dofile(). This is not recursive.

Parameters:

  • path: Path to the folder.

Usage:

    --@includedirasync lib 
     
    if ents.player() == ents.owner() then 
    	require( "lib/someLibrary.txt" ) 
    	require( "lib/someOtherLibrary.txt" ) 
    end 
    -- CODE
--@includesv path
Mark a file to be included in the upload, but not sent to clients for download. Use this for files that will only be used on the server.

Parameters:

  • path: Path to the file.

Usage:

    --@includesv lib/someLibrary.txt 
    if SERVER then 
    	require( "lib/someLibrary.txt" ) 
    end 
    -- CODE
--@mainfile 
Marks the script as only runnable as the main file. Any instance attempting to load with this script as an include rather than the main script will error before running.

Usage:

    --@mainfile 
    -- This can only be executing if the file is the mainfile. 
    assert( _MAINFILE == starfall.getMainFileName() )
--@model path
Sets the model of a processor entity only.

Parameters:

  • path: Path of the model to use.

Usage:

    --@model models/props_borealis/bluebarrel001.mdl
--@name name
Set the name of the script. This will become the name of the tab and will show on the overlay of the processor

Parameters:

  • name: Name of the script.

Usage:

    --@name Awesome script 
    -- CODE
--@precache paths
Precaches a sound or model file. This ensures that playing the sound or creating a prop with the model does not use a large amount of CPU time.

Parameters:

  • paths: A comma-separated list of file paths (.wav, .ogg, .mp3, .mdl) to precache.

Usage:

    --@precache vo/k_lab/kl_fiddlesticks.wav,vo/k_lab/kl_dearme.wav
--@require path
Mark a file to be included in the upload and then required on both the server and the client.

Parameters:

  • path: Path to the file.

Usage:

    --@require lib/someLibrary.txt 
    -- Your file is already required and ready to use here.
--@requirecl path
Mark a file to be included in the upload and then required on the client only.

Parameters:

  • path: Path to the file.

Usage:

    --@requirecl lib/someLibrary.txt 
    if CLIENT then 
    -- Your file is already required and ready to use here. 
    end
--@requiresv path
Mark a file to be included in the upload and then required on the server only. This file will not be sent to clients.

Parameters:

  • path: Path to the file.

Usage:

    --@requiresv lib/someLibrary.txt 
    if SERVER then 
    -- Your file is already required and ready to use here. 
    end
--@resolution width, height
Sets the screen resolution in pixels. Valid values are 64, 128, 256, 512, 1024 or 2048 for each dimension. The default resolution is 512 x 512. Higher resolutions can be more costly to render, especially for lower-end systems.

Parameters:

  • width: The width of the screen in pixels.
  • height: The height of the screen in pixels.

Usage:

    -- Equivalent to --@widescreen 
    --@resolution 1024 512
--@shared 
For screens, HUDs and emitters, make the script run on the server alongside the client. You can use "if SERVER then" and "if CLIENT then" to determine if the script is currently being run on the server or the client, respectively.

Usage:

    --@shared 
     
    if SERVER then 
    	-- Do important calculations 
    	-- Send net message 
    else 
    	-- Display result of important calculations 
    end
--@updater steamID
Sets the Steam ID of the shared area folder to check for updates against. This allows users of your script to right click the file in the editor and choose "Update". They will then download the latest version of this file and all included files from your shared folder.

Parameters:

  • steamID: The SteamID of the player responsible for updating this script.

Usage:

    --@updater STEAM_0:0:123456
--@widescreen 
Sets whether the screen should be widescreen. Widescreen screens are 1024 x 512, while normal resolution screens are 512 x 512.

Valid XHTML 1.0!