Functions - IcyStarFrost/Lambda-Players GitHub Wiki

Introduction

Here you will find documentation of all the functions you can use within your addons to Lambda Players.

Global Functions

Lambda ConVars

shared $\textsf{\normalsize Must be Shared!}$

These functions allow you to create convars using Lambda's Convar function. This will automatically create a setting in the Spawn Menu where ever you specify

CreateLambdaConvar( name, val, shouldsave, isclient, userinfo, desc, min, max, settingstbl )

name | String | The name of the Convar
val | String | The default value of the Convar
shouldsave | Bool | If the Convar should save
isclient | Bool | If the Convar should be client-side only
userinfo | Bool | If the server can access the client-side Convar
desc | String | The description of the Convar
min | Number | The minimum number the Convar can go
max | Number | The maximum number the Convar can go
settingstbl | Table | The table to build settings with


CreateLambdaColorConvar( name, defaultcolor, isclient, userinfo, desc, settingstbl )

defaultcolor | Color | The default Color
This generally has the same args as CreateLambdaConvar()

-- Possible settingstbl variables --
These are variables you will have to use in the settingstbl Table. This will build the spawn menu settings

type | String | Must be one of the following: Slider, Bool, Text, Combo. For Colors, you must use CreateLambdaColorConvar()
name | String | Pretty name
category | String | The Lambda Settings category to place the convar into. Will create one if one doesn't exist already

decimals | Number | Slider only! How much decimals the slider should have
options | Table | Combo only! A table with its keys being the text and values being the data

See lambdaplayers/autorun_includes/shared/convars.lua


Lambda Console Commands

shared $\textsf{\normalsize Must be Shared!}$

This function will allow you to create Console Commands using Lambda's Console Command Function. This will automatically create a setting in the Spawn Menu where ever you specify

CreateLambdaConsoleCommand( name, func, isclient, helptext, settingstbl )

name | string | The Console Command name
func | function | The function that will be called See https://wiki.facepunch.com/gmod/concommand.Add for function args
isclient | bool | If the Console Command should be Client-Side only
helptext | string | The description of the Console Command
settingstbl | Table | The table to build settings with

-- Possible settingstbl variables --
These are variables you will have to use in the settingstbl Table. This will build the spawn menu settings

name | String | Pretty name
category | String | The Lambda Settings category to place the convar into. Will create one if one doesn't exist already

See lambdaplayers/autorun_includes/shared/d_consolecommands.lua


Lambda Universal Actions

shared $\textsf{\normalsize Server-Side}$

Universal actions are functions that are randomly called during run time. This means Lambda players could randomly change weapons or randomly look at something and ect

This function will allow you to add Universal Actions to Lambda's list of UActions.

AddUActionToLambdaUA( func( Entity lambda ) )

The function you provide first arg will be a Lambda Player who used your Universal Action

See lambdaplayers/autorun_includes/shared/lambda_universalactions.lua


Custom Profile Panel Settings

client $\textsf{\normalsize Client-Side}$

This function will allow you to add custom settings to the Profile Panel. This means you can add custom variables to be saved/edited on Lambda Profiles.

For example from the Friend System addon, you can set a permanent friend or more

LambdaCreateProfileSetting( panelclass, variablename, category, callback )

panelclass  | String |  The classname of the panel you want added to the profile panel. Current Value supported panels are below

-- Supported Panels
DTextEntry
DCheckBox
DNumSlider
DColorMixer
DComboBox
--

variablename  | String |  The variable name that will be applied to the Lambda. For example, inputting "testvar" will add a variable on the Lambda with the name testvar which can accessed by .testvar on the Lambda Entity
category  | String |  The panel category to put your setting in. You can place settings in the same category and they will be added onto each other
callback( createdpanel, parentpanel )  | Function |  The function that will be called when the panel is created. First arg is the panel created by panelclass. Second arg is the category panel

See the Friend System addon code for a example on using this function


Entity Picking Up

server $\textsf{\normalsize Server-Side}$

Pickup functions are the functions called when a Lambda Player wants to "pickup" a entity. For example, healing with a medkit and gaining armor by armor battery

This function will allow you to specify a function to be called for a specific entity class when a Lambda Player "picks up" said specified entity class.

LambdaPlayers_AddItemPickup( class, func )

class | string | The entity class to associate the function with
func( Entity lambda, Entity pickedupent ) | function | The function to be called when the entity is "picked up" by a Lambda Player

See lambdaplayers/autorun_includes/server/globals.lua


Custom Voice Types

shared $\textsf{\normalsize Must be Shared!}$

This function will allow you to register custom Voice Types which can be used with Lambda's Entity Method :GetVoiceLine( voicetype )

LambdaRegisterVoiceType( voicetypename, defaultpath, voicetypedescription )

-- voicetypename | string | The name of the voice type. Should be lowercare letters only and no spaces
-- defaultpath | string | The default directory relative to the "sound" folder for this voice type. Example, lambdaplayers/vo/taunt
-- voicetypedescription | string | The description of when this voice type is typically used

See lambdaplayers/autorun_includes/shared/c_registervoicetypes.lua


Custom Text Chat Key Words

server $\textsf{\normalsize Server-Side}$

There are two different types of key words so let's go over each one.

Key Words are words that are replaced before a message is sent by a Lambda Player. For example, Key Word /rndply/ will be replaced with the name of a random Real Player or Lambda Player.

LambdaAddTextChatKeyWord( keyword, replacefunction )

-- keyword | string | The word that will be detected and replaced
-- replacefunction( Entity lambda ) | function | Return a string in the function to replace the keyword with. The first arg is the Lambda Player who is using the key word

Conditional Key words are words that will test if certain conditions are met and will allow a text line that has the key words to be used. For example, Conditional Key Word |highping| will only let a text line that has it be used if the Lambda has high ping.

LambdaAddConditionalKeyWord( keyword, conditionfunc )

-- keyword | string | The word that will be detected and replaced
-- conditionfunc ( Entity lambda ) | function | Return true to allow the text line to be used. The first arg is the Lambda Player who is using the key word

See lambdaplayers/autorun_includes/shared/lambda_textchatkeywords.lua


Custom Lambda Tool Gun Tools

shared $\textsf{\normalsize Must be Shared!}$

This function will allow you to add custom tools that Lambda Player's can use with their tool gun. Best combined with Entity Limits if the tool creates entities.

AddToolFunctionToLambdaTools( toolname, func )

toolname | string | The name of the tool. Example, Light. This must have no spaces!
func( Entity lambda, Entity targetent ) | function | The function that will be called when a Lambda Player wants to use this tool. First arg is the Lambda using this tool. Second arg is the entity the Lambda wants to use the tool on this is completely optional.

Please See lambdaplayers/autorun_includes/shared/lambda_toolguntools.lua for examples


Custom Entity Limits

shared $\textsf{\normalsize Must be Shared!}$

Entity limits can help limit a certain type of entity or range of entities. This should be used in conjunction with Tool gun tools that spawn entities or Build functions that spawn untracked entities

This function will allow you to add custom Entity Limits to Lambda Players. This can allow you to limit whatever custom entity you want. See lambdaplayers/lambda/sv_entitylimits.lua for adding to the limit and checking the limit

CreateLambdaEntLimit( name, default, max )

name | string | The name of this limit. This must have no spaces!
default | number | The default number this limit should be at
max | number | The highest this limit can be set at

See lambdaplayers/autorun_includes/shared/lambda_entitylimits.lua


Custom Build Functions

shared $\textsf{\normalsize Must be Shared!}$

Build functions are functions that are called when a lambda player wants to build/spawn something. For example, prop spawning is used by this

Best combined with Entity Limits if the build function creates entities.

AddBuildFunctionToLambdaBuildingFunctions( spawnname, settingname, desc, func )

spawnname | string | The name of this spawn function. This must have no spaces!
settingname | string | The name to show in the settings. Example, Allow Prop Spawning
desc | string | The description of this build function
func( Entity lambda ) | function | The function that will be called when a Lambda Player uses this build function. First arg is the Lambda that used this build function

See lambdaplayers/autorun_includes/shared/lambda_x_buildingfunctions.lua


Custom Personalities

shared $\textsf{\normalsize Must be Shared!}$

"Personalities" are functions that have chances ordered from highest to lowest applied to them. When a Lambda Player is in the idle state, each chance will be tested and if it succeeds, the function will run. Personalities are responsible for the decisions on building stuff or fighting

I hope you got that because that's pretty much what personalities are for Lambda

LambdaCreatePersonalityType( personalityname, func )

personalityname | string | The name of this personality. This must have no spaces!
func( Entity lambda ) | function | The function that will be called if this personality's chance succeeds a test. First arg is the Lambda who had this personality run

See lambdaplayers/autorun_includes/shared/lambda_personalityfuncs.lua


Lambda's File System

shared $\textsf{\normalsize Shared}$

Lambdas have a set of functions for making file handling easier.

LAMBDAFS:WriteFile( filename, content, type ) 

filename | String | The file path to write to. See the file.Write() function https://wiki.facepunch.com/gmod/file.Write
content | String or Table | The string/table content that will be written. If string, you must set the type to nil! If table, you must set the type to either json or compressed!
type | string | How the provided table should be written. Values are "json" or "compressed". If the content is a string, set this to nil
LAMBDAFS:ReadFile( filename, type, path )

filename | String | The file path to read from. See the file.Read() function https://wiki.facepunch.com/gmod/file.Read
type | string | How should the file be read and returned. Values are "json" or "compressed". For example, if the file you are reading from is a json, input "json" and this function will return the table the json has. Likewise for compressed. Leave nil if you just want the raw text
path | string | The Game path to search from. See https://wiki.facepunch.com/gmod/File_Search_Paths. Leave nil for the DATA path
Updates or creates a new file containing a sequential table
type should be json or compressed

LAMBDAFS:UpdateSequentialFile( filename, addcontent, type ) 
filename | String | The file path to write to. See the file.Write() function https://wiki.facepunch.com/gmod/file.Write
addcontent | any | The content to add to the table
type | string | How the table should be encoded. Values are "json" or "compressed"
Updates or creates a new file containing a table that uses strings as keys
type should be json or compressed

LAMBDAFS:UpdateKeyValueFile( filename, addcontent, type ) 
filename | String | The file path to write to. See the file.Write() function https://wiki.facepunch.com/gmod/file.Write
addcontent | table | A table with a key and a value. The key will be the key written to the file's table which will contain the value of the addcontent table
type | string | How the table should be encoded. Values are "json" or "compressed"
SQ short for Sequential
Removes a value from the specified file containing a sequential table

LAMBDAFS:RemoveVarFromSQFile( filename, var, type )
filename | String | The file path to write to. See the file.Write() function https://wiki.facepunch.com/gmod/file.Write
var | any | The value to remove from the table
type | string | How the table should be encoded. Values are "json" or "compressed"
KV short for Key Value
Removes a key from the specified file containing a table that uses strings as keys

LAMBDAFS:RemoveVarFromKVFile( filename, key, type )
filename | String | The file path to write to. See the file.Write() function https://wiki.facepunch.com/gmod/file.Write
key | any | The key to remove from the table
type | string | How the table should be encoded. Values are "json" or "compressed"
If a file has the provided value
Only works if the file contains a sequential table

LAMBDAFS:FileHasValue( filename, value, type ) 
filename | String | The file path to write to. See the file.Write() function https://wiki.facepunch.com/gmod/file.Write
value | any | The value to check for
type | string | How the table is encoded. Values are "json" or "compressed"
Returns if the specified key's value exists

LAMBDAFS:FileKeyIsValid( filename, key, type ) 
filename | String | The file path to write to. See the file.Write() function https://wiki.facepunch.com/gmod/file.Write
key| any | The key to check
type | string | How the table is encoded. Values are "json" or "compressed"

Lambda Method Functions

Have a look in lambdaplayers/lambda folder for every method function that can be used on a Lambda Entity.