Summary

Methods

Shows a hint in the middle of the screen.
Queues cinematic text, shown between black bars at the top and bottom of the screen.
Adds the files in a directory to the client content download.
Adds a file to the client content download with resource.AddFile.
Appends a colored line to markup text.
Fills a Derma menu from a table of options.
Shows a hint in the top right corner of the screen.
Adds every item of a Steam Workshop collection to the client downloads.
Widens a width so that a text fits in it.
Returns whether two tables have the same contents.
CacheLimbs()client internal
Caches the limb textures and names and the colors and font used by the HUD.
Returns an alpha value that fades from 255 to 0 with distance.
CalculateHints()client internal
Animates the top and center hints and removes the ones that have expired.
Applies damage to a player's armor, health and limbs.
Fades the screen to black while the ShouldPlayerScreenFadeBlack hook returns true.
Starts a dead player's respawn timer.
Returns whether there are quick menu entries to show in the info menu.
Returns whether a file exists in the framework-wide data folder, settings/clockwork/.
Closes every open Derma menu.
Returns an opening markup color tag for a color.
Scales a force vector down so that its length does not exceed a limit.
Plays blood smoke and impact effects at a position and sprays blood decals.
Creates a client ConVar and watches it for changes.
Creates a console variable and runs the ClockworkConVarChanged hook whenever it changes.
Creates an expanded collapsible category in a panel.
Spawns an infodecal entity that paints a decal at a position.
Creates the info menu panel from the quick menu entries.
Gives a panel a markup tool tip.
Makes a table forward method calls to each of its values.
Prints a pink debug message when cw.LogLevel is 4 or higher.
Deletes a file from the framework-wide data folder, settings/clockwork/.
Deletes a file from the current schema's data folder.
Deserializes a string created by cw.core:Serialize.
DistributeWagesCash()server internal
Pays wages to every initialized, living player.
Runs the player-specific part of the EntityTakeDamage hook.
DrawAdminESP()client internal
Draws the admin ESP when the CW_CONVAR_ADMINESP ConVar is on.
DrawArmorBar()client internal
Adds the local player's armor bar to the top bars when they have armor.
DrawBackgroundBlurs()client internal
Draws the registered background blurs.
Draws a progress bar with a value and a maximum.
Draws every registered top bar from cw.bars.stored below a position.
Draws one frame of a cinematic text and advances its animation.
DrawCinematicInfo()client internal
Draws the title and text of the character intro.
Draws the credits part of the character intro and fades it in and out.
Draws the black bars of the character intro when the draw_intro_bars config is on.
DrawDateTime()client internal
Draws the tab menu's date and time box, bars, player info and limb damage diagram.
Draws a door's name and text on both sides of the door.
DrawHealthBar()client internal
Adds the local player's health bar to the top bars while they are alive.
DrawHints()client internal
Draws the top and center hints.
Draws outlined information text in the main_text font.
Draws a markup tool tip near a position, keeping it on the screen.
Draws the local player's information box from cw.PlayerInfoText.
Draws one sub box of the player info box.
Draws a rounded box at three quarters of the color's alpha.
Draws text in the main_text font with a dark outline.
Draws a rounded box at three quarters of the color's alpha with the gradient texture over it.
Prints a red error message when cw.LogLevel is 1 or higher.
Splits a string by a separator, keeping text between open and close tags together.
Finds files and folders in the current schema's data folder.
Scales a font size to the screen height, tripling it first.
Formats an amount of money with the schema's cash name.
Returns the panel whose markup tool tip is shown.
Returns ammo information for a scripted weapon.
Returns the alpha of the black screen fade.
Returns the size of a text, caching it per font.
Returns the framework gamemode folder without the gamemodes/ prefix.
Returns the Lua path of the framework's gamemode/core directory.
Returns whether entity menus are shown as a Derma menu.
Returns the table admin ESP entries are collected in.
Returns the font size used for 3D2D text.
Returns the gradient texture.
Returns the color used for a log type.
Returns a material, creating and caching it on first use.
Returns the notice panel when it is visible.
Returns the absolute path of the game's root directory.
Returns every prop_physics and prop_physics_multiplayer entity.
Returns the layout of the player info box from the last time it was drawn.
Returns the eye angles used while the local player's view follows their ragdoll.
Returns the bone of a ragdoll closest to a position.
Returns the hit group of the ragdoll bone closest to a position.
Returns the recognise menu.
Returns the path of the current schema's data folder.
Returns the schema folder, or a subfolder of its schema directory.
Returns the schema's gamemode information from its gamemode .txt file.
Returns the name of the loaded schema.
Returns the schema gamemode folder name.
Returns the version of the schema from its gamemode .txt file.
Returns the point HUD elements are centered on, slightly below the middle of the screen.
Returns a global networked variable; see netvars.GetNetVar.
Returns a short checksum of a string.
Returns the names of all registered commands in alphabetical order.
Returns the target ID data of the entity the local player is looking at.
Returns the size of a text, measured character by character.
Returns the kernel version.
Returns the kernel version and build.
Returns a text wrapped into lines that fit a width, as cw.core:WrapText does.
Prints a green success message when cw.LogLevel is 3 or higher.
Opens the context menu for an entity.
Opens the action menu for an item's spawn icon.
Runs an item's default action when its spawn icon is right-clicked.
Blocks or restores a weapon's primary and secondary fire based on the PlayerCanFireWeapon hook.
Returns whether a player may use an object such as an item, class or attribute.
Scales a font size to the screen height without tripling it.
Includes every Lua file in a directory; see util.IncludeDirectory.
Includes every plugin in a directory.
Includes a file in the realm its prefix says; see util.Include.
IncludeSchema()shared internal
Loads the schema, loading the config before and after it.
Returns whether the character menu is open.
Returns whether the local player is in the character menu.
Returns whether a weapon is a sandbox tool (physgun, gravity gun or toolgun).
Returns whether the info menu is open.
Returns whether the screen has completely faded to black.
Returns whether the server is shutting down.
Returns whether the local player is holding the camera.
Returns whether the local player is holding the toolgun.
Returns whether a letter is an English vowel.
LoadSchema()shared internal
Loads the active schema and its plugins.
Turns a table into a proxy table that stores non-function values in a subtable.
Wraps text in markup font and color tags.
Clamps and punctuates a physical description.
Creates an object that inherits from a table.
Runs a function on the next frame.
Temporarily replaces the main_text font, or restores it.
Replaces a markup object's Draw method so that it draws outlined text.
Expands the placeholders in a text.
PerformDateTimeThink()server internal
Advances the in-game clock by one minute, rolling over hours, days, months and years.
Returns the plural of some text.
Prints a message to the console with a green [Catwork] prefix.
Prints colored text to the chat and console with the engine chat.AddText.
Sends a log message to admins who have log display enabled and writes it to the server log.
Blurs the screen behind a panel while it is visible.
Registers a callback that runs when a networked variable of an entity changes.
Hides the active Derma tool tip.
Removes a background blur registered with cw.core:RegisterBackgroundBlur.
Removes a suffix from a string if it is present.
Replaces every occurrence of a plain string, without pattern matching.
Reads and deserializes a file from the framework-wide data folder, settings/clockwork/.
Reads and deserializes a file from the current schema's data folder.
Runs a framework command through the cwCmd console command.
Serializes a table as JSON with cw.core:Serialize and writes it to settings/clockwork/<fileName>.cw.
Stores a player's attribute boosts in their character data so they survive a reconnect.
Serializes a table and writes it to the current schema's data folder.
Returns whether a file exists in the current schema's data folder.
Serializes a table to a JSON string.
Writes a message to the server log and to the day's Catwork log file.
Changes the case of the first character of a string.
Sets the notice panel.
Runs a callback after a panel's PerformLayout.
Stores the recognise menu and gives it its title.
Sets a global networked variable; see netvars.SetNetVar.
Sets the menu that gets a title drawn above it.
Prints a pink verbose message when cw.LogLevel is 5 or higher.
Splits a string into chunks of equal length.
Parses a color from a comma-separated string.
Converts a string to a boolean.
Returns the components of a color.
Returns whether a custom crosshair is in use.
Removes falsy entries from the array part of a table, in place.
Prints a yellow warning message when cw.LogLevel is 2 or higher.
Wraps text into lines that fit a width.
Pads a number with leading zeros.

Methods

cw.core:AddCenterHint(text, delay, color, bNoSound, showDuplicated)

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

Shows a hint in the middle of the screen.

At most 10 center hints are shown; identical hints already on screen are skipped unless showDuplicated is set. Does nothing when text is nil.

Parameters

  • text String The hint text
  • delay Number optional, defaults to 5 Seconds the hint stays before fading
  • color Color optional, defaults to nil Text color, or the name of a color option; defaults to white
  • bNoSound String optional, defaults to nil Sound to play; nil plays a blip and false plays nothing
  • showDuplicated Boolean optional, defaults to false Show the hint even when the same text is on screen

See also

cw.core:AddCinematicText(text, color, barLength, hangTime, font, bThisOnly)

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

Queues cinematic text, shown between black bars at the top and bottom of the screen.

Parameters

  • text String The text
  • color Color optional, defaults to nil Text color; defaults to white
  • barLength Number optional, defaults to ScrH() * 8 Height of the bars in pixels
  • hangTime Number optional, defaults to 3 Seconds the text stays once the bars are in
  • font String optional, defaults to nil Font; defaults to the cinematic_text font
  • bThisOnly Boolean optional, defaults to false Replace the current cinematic instead of queueing

cw.core:AddDirectory(directory, bRecursive)

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

Adds the files in a directory to the client content download.

A path ending in / adds every file in it; otherwise the path is used as a search pattern.

Parameters

  • directory String Path relative to the game folder, such as 'materials/catwork/'
  • bRecursive Boolean optional, defaults to false Also add subdirectories

See also

cw.core:AddFile(fileName)

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

Adds a file to the client content download with resource.AddFile.

Parameters

  • fileName String Path relative to the game folder

cw.core:AddMarkupLine(markupText, text, color)

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

Appends a colored line to markup text.

Parameters

  • markupText String Existing markup; a newline is added when it is not empty
  • text String Text of the new line
  • color Color optional, defaults to nil Color of the line

Returns

  • String The new markup

See also

cw.core:AddMenuFromData(menuPanel, data, Callback, iMinimumWidth, bManualOpen)

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

Fills a Derma menu from a table of options.

Keys are option names, sorted alphabetically. A function value becomes an option that runs it, a table becomes a submenu (unless it has isArgTable set), and anything else is passed to the callback, which adds the option itself. When menuPanel is nil a new menu is created and opened, or removed if it has no options.

cw.core:AddMenuFromData(nil, {
  ['Say hello'] = function() RunConsoleCommand('say', 'Hello') end,
  ['More'] = { ['Wave'] = function() RunConsoleCommand('act', 'wave') end }
})

Parameters

  • menuPanel Panel optional, defaults to nil Menu to add to; nil creates one
  • data Map Options keyed by name
  • Callback Function optional, defaults to nil Called with the menu, name and value for other values
  • iMinimumWidth Number optional, defaults to nil Minimum width of a new menu
  • bManualOpen Boolean optional, defaults to false Do not open a new menu automatically

Returns

  • Panel The new menu, or nil when an existing menu was passed

cw.core:AddTopHint(text, delay, color, bNoSound, showDuplicated)

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

Shows a hint in the top right corner of the screen.

At most 10 top hints are shown; identical hints already on screen are skipped unless showDuplicated is set. Does nothing when text is nil.

Parameters

  • text String The hint text
  • delay Number optional, defaults to 5 Seconds the hint stays before fading
  • color Color optional, defaults to nil Text color, or the name of a color option; defaults to white
  • bNoSound String optional, defaults to nil Sound to play; nil plays a blip and false plays nothing
  • showDuplicated Boolean optional, defaults to false Show the hint even when the same text is on screen

See also

cw.core:AddWorkshopCollection(id)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:901

Adds every item of a Steam Workshop collection to the client downloads.

Fetches the collection page asynchronously and calls resource.AddWorkshop for each item on it.

Parameters

  • id String The collection's Workshop ID

cw.core:AdjustMaximumWidth(font, text, width, addition, extra)

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

Widens a width so that a text fits in it.

& characters are measured as U.

Parameters

  • font String Font name
  • text String The text
  • width Number Current width
  • addition Number optional, defaults to 0 Padding added when the width has to grow
  • extra Number optional, defaults to 0 Extra width added to the text measurement

Returns

  • Number The text width plus addition if it is wider, else width

cw.core:AreTablesEqual(tableA, tableB)

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

Returns whether two tables have the same contents.

Every key of each table must be present in the other with an equal value; nested tables are compared the same way. Returns false when either argument is not a table.

Parameters

  • tableA Map The first table
  • tableB Map The second table

Returns

  • Boolean Whether the tables are equal

cw.core:CacheLimbs()

client internal gamemodes/catwork/gamemode/core/cl_kernel.lua:948

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel once the options are available.

Caches the limb textures and names and the colors and font used by the HUD.

cw.core:CalculateAlphaFromDistance(maximum, start, finish)

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

Returns an alpha value that fades from 255 to 0 with distance.

Parameters

  • maximum Number Distance at which the alpha reaches 0
  • start Vector Start position; a player uses its shoot position, an entity its position
  • finish Vector End position; a player uses its shoot position, an entity its position

Returns

  • Number The alpha, 0 to 255

cw.core:CalculateHints()

client internal gamemodes/catwork/gamemode/core/cl_kernel.lua:904

Internal

This function is internal. It is not part of the public API and may change without notice.

Called every frame by the kernel.

Animates the top and center hints and removes the ones that have expired.

cw.core:CalculatePlayerDamage(player, hitGroup, damageInfo)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:570

Applies damage to a player's armor, health and limbs.

Bullet, club and slash damage is taken from armor first (only on the chest and generic hit groups when armor_chest_only is on); damage that gets through hurts the hit limb with cw.limb:TakeDamage. Health never drops below 1 here, and fall damage also hurts both legs.

Parameters

  • player Player The damaged player
  • hitGroup Number The HITGROUP_* that was hit
  • damageInfo CTakeDamageInfo The damage

cw.core:CalculateScreenFading()

client internal gamemodes/catwork/gamemode/core/cl_kernel.lua:2712

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel while the HUD is drawn.

Fades the screen to black while the ShouldPlayerScreenFadeBlack hook returns true.

Fades back out afterwards; see cw.core:GetBlackFadeAlpha.

cw.core:CalculateSpawnTime(player, inflictor, attacker, damageInfo)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:473

Starts a dead player's respawn timer.

The delay is the spawn_time config, adjusted by the PlayerAdjustDeathInfo hook through an info table with attacker, inflictor, spawnTime and damageInfo. Sets the player's spawn action when the resulting time is above zero.

Parameters

  • player Player The player who died
  • inflictor Entity The entity that inflicted the damage
  • attacker Entity The entity that caused the death
  • damageInfo CTakeDamageInfo optional, defaults to nil The fatal damage

cw.core:CanCreateInfoMenuPanel()

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

Returns whether there are quick menu entries to show in the info menu.

Returns

cw.core:ClockworkDataExists(fileName)

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:382

On the server

Returns whether a file exists in the framework-wide data folder, settings/clockwork/.

Parameters

  • fileName String File name without extension

Returns

  • Boolean Whether the file exists

On the client

Returns whether a framework data file exists.

Parameters

  • fileName String File name without extension

Returns

  • Boolean Whether the file exists

Defined in

cw.core:CloseActiveDermaMenus()

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

Closes every open Derma menu.

cw.core:ColorToMarkup(color)

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

Returns an opening markup color tag for a color.

Parameters

  • color Color The color; alpha is ignored

Returns

  • String The tag, such as '<color=255,0,0>'

cw.core:ConvertForce(force, limit)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:407

Scales a force vector down so that its length does not exceed a limit.

Used to keep damage forces applied to ragdolls and players within reason.

Parameters

  • force Vector The force to limit
  • limit Number optional, defaults to 800 Maximum length of the returned vector

Returns

  • Vector The force, shortened to limit if it was longer, or a zero vector for a zero force

cw.core:CreateBloodEffects(position, decals, entity, forceVec, fScale)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:674

Plays blood smoke and impact effects at a position and sprays blood decals.

Does nothing if the entity bled less than half a second ago.

Parameters

  • position Vector Where the blood appears
  • decals Number How many blood decals to trace
  • entity Entity The bleeding entity; also filtered out of the decal traces
  • forceVec Vector optional, defaults to nil Direction of the blood smoke; random if nil
  • fScale Number optional, defaults to 0.5 Scale of the effects

cw.core:CreateClientConVar(name, value, save, userData, Callback)

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

Creates a client ConVar and watches it for changes.

Every change runs the ClockworkConVarChanged hook and then the optional callback.

Parameters

  • name String Name of the ConVar
  • value String Default value
  • save Boolean Save the value between sessions
  • userData Boolean Send the value to the server
  • Callback Function optional, defaults to nil Called with the ConVar name, old value and new value

Returns

  • ConVar The ConVar

cw.core:CreateConVar(name, value, flags, Callback)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:778

Creates a console variable and runs the ClockworkConVarChanged hook whenever it changes.

Parameters

  • name String Name of the convar
  • value String Default value
  • flags Number optional, defaults to nil FCVAR_* flags; replicated, notify and archive when nil
  • Callback Function optional, defaults to nil Called as Callback(conVar, previousValue, newValue) on every change

Returns

  • ConVar The created convar

cw.core:CreateCustomCategoryPanel(categoryName, parent)

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

Creates an expanded collapsible category in a panel.

The category is added to parent.CategoryList.

Parameters

  • categoryName String Label of the category
  • parent Panel The parent panel

Returns

  • Panel The DCollapsibleCategory

cw.core:CreateDecal(texture, position, temporary)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:493

Spawns an infodecal entity that paints a decal at a position.

Parameters

  • texture String Material path of the decal
  • position Vector Where to place the decal
  • temporary Boolean optional, defaults to nil Whether the decal is low priority, so the engine may remove it

Returns

  • Entity The decal entity

cw.core:CreateInfoMenuPanel(x, y, iMinimumWidth)

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

Creates the info menu panel from the quick menu entries.

Each entry's GetInfo returns its option table (name, Callback, options, toolTip). The panel is stored in cw.InfoMenuPanel and starts hidden. Does nothing if it already exists.

Parameters

  • x Number X position
  • y Number Y position
  • iMinimumWidth Number Width of the panel

cw.core:CreateMarkupToolTip(panel)

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

Gives a panel a markup tool tip.

Adds SetMarkupToolTip, GetMarkupToolTip and SetToolTip methods and wraps OnCursorEntered/OnCursorExited so the tip shows while the cursor is over the panel.

cw.core:CreateMarkupToolTip(button)
button:SetMarkupToolTip(cw.core:MarkupTextWithColor('Sells for ^50^', Color(0, 255, 0)))

Parameters

  • panel Panel The panel

Returns

  • Panel The same panel

cw.core:CreateMulticallTable(baseTable, object)

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

Makes a table forward method calls to each of its values.

Calling baseTable:Method(...) calls object.Method(value, ...) for every value in the table.

local players = cw.core:CreateMulticallTable(player.GetAll(), FindMetaTable('Player'))
players:Freeze(true)

Parameters

  • baseTable List The values to call methods on
  • object Map Table the methods are looked up in

Returns

  • List The same table, with its metatable set

Prints a pink debug message when cw.LogLevel is 4 or higher.

Parameters

  • message String The message

cw.core:DeleteClockworkData(fileName)

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:393

On the server

Deletes a file from the framework-wide data folder, settings/clockwork/.

Parameters

  • fileName String File name without extension

Returns

  • Boolean The result of File.delete

On the client

Deletes a framework data file.

Parameters

  • fileName String File name without extension

Defined in

cw.core:DeleteSchemaData(fileName)

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:190

On the server

Deletes a file from the current schema's data folder.

Parameters

Returns

  • Boolean The result of File.delete

On the client

Deletes a schema data file.

Parameters

  • fileName String File name without extension

Defined in

cw.core:Deserialize(strData)

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

Deserializes a string created by cw.core:Serialize.

Prints an error and returns an empty table when the data is not a string.

Parameters

  • strData String The serialized data

Returns

  • Map The decoded table, or nil when the data cannot be decoded

See also

cw.core:Deserialize(strData)

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

No documentation available.

cw.core:DistributeWagesCash()

server internal gamemodes/catwork/gamemode/core/sv_kernel.lua:806

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel every wages_interval seconds.

Pays wages to every initialized, living player.

For each player the PlayerModifyWagesInfo hook may change the wages field of an info table. When PlayerCanEarnWagesCash allows it and the wages are positive, PlayerGiveWagesCash decides whether the cash is given with cw.player:GiveCash; PlayerEarnWagesCash runs afterwards in any case.

cw.core:DoEntityTakeDamageHook(entity, damageInfo)

server internal gamemodes/catwork/gamemode/core/sv_kernel.lua:934

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel's EntityTakeDamage hook.

Runs the player-specific part of the EntityTakeDamage hook.

For players and their ragdolls it runs PrePlayerTakeDamage, cancels damage that PlayerShouldTakeDamage rejects or that hits a player in god mode, redirects damage from a ragdolled player to the ragdoll and turns crush damage on a ragdoll into fall damage (at most once a second) using GetFallDamage.

Parameters

  • entity Entity The damaged entity
  • damageInfo CTakeDamageInfo The damage; modified in place

Returns

  • Boolean true when the damage was cancelled or redirected and the caller should stop

cw.core:DrawAdminESP()

client internal gamemodes/catwork/gamemode/core/cl_kernel.lua:1287

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel while the HUD is drawn.

Draws the admin ESP when the CW_CONVAR_ADMINESP ConVar is on.

Shows the name, Steam name, weapon, status and bounding box of every other player in front of the view, their health and armor bars when cwESPBars is on, plus persistent props, items and salesmen when their ESP ConVars are on. The entities are looked up again every cwESPTime seconds.

cw.core:DrawArmorBar()

client internal gamemodes/catwork/gamemode/core/cl_kernel.lua:2551

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel while the top bars are built.

Adds the local player's armor bar to the top bars when they have armor.

The displayed value moves towards the real one by one point per call.

cw.core:DrawBackgroundBlurs()

client internal gamemodes/catwork/gamemode/core/cl_kernel.lua:2612

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel while the HUD is drawn.

Draws the registered background blurs.

cw.core:DrawBar(x, y, width, height, color, text, value, maximum, flash, barInfo)

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

Draws a progress bar with a value and a maximum.

The bar's fields are copied into barInfo where it has none, and that table is passed to the PreDrawBar, PostDrawBar and DrawBarLimit hooks; return true from one to replace that part of the drawing. When barInfo.maxValue is more than 5 below the maximum, the part above it is shaded, with barInfo.limitText drawn on it.

Parameters

  • x Number X position
  • y Number Y position
  • width Number Width
  • height Number Height
  • color Color Color of the filled part
  • text String Text drawn in the middle of the bar
  • value Number Current value
  • maximum Number Maximum value
  • flash Boolean Make the bar pulse
  • barInfo Map optional, defaults to nil Extra bar options, such as maxValue, limitText or drawBackground

Returns

  • Number The bar's y position

cw.core:DrawBars(info, class)

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

Draws every registered top bar from cw.bars.stored below a position.

Only draws when the PlayerCanSeeBars hook returns true. Moves info.y below the last bar.

Parameters

  • info Map Layout table with x, y and width fields; y is updated
  • class String Where the bars are drawn; 'tab' centers them on info.x

cw.core:DrawCinematic(cinematicTable, curTime)

client internal gamemodes/catwork/gamemode/core/cl_kernel.lua:2749

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel for the first queued cinematic.

Draws one frame of a cinematic text and advances its animation.

Removes the cinematic from cw.Cinematics once its bars have slid back out.

Parameters

cw.core:DrawCinematicInfo()

client internal gamemodes/catwork/gamemode/core/cl_kernel.lua:2884

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel after a character is loaded.

Draws the title and text of the character intro.

Uses the title and text from the GetCinematicIntroInfo hook and fades them out once the intro screen starts.

cw.core:DrawCinematicIntro(curTime)

client internal gamemodes/catwork/gamemode/core/cl_kernel.lua:2788

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel after a character is loaded.

Draws the credits part of the character intro and fades it in and out.

Uses the table from the GetCinematicIntroInfo hook.

Parameters

  • curTime Number The current time

cw.core:DrawCinematicIntroBars()

client internal gamemodes/catwork/gamemode/core/cl_kernel.lua:2835

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel after a character is loaded.

Draws the black bars of the character intro when the draw_intro_bars config is on.

cw.core:DrawDateTime()

client internal gamemodes/catwork/gamemode/core/cl_kernel.lua:984

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel while the tab menu is drawn.

Draws the tab menu's date and time box, bars, player info and limb damage diagram.

While the info menu is open it also draws and positions the quick menu panel. Runs the PlayerCanSeeDateTime, PaintInfoMenuExtras, PostDrawDateTimeBox and PlayerCanSeeLimbDamage hooks and stores the box layout in cw.LastDateTimeInfo.

cw.core:DrawDoorText(entity, eyePos, eyeAngles, font, nameColor, textColor)

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

Draws a door's name and text on both sides of the door.

The text comes from the GetDoorInfo hook. Nothing is drawn for invisible doors, doors whose text position hits the world, or when the door is more than 256 units away.

Parameters

  • entity Entity The door
  • eyePos Vector Position of the viewer's eyes
  • eyeAngles Angle Angles of the viewer's eyes; unused
  • font String Font of the text
  • nameColor Color Color of the door name
  • textColor Color Color of the door text

cw.core:DrawGradient(gradientType, x, y, width, height, color)

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

Draws a gradient rectangle.

Does nothing when the gradient type has no texture in cw.Gradients.

Parameters

  • gradientType Number A GRADIENT_* constant, such as GRADIENT_RIGHT
  • x Number X position
  • y Number Y position
  • width Number Width
  • height Number Height
  • color Color Draw color

cw.core:DrawHealthBar()

client internal gamemodes/catwork/gamemode/core/cl_kernel.lua:2570

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel while the top bars are built.

Adds the local player's health bar to the top bars while they are alive.

The displayed value moves towards the real one by one point per call, and the bar flashes below 10 health.

cw.core:DrawHints()

client internal gamemodes/catwork/gamemode/core/cl_kernel.lua:1159

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel while the HUD is drawn.

Draws the top and center hints.

Each kind is only drawn when PlayerCanSeeHints or PlayerCanSeeCenterHints returns true.

cw.core:DrawInfo(text, x, y, color, alpha, bAlignLeft, Callback, shadowDepth)

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

Draws outlined information text in the main_text font.

The text is translated first and centered on x unless bAlignLeft is set. Nothing is drawn when the text is nil.

y = cw.core:DrawInfo('#Hint_Example', x, y, Color(255, 255, 255), 200, true, function(x, y, w, h)
  return x, y - h
end)

Parameters

  • text String The text, or a language phrase
  • x Number X position
  • y Number Y position
  • color Color Text color
  • alpha Number optional, defaults to nil Alpha; defaults to the color's alpha
  • bAlignLeft Boolean optional, defaults to false Draw from x instead of centering on it
  • Callback Function optional, defaults to nil Called with x, y, width, height; returns the new x, y
  • shadowDepth Number optional, defaults to 1 Thickness of the outline in pixels

Returns

  • Number Y position below the text
  • Number Width of the text

See also

cw.core:DrawInfoScaled(scale, text, x, y, color, alpha, bAlignLeft, Callback, shadowDepth)

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

Draws information text with the main font scaled; see cw.core:DrawInfo.

Parameters

  • scale Number Font size multiplier for cwMainText
  • text String The text, translated before drawing
  • x Number X position
  • y Number Y position
  • color Color Text color
  • alpha Number optional, defaults to nil Alpha; defaults to the color's alpha
  • bAlignLeft Boolean optional, defaults to false Draw from x instead of centering on it
  • Callback Function optional, defaults to nil Called with x, y, width, height; returns the new x, y
  • shadowDepth Number optional, defaults to 1 Thickness of the outline in pixels

Returns

  • Number Y position below the text

cw.core:DrawMarkupToolTip(markupObject, x, y, alpha)

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

Draws a markup tool tip near a position, keeping it on the screen.

Parameters

  • markupObject Map A markup object from markup.Parse
  • x Number X position
  • y Number Y position
  • alpha Number Alpha of the tool tip

cw.core:DrawPlayerInfo(info)

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

Draws the local player's information box from cw.PlayerInfoText.

Only draws when the PlayerCanSeePlayerInfo hook returns true and there is text to show. The PreDrawPlayerInfo hook can return true to replace the drawing; PostDrawPlayerInfo runs afterwards. Moves info.y below the box.

Parameters

  • info Map Layout table with x, y and width fields; y is updated

Returns

  • Map The box layout (x, y, width, height, information, subInformation...)

cw.core:DrawPlayerInfoSubBox(text, x, y, width, boxInfo)

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

Draws one sub box of the player info box.

Parameters

  • text String Text of the box
  • x Number X position
  • y Number Y position
  • width Number Width
  • boxInfo Map Layout from cw.core:DrawPlayerInfo; uses textHeight and drawBackground

Returns

  • Number X position
  • Number Y position for the next box

cw.core:DrawSimpleGradientBox(cornerSize, x, y, width, height, color, maxAlpha)

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

Draws a rounded box at three quarters of the color's alpha.

Despite the name, no gradient is drawn on top.

Parameters

  • cornerSize Number Corner radius
  • x Number X position
  • y Number Y position
  • width Number Width
  • height Number Height
  • color Color Box color
  • maxAlpha Number optional, defaults to 100 Unused

See also

cw.core:DrawSimpleText(text, x, y, color, alignX, alignY, shadowless, shadowDepth)

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

Draws text in the main_text font with a dark outline.

Parameters

  • text String The text
  • x Number X position, rounded
  • y Number Y position, rounded
  • color Color Text color
  • alignX Number optional, defaults to nil A TEXT_ALIGN_* horizontal alignment
  • alignY Number optional, defaults to nil A TEXT_ALIGN_* vertical alignment
  • shadowless Boolean optional, defaults to false Skip the outline
  • shadowDepth Number optional, defaults to 1 Thickness of the outline in pixels

Returns

  • Number Y position below the text
  • Number Width of the text

See also

cw.core:DrawTexturedGradientBox(cornerSize, x, y, width, height, color, maxAlpha)

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

Draws a rounded box at three quarters of the color's alpha with the gradient texture over it.

Parameters

  • cornerSize Number Corner radius; the gradient is inset by this much
  • x Number X position
  • y Number Y position
  • width Number Width
  • height Number Height
  • color Color Box color
  • maxAlpha Number optional, defaults to 100 Maximum alpha of the gradient

See also

Prints a red error message when cw.LogLevel is 1 or higher.

Parameters

  • message String The message

cw.core:ExplodeByTags(text, seperator, open, close, hide)

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

Splits a string by a separator, keeping text between open and close tags together.

cw.core:ExplodeByTags('say "hello there"', ' ', '"', '"', true) -- { 'say', 'hello there' }

Parameters

  • text String The text to split
  • seperator String Single character to split on
  • open String Single character that opens a tag
  • close String Single character that closes a tag
  • hide Boolean optional, defaults to false Remove the tag characters from the results

Returns

  • List<String> The parts

cw.core:FakeDamageInfo(damage, inflictor, attacker, position, damageType, damageForce)

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

Creates a damage info object.

Parameters

  • damage Number Damage amount; rounded up and clamped to 0 or more
  • inflictor Entity The inflictor
  • attacker Entity The attacker
  • position Vector Damage position
  • damageType Number A DMG_* damage type
  • damageForce Number Scale of the damage force

Returns

  • CTakeDamageInfo The damage info

cw.core:FindSchemaDataInDir(directory)

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:267

On the server

Finds files and folders in the current schema's data folder.

Parameters

  • directory String Path and wildcard relative to the schema data folder, e.g. 'plugins/*'

Returns

  • List<String> File names
  • List<String> Folder names, as returned by file.Find

On the client

Finds files in the schema data folder.

Parameters

  • directory String Search pattern inside the schema data folder, such as 'logs/*'

Returns

  • List<String> File names
  • List<String> Folder names

Defined in

cw.core:FontScreenScale(size)

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

Scales a font size to the screen height, tripling it first.

The reference height is 1200 on 16:10 screens, 1024 on 4:3 screens and 1080 otherwise.

Parameters

  • size Number Font size

Returns

  • Number The scaled size

See also

cw.core:FormatCash(amount, singular, lowerName)

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

Formats an amount of money with the schema's cash name.

Uses the format_cash or format_singular_cash option, replacing %n with the name_cash option and %a with the rounded amount. On the client the cash name is translated.

Parameters

  • amount Number The amount of cash
  • singular Boolean optional, defaults to false Use the singular format
  • lowerName Boolean optional, defaults to false Lowercase the cash name; client only

Returns

  • String The formatted amount

cw.core:GetActiveMarkupToolTip()

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

Returns the panel whose markup tool tip is shown.

Returns

  • Panel The panel under the cursor, or nil

cw.core:GetAmmoInformation(weapon)

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

Returns ammo information for a scripted weapon.

The table is cached on the weapon as weapon.AmmoInfo and refreshed on every call. It has primary and secondary subtables with ammoType, clipSize, ownerAmmo, clipBullets, doesNotShoot and ownerClips. Returns nil for invalid or ownerless weapons and weapons without Primary and Secondary tables.

Parameters

  • weapon Weapon The weapon

Returns

  • Map The ammo information

cw.core:GetBlackFadeAlpha()

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

Returns the alpha of the black screen fade.

Returns

  • Number The alpha of the fade in or out, or 0 when there is none

cw.core:GetCachedTextSize(font, text)

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

Returns the size of a text, caching it per font.

Parameters

  • font String Font name
  • text String The text

Returns

  • Number Width in pixels
  • Number Height in pixels

cw.core:GetClockworkFolder()

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

Returns the framework gamemode folder without the gamemodes/ prefix.

Returns

  • String The folder name, such as 'catwork'

cw.core:GetClockworkPath()

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

Returns the Lua path of the framework's gamemode/core directory.

Returns

  • String The path, such as 'catwork/gamemode/core'

cw.core:GetEntityMenuType()

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

Returns whether entity menus are shown as a Derma menu.

cw.core:HandleEntityMenu only opens a menu when this is true.

Returns

  • Boolean Always true

Returns the table admin ESP entries are collected in.

Returns

  • List The ESP info table

cw.core:GetFontSize3D()

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

Returns the font size used for 3D2D text.

Returns

  • Number Always 128

cw.core:GetGradientTexture()

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

Returns the gradient texture.

Returns

  • IMaterial The material stored in cw.GradientTexture, made from the gradient option

cw.core:GetLogTypeColor(logType)

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

Returns the color used for a log type.

Parameters

  • logType Number Log type 1 to 5; anything else uses the color of type 5

Returns

  • Color The color

cw.core:GetMaterial(materialPath, pngParameters)

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

Returns a material, creating and caching it on first use.

Parameters

  • materialPath String Material path; any other value is returned unchanged
  • pngParameters String optional, defaults to nil Parameters for Material, such as 'smooth'

Returns

  • IMaterial The material

cw.core:GetNoticePanel()

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

Returns the notice panel when it is visible.

Returns

  • Panel The panel, or nil

cw.core:GetPathToGMod()

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

Returns the absolute path of the game's root directory.

Returns

  • String The full path without a trailing separator

cw.core:GetPhysicsEntities()

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

Returns every prop_physics and prop_physics_multiplayer entity.

Returns

  • List<Entity> The entities

cw.core:GetPlayerInfoBox()

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

Returns the layout of the player info box from the last time it was drawn.

Returns

cw.core:GetRagdollEyeAngles()

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

Returns the eye angles used while the local player's view follows their ragdoll.

Creates the angle the first time it is needed.

Returns

  • Angle The angle stored in cw.RagdollEyeAngles

cw.core:GetRagdollHitBone(entity, position, failSafe, minimum)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:610

Returns the bone of a ragdoll closest to a position.

Only the bones listed in cw.HitGroupBonesCache are considered.

Parameters

  • entity Entity The ragdoll
  • position Vector The position to check, usually the damage position
  • failSafe Any optional, defaults to nil Value to return when no bone is close enough
  • minimum Number optional, defaults to nil Maximum distance a bone may be from the position

Returns

  • Number The bone index, or failSafe

cw.core:GetRagdollHitGroup(entity, position)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:643

Returns the hit group of the ragdoll bone closest to a position.

Parameters

  • entity Entity The ragdoll
  • position Vector The position to check, usually the damage position

Returns

  • Number The HITGROUP_* of the closest bone in cw.HitGroupBonesCache, or HITGROUP_GENERIC

cw.core:GetRecogniseMenu(menuPanel)

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

Returns the recognise menu.

Parameters

  • menuPanel Panel Unused

Returns

cw.core:GetSchemaDataPath()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:211

Returns the path of the current schema's data folder.

Returns

  • String The path, settings/catwork/schemas/<schema>, relative to the garrysmod folder

cw.core:GetSchemaFolder(sFolderName)

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

Returns the schema folder, or a subfolder of its schema directory.

Parameters

  • sFolderName String optional, defaults to nil Subfolder inside <schema>/schema/

Returns

  • String The folder name or path

cw.core:GetSchemaGamemodeInfo()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:222

Returns the schema's gamemode information from its gamemode .txt file.

Reads gamemodes/<schema>/<schema>.txt once and caches the result in the SCHEMA_GAMEMODE_INFO global. Missing fields are 'Undefined'.

Returns

  • Map The name (the file's title), author, description and version of the schema

cw.core:GetSchemaGamemodeName()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:247

Returns the name of the loaded schema.

Returns

  • String The schema's name from Schema:GetName, or 'Catwork' before the schema has loaded

cw.core:GetSchemaGamemodePath()

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

Returns the schema gamemode folder name.

Returns

  • String The value of cw.Schema

cw.core:GetSchemaGamemodeVersion()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:258

Returns the version of the schema from its gamemode .txt file.

Returns

  • String The version, or 'Undefined' if the file does not set one

See also

cw.core:GetScreenCenter()

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

Returns the point HUD elements are centered on, slightly below the middle of the screen.

Returns

  • Number X position
  • Number Y position

cw.core:GetSharedVar(key, default)

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

Returns a global networked variable; see netvars.GetNetVar.

Parameters

  • key String Name of the variable
  • default Any optional, defaults to nil Value returned when the variable is not set

Returns

  • Any The value

See also

cw.core:GetShortCRC(value)

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

Returns a short checksum of a string.

Parameters

  • value String The value to hash

Returns

  • Number The CRC divided by 100000, rounded up

cw.core:GetSortedCommands()

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

Returns the names of all registered commands in alphabetical order.

Returns

  • List<String> The command names

cw.core:GetTargetIDData()

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

Returns the target ID data of the entity the local player is looking at.

Returns

  • Map The value of cw.TargetIDData

cw.core:GetTextSize(font, text)

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

Returns the size of a text, measured character by character.

Characters that measure zero width count as wide as U.

Parameters

  • font String Font name
  • text String The text

Returns

  • Number Width in pixels
  • Number Height in pixels

See also

Returns the kernel version.

Returns

  • String The value of cw.KernelVersion

cw.core:GetVersionBuild()

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

Returns the kernel version and build.

Currently the same as cw.core:GetVersion.

Returns

  • String The value of cw.KernelVersion

cw.core:GetWrappedLines(text, font, maximumWidth)

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

Returns a text wrapped into lines that fit a width, as cw.core:WrapText does.

The lines of the most recently wrapped texts are cached, so wrapping the same text every frame is cheap.

Parameters

  • text String The text to wrap
  • font String Font name
  • maximumWidth Number Maximum line width in pixels

Returns

  • List<String> The lines; the table is shared, do not change it

See also

Prints a green success message when cw.LogLevel is 3 or higher.

Parameters

  • message String The message

cw.core:HandleEntityMenu(entity)

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

Opens the context menu for an entity.

Options come from the GetEntityMenuOptions hook and, for cw_item entities, from the item's GetOptions. Item options are handled by the item's HandleOptions and sent to the server with the MenuOption Cable message; other options are sent with cw.entity:ForceMenuOption. Option tables may set isOrdered (show first) and toolTip. Does nothing when there are no options.

Parameters

  • entity Entity The entity the menu is for

Returns

  • Panel The menu, or nil when no menu was opened

cw.core:HandleItemSpawnIconClick(itemTable, spawnIcon, Callback)

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

Opens the action menu for an item's spawn icon.

Collects the item's use, drop and destroy actions, customFunctions and GetOptions, lets the item (OnEditFunctions) and the PlayerAdjustItemFunctions and PlayerAdjustItemMenu hooks change them, and runs the chosen action with the InvAction command. Does nothing when the item has no actions and no callback is given.

Parameters

  • itemTable Item The item
  • spawnIcon Panel The clicked spawn icon; unused
  • Callback Function optional, defaults to nil Called with the menu before the actions are added

See also

cw.core:HandleItemSpawnIconRightClick(itemTable, spawnIcon)

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

Runs an item's default action when its spawn icon is right-clicked.

If the item's OnHandleRightClick returns an action name other than 'Use', that action is run; otherwise the item is used when it has OnUse. OnHandleUse can delay the use.

Parameters

  • itemTable Item The item
  • spawnIcon Panel The clicked spawn icon; unused

cw.core:HandleWeaponFireDelay(player, bIsRaised, weapon, curTime)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:516

Blocks or restores a weapon's primary and secondary fire based on the PlayerCanFireWeapon hook.

When firing is not allowed, the next fire time is pushed a minute ahead and the original time is kept on the weapon to restore once firing is allowed again. The SMG's secondary fire is never delayed.

Parameters

  • player Player The player holding the weapon
  • bIsRaised Boolean Whether the weapon is raised
  • weapon Weapon The weapon
  • curTime Number The current CurTime

cw.core:HasObjectAccess(player, object)

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

Returns whether a player may use an object such as an item, class or attribute.

Access is granted when the player has any of the object's access flags, belongs to one of its factions or classes (by team index or class name), or when none of those fields are set. A matching faction, class or flag in blacklist denies access. An object:HasObjectAccess(player, hasAccess) method, if present, has the final say.

Parameters

  • player Player The player
  • object Map Table with optional access, factions, classes and blacklist fields

Returns

  • Boolean Whether the player has access

cw.core:HDFontScreenScale(size)

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

Scales a font size to the screen height without tripling it.

Uses the same reference heights as cw.core:FontScreenScale.

Parameters

  • size Number Font size

Returns

  • Number The scaled size

cw.core:IncludeDirectory(directory, bFromBase)

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

Includes every Lua file in a directory; see util.IncludeDirectory.

Parameters

  • directory String The directory
  • bFromBase String optional, defaults to nil Prefix for the directory; true uses 'catwork/gamemode/core/'

cw.core:IncludePlugins(directory, bFromBase)

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

Includes every plugin in a directory.

Single-file plugins (*.lua) and plugin folders (<name>/plugin) are loaded with plugin.Include.

Parameters

  • directory String The plugins directory
  • bFromBase Boolean optional, defaults to false Prefix the directory with 'catwork/'

Returns

  • Boolean Always true

cw.core:IncludePrefixed(fileName)

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

Includes a file in the realm its prefix says; see util.Include.

Parameters

  • fileName String Path of the file

Returns

  • Any What the file returns, when it is included

cw.core:IncludeSchema()

shared internal gamemodes/catwork/gamemode/core/sv_kernel.lua:830

On the server

Internal

This function is internal. It is not part of the public API and may change without notice.

Called once while the framework boots, from shared.lua.

Loads the schema, loading the config before and after it.

On the client

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel while the gamemode loads.

Loads the schema with cw.core:LoadSchema when a schema folder is set.

Defined in

cw.core:IsCharacterScreenOpen(isVisible)

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

Returns whether the character menu is open.

Parameters

  • isVisible Boolean optional, defaults to false Also require the panel to be visible

Returns

  • Boolean Whether the menu is open, or nil when it is not

cw.core:IsChoosingCharacter()

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

Returns whether the local player is in the character menu.

Returns

  • Boolean true while the menu is open or has not been created yet

cw.core:IsDefaultWeapon(weapon)

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

Returns whether a weapon is a sandbox tool (physgun, gravity gun or toolgun).

Parameters

  • weapon Weapon The weapon to check

Returns

  • Boolean Whether the weapon is a default weapon; false for invalid entities

cw.core:IsInfoMenuOpen()

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

Returns whether the info menu is open.

Returns

  • Boolean Whether the info menu is open

cw.core:IsScreenFadedBlack()

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

Returns whether the screen has completely faded to black.

Returns

  • Boolean Whether the black fade in is at full alpha

cw.core:IsShuttingDown()

server gamemodes/catwork/gamemode/core/sv_kernel.lua:796

Returns whether the server is shutting down.

Set in the ShutDown hook; used to skip work such as dropping belongings while the map unloads.

Returns

  • Boolean true during shutdown, otherwise nil

Returns whether the local player is holding the camera.

Returns

  • Boolean Whether the active weapon is gmod_camera

Returns whether the local player is holding the toolgun.

Returns

  • Boolean Whether the active weapon is gmod_tool

cw.core:IsVowel(letter)

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

Returns whether a letter is an English vowel.

Parameters

  • letter String A single letter, case-insensitive

Returns

  • Boolean Whether it is a, e, i, o or u

cw.core:LoadSchema()

shared internal gamemodes/catwork/gamemode/core/sh_kernel.lua:1384

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel while the gamemode loads.

Loads the active schema and its plugins.

Creates Schema, merges the schema's gamemode info into it (sent to clients through CW_SCRIPT_SHARED.schemaData), includes sh_schema.lua and the schema's extra folders, caches its hooks and then includes the schema's plugins. Prints timings with cw.core:Debug.

cw.core:MakeProxyTable(baseTable, baseClass, proxy)

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

Turns a table into a proxy table that stores non-function values in a subtable.

Existing non-function fields are moved into baseTable[proxy], and __index/__newindex are set so that reads and writes of non-function keys go there. If the object has a __proxy method, reads of missing keys call it instead.

Parameters

  • baseTable Map The table to convert
  • baseClass Map Metatable to set on baseTable
  • proxy String Key of the subtable that holds the values

cw.core:MarkupTextWithColor(text, color, scale)

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

Wraps text in markup font and color tags.

Parameters

  • text String The text
  • color Color optional, defaults to nil Color of the text
  • scale Number optional, defaults to 1 Size multiplier for the cwTooltip font

Returns

  • String The markup

cw.core:ModifyPhysDesc(description)

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

Clamps and punctuates a physical description.

Descriptions with Cyrillic letters are cut to 256 characters, others to 1024, ending in .... A period is added when the description does not end with punctuation.

Parameters

  • description String The description

Returns

  • String The modified description

cw.core:NewMetaTable(baseTable)

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

Creates an object that inherits from a table.

Sets baseTable.__index to itself and returns an empty table with it as the metatable.

Parameters

  • baseTable Map The table to inherit from

Returns

  • Map The new object

cw.core:OnNextFrame(name, Callback)

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

Runs a function on the next frame.

Parameters

  • name String Unique timer name; reusing it replaces the pending call
  • Callback Function The function to run

cw.core:OverrideMainFont(font)

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

Temporarily replaces the main_text font, or restores it.

Text drawn with cw.core:DrawInfo and cw.core:DrawSimpleText uses this font.

cw.core:OverrideMainFont(cw.option:GetFont('hints_text'))
  cw.core:DrawInfo('Hello', x, y, color)
cw.core:OverrideMainFont(false)

Parameters

  • font String Font to use, or false to restore the original font

cw.core:OverrideMarkupDraw(markupObject, sCustomFont)

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

Replaces a markup object's Draw method so that it draws outlined text.

The new method takes an extra alphaOverride argument after the alignment arguments.

Parameters

  • markupObject Map A markup object from markup.Parse
  • sCustomFont String optional, defaults to nil Font for every block; defaults to each block's own font

Expands the placeholders in a text.

^amount^ becomes formatted cash and !amount! singular cash (with (amount) for a lowercase cash name), *key* the value of an option (*(key)* passes true to cw.option:GetKey; text between asterisks that is not an option is left alone) and, on the client, :command: the key bound to a command. Finally config.Parse replaces $key$ with config values.

cw.core:ParseData('It costs ^50^. Press :+use: to buy.')

Parameters

  • text String The text to parse

Returns

  • String The parsed text

cw.core:PerformDateTimeThink()

server internal gamemodes/catwork/gamemode/core/sv_kernel.lua:708

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel every minute_time seconds (one in-game minute).

Advances the in-game clock by one minute, rolling over hours, days, months and years.

Runs the TimePassed hook with TIME_MINUTE, TIME_HOUR, TIME_DAY, TIME_MONTH or TIME_YEAR for each unit that changed and networks the time and date with netvars.SetNetVar.

cw.core:Pluralize(text)

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

Returns the plural of some text.

Currently returns the text unchanged.

Parameters

  • text String The text

Returns

  • String The text

cw.core:Print(message, color)

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

Prints a message to the console with a green [Catwork] prefix.

A table is joined with spaces first. Empty or non-string messages print nothing.

Parameters

  • message String The message, or a list of strings
  • color Color optional, defaults to Color(255, 255, 255) Color of the message text

See also

cw.core:PrintColoredText(...)

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

Prints colored text to the chat and console with the engine chat.AddText.

A player argument adds their name in their team color; a color applies to the next argument; other values without a color before them are white.

cw.core:PrintColoredText(player, Color(255, 0, 0), ' was arrested.')

Parameters

  • ... Any Players, colors and text

cw.core:PrintLog(logType, text)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:846

Sends a log message to admins who have log display enabled and writes it to the server log.

Admins receive it when their cwShowLog client convar is 1. On dedicated servers with CW_CONVAR_LOG enabled the message is also passed to cw.core:ServerLog.

Parameters

  • logType Number optional, defaults to LOGTYPE_GENERIC One of the LOGTYPE_* enums
  • text String The message

cw.core:RegisterBackgroundBlur(panel, fCreateTime)

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

Blurs the screen behind a panel while it is visible.

The blur fades in over one second from the creation time.

Parameters

  • panel Panel The panel, or a string key for a blur not tied to a panel
  • fCreateTime Number optional, defaults to SysTime() Time the blur starts fading in

See also

cw.core:RegisterNetworkProxy(entity, name, Callback)

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

Registers a callback that runs when a networked variable of an entity changes.

The value is polled by the kernel; pass game.GetWorld() to watch a global networked variable. Replaces any proxy already registered for the same entity and name.

cw.core:RegisterNetworkProxy(cw.client, 'Cash', function(entity, name, oldValue, newValue)
  print('Cash changed to '..newValue)
end)

Parameters

  • entity Entity The entity to watch
  • name String Name of the networked variable
  • Callback Function Called with the entity, name, old value and new value

cw.core:RemoveActiveToolTip()

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

Hides the active Derma tool tip.

cw.core:RemoveBackgroundBlur(panel)

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

Removes a background blur registered with cw.core:RegisterBackgroundBlur.

Parameters

  • panel Panel The panel or string key of the blur

cw.core:RemoveTextFromEnd(text, toRemove)

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

Removes a suffix from a string if it is present.

Parameters

  • text String The string to trim
  • toRemove String The suffix to remove

Returns

  • String The string without the suffix, or unchanged

cw.core:Replace(text, find, replace)

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

Replaces every occurrence of a plain string, without pattern matching.

Parameters

  • text String The text to search
  • find String The literal text to find
  • replace String The replacement, inserted as it is

Returns

  • String The new text

cw.core:RestoreClockworkData(fileName, failSafe)

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:323

On the server

Reads and deserializes a file from the framework-wide data folder, settings/clockwork/.

If the file cannot be deserialized, an error is printed and the file is deleted; a copy of it is kept, see KeepUnreadableData.

Parameters

  • fileName String File name without extension, as passed to cw.core:SaveClockworkData
  • failSafe Any optional, defaults to nil Value to return when the file is missing or invalid; an empty table if nil

Returns

  • Any The stored table, or failSafe when it could not be restored

See also

On the client

Loads a table saved with cw.core:SaveClockworkData.

A file that cannot be read is deleted.

Parameters

  • fileName String File name without extension
  • failSafe Any optional, defaults to nil Value returned when there is no data; defaults to an empty table

Returns

  • Map The data

Defined in

cw.core:RestoreSchemaData(fileName, failSafe)

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:283

On the server

Reads and deserializes a file from the current schema's data folder.

If deserializing the file raises an error, the error is printed and the file is deleted. A file that is neither JSON nor legacy pON is left alone. Either way a copy of the unreadable file is kept, see KeepUnreadableData.

Parameters

  • fileName String File name without extension, as passed to cw.core:SaveSchemaData
  • failSafe Any optional, defaults to nil Value to return when the file is missing or invalid; an empty table if nil

Returns

  • Any The stored table, or failSafe when it could not be restored

See also

On the client

Loads a table saved with cw.core:SaveSchemaData.

A file that cannot be read is deleted.

Parameters

  • fileName String File name without extension
  • failSafe Any optional, defaults to nil Value returned when there is no data; defaults to an empty table

Returns

  • Map The data

Defined in

cw.core:RunCommand(command, ...)

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

Runs a framework command through the cwCmd console command.

cw.core:RunCommand('InvAction', 'use', itemTable.uniqueID, itemTable.itemID)

Parameters

  • command String Name of the command
  • ... Any Arguments of the command

cw.core:SaveClockworkData(fileName, data)

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:361

On the server

Serializes a table as JSON with cw.core:Serialize and writes it to settings/clockwork/<fileName>.cw.

Unlike schema data, this data is shared by every schema. Prints an error and saves nothing when data is not a table or the file name contains ...

Parameters

  • fileName String File name without extension
  • data Map Table to save

Returns

  • Boolean The result of File.write, or nil when nothing was saved

See also

On the client

Saves a table to data/clockwork/<fileName>.txt.

Prints an error and saves nothing when the data is not a table.

Parameters

  • fileName String File name without extension; may contain folders
  • data Map The data to save

See also

Defined in

cw.core:SavePlayerAttributeBoosts(player, data)

server internal gamemodes/catwork/gamemode/core/sv_kernel.lua:432

Internal

This function is internal. It is not part of the public API and may change without notice.

Called by the kernel when a character is saved.

Stores a player's attribute boosts in their character data so they survive a reconnect.

Writes the AttrBoosts key of data, keeping the remaining duration of timed boosts and dropping expired ones. Called from PlayerSaveCharacterData when the save_attribute_boosts config is on.

Parameters

  • player Player The player whose boosts are saved
  • data Map The character data table being saved

cw.core:SaveSchemaData(fileName, data)

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:170

On the server

Serializes a table and writes it to the current schema's data folder.

The file is settings/catwork/schemas/<schema>/<fileName>.cw, encoded as JSON with cw.core:Serialize. Prints an error and saves nothing when data is not a table or the file name contains ...

Parameters

  • fileName String File name without extension; may contain subfolders
  • data Map Table to save

Returns

  • Boolean The result of File.write, or nil when nothing was saved

See also

On the client

Saves a table to data/clockwork/schemas/<schema>/<fileName>.txt.

Prints an error and saves nothing when the data is not a table.

Parameters

  • fileName String File name without extension; may contain folders
  • data Map The data to save

See also

Defined in

cw.core:SchemaDataExists(fileName)

shared gamemodes/catwork/gamemode/core/sv_kernel.lua:201

On the server

Returns whether a file exists in the current schema's data folder.

Parameters

Returns

  • Boolean Whether the file exists

On the client

Returns whether a schema data file exists.

Parameters

  • fileName String File name without extension

Returns

  • Boolean Whether the file exists

Defined in

cw.core:Serialize(tTable)

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

Serializes a table to a JSON string.

Everything Catwork writes to disk goes through this function. String and number keys, strings, numbers, booleans, vectors, angles and nested tables are read back by cw.core:Deserialize exactly as they were; colors come back as plain tables with r, g, b and a. Values that JSON cannot hold (entities, functions, userdata, a table inside itself) are left out and reported with cw.core:Debug. Prints an error and returns an empty string when the table cannot be serialized or is not a table.

Parameters

  • tTable Map The table to serialize

Returns

  • String The serialized data

See also

cw.core:ServerLog(text)

server gamemodes/catwork/gamemode/core/sv_kernel.lua:873

Writes a message to the server log and to the day's Catwork log file.

Appends a timestamped line to logs/clockwork/<YYYY-MM-DD>.log, passes the text to the engine's ServerLog and runs the ClockworkLog hook with the text and the Unix time.

Parameters

  • text String The message; newlines are removed in the log file

cw.core:SetCamelCase(text, bCamelCase)

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

Changes the case of the first character of a string.

Parameters

  • text String The text
  • bCamelCase Boolean true to lowercase the first character, false to uppercase it

Returns

  • String The new text
  • Number The number of replacements made

cw.core:SetNoticePanel(noticePanel)

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

Sets the notice panel.

Parameters

  • noticePanel Panel The panel

cw.core:SetOnLayoutCallback(target, Callback)

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

Runs a callback after a panel's PerformLayout.

The original method is kept as OldPerformLayout. Does nothing when the panel has no PerformLayout.

Parameters

  • target Panel The panel
  • Callback Function Called with the panel after each layout

cw.core:SetRecogniseMenu(menuPanel)

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

Stores the recognise menu and gives it its title.

Parameters

  • menuPanel Panel The menu

See also

cw.core:SetSharedVar(key, val, sendTo)

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

Sets a global networked variable; see netvars.SetNetVar.

Only works on the server.

Parameters

  • key String Name of the variable
  • val Any The new value
  • sendTo Player optional, defaults to nil Player or recipients to send it to; nil sends to everyone

See also

cw.core:SetTitledMenu(menuPanel, title)

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

Sets the menu that gets a title drawn above it.

Parameters

  • menuPanel Panel The menu
  • title String The title, or a language phrase

Prints a pink verbose message when cw.LogLevel is 5 or higher.

Parameters

  • message String The message

cw.core:SplitString(text, interval)

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

Splits a string into chunks of equal length.

Parameters

  • text String The string to split; UTF-8 aware
  • interval Number Characters per chunk

Returns

  • List<String> The chunks; the last one may be shorter

cw.core:StringToColor(text)

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

Parses a color from a comma-separated string.

Missing or invalid components default to 255.

Parameters

  • text String Components as 'r, g, b[, a]'

Returns

  • Color The color

Converts a string to a boolean.

Parameters

  • text String The text to convert

Returns

  • Boolean true for 'true', 'yes' or '1', otherwise false

cw.core:UnpackColor(color)

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

Returns the components of a color.

Parameters

  • color Color The color

Returns

  • Number Red
  • Number Green
  • Number Blue
  • Number Alpha

cw.core:UsingCustomCrosshair()

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

Returns whether a custom crosshair is in use.

Returns

  • Boolean The value of cw.CustomCrosshair

cw.core:ValidateTableKeys(baseTable)

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

Removes falsy entries from the array part of a table, in place.

Parameters

  • baseTable List The table to clean

cw.core:Warning(message)

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

Prints a yellow warning message when cw.LogLevel is 2 or higher.

Parameters

  • message String The message

cw.core:WrapText(text, font, maximumWidth, baseTable)

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

Wraps text into lines that fit a width.

Lines are appended to baseTable. Breaks happen at any character, not only at spaces. Does nothing when the width is not positive or the text is empty.

Parameters

  • text String The text to wrap
  • font String Font name
  • maximumWidth Number Maximum line width in pixels
  • baseTable List<String> Table the lines are added to

cw.core:ZeroNumberToDigits(number, digits)

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

Pads a number with leading zeros.

Parameters

  • number Number The number
  • digits Number Minimum length of the result

Returns

  • String The padded number

Defined in