Summary

Functions

Shows a world tip only to the player who owns the entity, and only while they hold the toolgun.
Creates a global class; the short form of library.NewClass.
Creates a color from components, a hexadecimal string or a CSS color name.
cout(...)shared
Prints its arguments; an alias of print.
Returns a copy of a table that util.TableToJSON writes without losing anything.
Returns how long the server has been loading Catwork, in seconds.
Builds a phrase string to send to clients, which translate it themselves.
Prints a C-style formatted string.
Runs a console command, ignoring calls without a command name.
Returns whether the screen has the given aspect ratio.
Adds a ban to the in-memory ban list without saving it to the database.
Returns the lowercase name of a value's type.

Functions

AddWorldTip(entIndex, text, dieTime, position, entity)

client gamemodes/catwork/gamemode/core/cl_kernel.lua:61

Shows a world tip only to the player who owns the entity, and only while they hold the toolgun.

Replaces the engine AddWorldTip, which is kept as cw.AddWorldTip. The entity must have a GetPlayerName method whose result matches the local player's name.

Parameters

  • entIndex Number Index of the entity the tip belongs to
  • text String Text of the tip
  • dieTime Number Time the tip disappears
  • position Vector Position of the tip
  • entity Entity The entity the tip belongs to

Class(strName, CExtends, tParent)

shared gamemodes/catwork/gamemode/core/sh_kernel.lua:779

Creates a global class; the short form of library.NewClass.

class 'CItem'

Parameters

  • strName String Name of the class
  • CExtends Map optional, defaults to nil Base class to inherit from
  • tParent Map optional, defaults to _G Table the class is stored in

Returns

  • Map The class table

Aliases

  • class
  • Meta

Creates a color from components, a hexadecimal string or a CSS color name.

Replaces the engine Color, which is kept as cw.oldColor. A string starting with # is passed to util.HexToColor, a known CSS color name (such as 'tomato', case-insensitive) returns that color, and any other string returns white.

Color(255, 0, 0)
Color('#ff000080')
Color('steelblue')

Parameters

  • r Number Red component 0 to 255, or a color string
  • g Number Green component; ignored for strings
  • b Number Blue component; ignored for strings
  • a Number optional, defaults to 255 Alpha component; ignored for strings

Returns

  • Color The color

Prints its arguments; an alias of print.

Parameters

  • ... Any Values to print

Derma_NumRequest(strTitle, strText, nDefaultValue, min, max, dec, fnEnter, fnCancel, strButtonText, strButtonCancelText)

client gamemodes/catwork/gamemode/core/cl_kernel.lua:3320

Opens a modal dialog that asks for a number with a slider.

Derma_NumRequest('Volume', 'Choose a volume.', 50, 0, 100, 0, function(value)
  RunConsoleCommand('volume', value / 100)
end)

Parameters

  • strTitle String Window title
  • strText String Message above the slider
  • nDefaultValue Number optional, defaults to 0 Initial value
  • min Number optional, defaults to 0 Minimum value
  • max Number optional, defaults to 256 Maximum value
  • dec Number optional, defaults to 0 Number of decimals
  • fnEnter Function Called with the value when the player confirms
  • fnCancel Function optional, defaults to nil Called with the value when the player cancels
  • strButtonText String optional, defaults to '#DermaRequest_OK' Text of the confirm button
  • strButtonCancelText String optional, defaults to '#DermaRequest_confirmQuery_Cancel' Text of the cancel button

Returns

  • Panel The dialog window

EncodeTable(tTable, visiting, skipped)

shared gamemodes/catwork/gamemode/core/sh_kernel.lua:1051

Returns a copy of a table that util.TableToJSON writes without losing anything.

A table whose keys are exactly 1 to n stays a list and becomes a JSON array. Any other table becomes a JSON object, with its keys turned into strings by EncodeKey. Values that JSON cannot hold (entities, functions, userdata, keys that are neither strings nor numbers, a table inside itself) are left out.

Parameters

  • tTable Map The table
  • visiting Map The tables that are being encoded right now
  • skipped Map Filled with the kinds of values that were left out

Returns

  • Map The table to save, or nil when the table contains itself

GetTimeSinceBoot()

server gamemodes/catwork/gamemode/init.lua:45

Returns how long the server has been loading Catwork, in seconds.

Measured with os.clock from the start of init.lua, which resets the start time on every Lua refresh.

Returns

  • Number Seconds since the framework started booting, rounded to three decimals

On the server

Builds a phrase string to send to clients, which translate it themselves.

Returns #Identifier:arg1,arg2;, which the client's L and cw.lang:TranslateText understand. Can also be called without the player, as L(identifier, ...).

cw.player:Notify(player, L('CashSetTarget', '#CashSet_Cash', amount, playerName))

Parameters

  • player Player The player the text is for (unused), or the identifier when called without one
  • identifier String Phrase identifier without the leading #
  • ... Any Arguments for #1, #2... in the phrase; converted with tostring

Returns

  • String The phrase string, or nil when there is no identifier

On the client

Translates a phrase for the local player.

The identifier can carry arguments in the networked form built by the server's L: #Identifier:arg1,arg2;.

L('#Attribute_MaximumReached')
L('#Scoreboard_Ping:'..self.player:Ping()..';')

Parameters

  • identifier String Phrase identifier, with optional arguments

Returns

  • String The translated text, or an empty string when identifier is nil

See also

Defined in

Prints a C-style formatted string.

Parameters

  • str String Format string for Format
  • ... Any Values for the format string

RunConsoleCommand(command, ...)

client gamemodes/catwork/gamemode/core/cl_kernel.lua:109

Runs a console command, ignoring calls without a command name.

Wraps the engine RunConsoleCommand, which is kept as cw.RunConsoleCommand, so that a nil command does nothing instead of raising an error.

Parameters

  • command String The command name
  • ... Any The command's arguments

Returns whether the screen has the given aspect ratio.

The aspect ratio is measured once when the file loads.

Parameters

  • w Number Width part of the ratio, such as 16
  • h Number Height part of the ratio, such as 9

Returns

  • Boolean Whether the ratio matches exactly

SimpleBan(name, steamId, duration, reason, fullTime)

server gamemodes/catwork/gamemode/shared.lua:117

Adds a ban to the in-memory ban list without saving it to the database.

Used at boot to apply hard-coded bans. The entry is written to cw.bans.stored, so it is lost on restart.

Parameters

  • name String Steam name to show for the ban
  • steamId String Steam ID of the banned player
  • duration Number Ban length in seconds, or the unban time when fullTime is set
  • reason String Reason for the ban
  • fullTime Boolean optional, defaults to nil Whether duration is already an absolute os.time timestamp

Returns the lowercase name of a value's type.

Parameters

  • obj Any The value to check

Returns

  • String The result of type in lowercase, such as 'player' or 'string'

Defined in