cw.core class
Summary
Methods
resource.AddFile.ShouldPlayerScreenFadeBlack hook returns true.settings/clockwork/.ClockworkConVarChanged hook whenever it changes.infodecal entity that paints a decal at a position.cw.LogLevel is 4 or higher.settings/clockwork/.cw.core:Serialize.EntityTakeDamage hook.CW_CONVAR_ADMINESP ConVar is on.cw.bars.stored below a position.draw_intro_bars config is on.main_text font.cw.core:DrawInfo.cw.PlayerInfoText.main_text font with a dark outline.cw.LogLevel is 1 or higher.gamemodes/ prefix.gamemode/core directory.prop_physics and prop_physics_multiplayer entity.schema directory..txt file..txt file.netvars.GetNetVar.cw.core:WrapText does.cw.LogLevel is 3 or higher.PlayerCanFireWeapon hook.util.IncludeDirectory.util.Include.main_text font, or restores it.Draw method so that it draws outlined text.[Catwork] prefix.chat.AddText.cw.core:RegisterBackgroundBlur.settings/clockwork/.cwCmd console command.cw.core:Serialize and writes it to settings/clockwork/<fileName>.cw.PerformLayout.netvars.SetNetVar.cw.LogLevel is 5 or higher.cw.LogLevel is 2 or higher.Methods
cw.core:AddCenterHint(text, delay, color, bNoSound, showDuplicated)
client gamemodes/catwork/gamemode/core/cl_kernel.lua:822Shows 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
5Seconds the hint stays before fading - color Color optional, defaults to
nilText color, or the name of a color option; defaults to white - bNoSound String optional, defaults to
nilSound to play;nilplays a blip andfalseplays nothing - showDuplicated Boolean optional, defaults to
falseShow 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:2668Queues cinematic text, shown between black bars at the top and bottom of the screen.
Parameters
- text String The text
- color Color optional, defaults to
nilText color; defaults to white - barLength Number optional, defaults to
ScrH() * 8Height of the bars in pixels - hangTime Number optional, defaults to
3Seconds the text stays once the bars are in - font String optional, defaults to
nilFont; defaults to thecinematic_textfont - bThisOnly Boolean optional, defaults to
falseReplace the current cinematic instead of queueing
cw.core:AddDirectory(directory, bRecursive)
shared gamemodes/catwork/gamemode/core/sh_kernel.lua:1594Adds 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
falseAlso add subdirectories
See also
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:2352Appends 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
nilColor 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:695Fills 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
nilMenu to add to;nilcreates one - data Map Options keyed by name
- Callback Function optional, defaults to
nilCalled with the menu, name and value for other values - iMinimumWidth Number optional, defaults to
nilMinimum width of a new menu - bManualOpen Boolean optional, defaults to
falseDo not open a new menu automatically
Returns
- Panel The new menu, or
nilwhen an existing menu was passed
cw.core:AddTopHint(text, delay, color, bNoSound, showDuplicated)
client gamemodes/catwork/gamemode/core/cl_kernel.lua:836Shows 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
5Seconds the hint stays before fading - color Color optional, defaults to
nilText color, or the name of a color option; defaults to white - bNoSound String optional, defaults to
nilSound to play;nilplays a blip andfalseplays nothing - showDuplicated Boolean optional, defaults to
falseShow the hint even when the same text is on screen
See also
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:749Widens 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
0Padding added when the width has to grow - extra Number optional, defaults to
0Extra width added to the text measurement
Returns
- Number The text width plus
additionif it is wider, elsewidth
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
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:428Returns 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
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:570Applies 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
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:473Starts 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
nilThe fatal damage
Returns whether there are quick menu entries to show in the info menu.
Returns
- Boolean Whether
cw.quickmenuhas any entries or categories
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
Closes every open Derma menu.
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>'
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
800Maximum length of the returned vector
Returns
- Vector The force, shortened to
limitif 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:674Plays 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
nilDirection of the blood smoke; random ifnil - fScale Number optional, defaults to
0.5Scale of the effects
cw.core:CreateClientConVar(name, value, save, userData, Callback)
client gamemodes/catwork/gamemode/core/cl_kernel.lua:301Creates 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
nilCalled 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:778Creates 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
nilFCVAR_*flags; replicated, notify and archive whennil - Callback Function optional, defaults to
nilCalled asCallback(conVar, previousValue, newValue)on every change
Returns
- ConVar The created convar
cw.core:CreateCustomCategoryPanel(categoryName, parent)
client gamemodes/catwork/gamemode/core/cl_kernel.lua:2533Creates 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:493Spawns 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
nilWhether 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:1932Creates 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
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:1909Makes 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
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
On the server
Deletes a file from the current schema's data folder.
Parameters
- fileName String File name without extension, as passed to
cw.core:SaveSchemaData
Returns
- Boolean The result of
File.delete
On the client
Deletes a schema data file.
Parameters
- fileName String File name without extension
Defined in
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
nilwhen the data cannot be decoded
See also
No documentation available.
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:934Internal
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
truewhen the damage was cancelled or redirected and the caller should stop
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.
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.
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:1458Draws 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
nilExtra bar options, such asmaxValue,limitTextordrawBackground
Returns
- Number The bar's y position
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,yandwidthfields;yis updated - class String Where the bars are drawn;
'tab'centers them oninfo.x
cw.core:DrawCinematic(cinematicTable, curTime)
client internal gamemodes/catwork/gamemode/core/cl_kernel.lua:2749Internal
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
- cinematicTable Map The cinematic, as added by
cw.core:AddCinematicText - curTime Number The current time
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:2788Internal
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
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.
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:3013Draws 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:2040Draws a gradient rectangle.
Does nothing when the gradient type has no texture in cw.Gradients.
Parameters
- gradientType Number A
GRADIENT_*constant, such asGRADIENT_RIGHT - x Number X position
- y Number Y position
- width Number Width
- height Number Height
- color Color Draw color
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.
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:1797Draws 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
nilAlpha; defaults to the color's alpha - bAlignLeft Boolean optional, defaults to
falseDraw fromxinstead of centering on it - Callback Function optional, defaults to
nilCalled withx, y, width, height; returns the newx, y - shadowDepth Number optional, defaults to
1Thickness 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:1763Draws 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
nilAlpha; defaults to the color's alpha - bAlignLeft Boolean optional, defaults to
falseDraw fromxinstead of centering on it - Callback Function optional, defaults to
nilCalled withx, y, width, height; returns the newx, y - shadowDepth Number optional, defaults to
1Thickness 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:2365Draws 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
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,yandwidthfields;yis 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:2093Draws 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; usestextHeightanddrawBackground
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:2061Draws 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
100Unused
See also
cw.core:DrawSimpleText(text, x, y, color, alignX, alignY, shadowless, shadowDepth)
client gamemodes/catwork/gamemode/core/cl_kernel.lua:1613Draws 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
nilATEXT_ALIGN_*horizontal alignment - alignY Number optional, defaults to
nilATEXT_ALIGN_*vertical alignment - shadowless Boolean optional, defaults to
falseSkip the outline - shadowDepth Number optional, defaults to
1Thickness 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:2074Draws 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
100Maximum 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:1445Splits 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
falseRemove 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:1933Creates 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
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
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:629Formats 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
falseUse the singular format - lowerName Boolean optional, defaults to
falseLowercase the cash name; client only
Returns
- String The formatted amount
Returns the panel whose markup tool tip is shown.
Returns
- Panel The panel under the cursor, or
nil
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
Returns the alpha of the black screen fade.
Returns
- Number The alpha of the fade in or out, or
0when there is none
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
Returns the framework gamemode folder without the gamemodes/ prefix.
Returns
- String The folder name, such as
'catwork'
Returns the Lua path of the framework's gamemode/core directory.
Returns
- String The path, such as
'catwork/gamemode/core'
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
Returns the font size used for 3D2D text.
Returns
- Number Always
128
Returns the gradient texture.
Returns
- IMaterial The material stored in
cw.GradientTexture, made from thegradientoption
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:366Returns 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
nilParameters forMaterial, such as'smooth'
Returns
- IMaterial The material
Returns the notice panel when it is visible.
Returns
- Panel The panel, or
nil
Returns the absolute path of the game's root directory.
Returns
- String The full path without a trailing separator
Returns every prop_physics and prop_physics_multiplayer entity.
Returns
- List<Entity> The entities
Returns the layout of the player info box from the last time it was drawn.
Returns
- Map The box info returned by
cw.core:DrawPlayerInfo, ornil
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:610Returns 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
nilValue to return when no bone is close enough - minimum Number optional, defaults to
nilMaximum 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:643Returns 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 incw.HitGroupBonesCache, orHITGROUP_GENERIC
Returns the recognise menu.
Parameters
- menuPanel Panel Unused
Returns
- Panel The menu set with
cw.core:SetRecogniseMenu, ornil
Returns the path of the current schema's data folder.
Returns
- String The path,
settings/catwork/schemas/<schema>, relative to thegarrysmodfolder
Returns the schema folder, or a subfolder of its schema directory.
Parameters
- sFolderName String optional, defaults to
nilSubfolder inside<schema>/schema/
Returns
- String The folder name or path
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'stitle),author,descriptionandversionof the schema
Returns the name of the loaded schema.
Returns
- String The schema's name from
Schema:GetName, or'Catwork'before the schema has loaded
Returns the schema gamemode folder name.
Returns
- String The value of
cw.Schema
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
Returns the point HUD elements are centered on, slightly below the middle of the screen.
Returns
- Number X position
- Number Y position
Returns a short checksum of a string.
Parameters
- value String The value to hash
Returns
- Number The CRC divided by 100000, rounded up
Returns the names of all registered commands in alphabetical order.
Returns
- List<String> The command names
Returns the target ID data of the entity the local player is looking at.
Returns
- Map The value of
cw.TargetIDData
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
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:507Returns 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
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
nilwhen no menu was opened
cw.core:HandleItemSpawnIconClick(itemTable, spawnIcon, Callback)
client gamemodes/catwork/gamemode/core/cl_kernel.lua:2121Opens 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
nilCalled with the menu before the actions are added
See also
cw.core:HandleItemSpawnIconRightClick(itemTable, spawnIcon)
client gamemodes/catwork/gamemode/core/cl_kernel.lua:2288Runs 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:516Blocks 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
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,classesandblacklistfields
Returns
- Boolean Whether the player has access
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:1708Includes every Lua file in a directory; see util.IncludeDirectory.
Parameters
- directory String The directory
- bFromBase String optional, defaults to
nilPrefix for the directory;trueuses'catwork/gamemode/core/'
cw.core:IncludePlugins(directory, bFromBase)
shared gamemodes/catwork/gamemode/core/sh_kernel.lua:1726Includes 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
falsePrefix the directory with'catwork/'
Returns
- Boolean Always
true
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
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
Returns whether the character menu is open.
Parameters
- isVisible Boolean optional, defaults to
falseAlso require the panel to be visible
Returns
- Boolean Whether the menu is open, or
nilwhen it is not
Returns whether the local player is in the character menu.
Returns
- Boolean
truewhile the menu is open or has not been created yet
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;
falsefor invalid entities
Returns whether the info menu is open.
Returns
- Boolean Whether the info menu is open
Returns whether the screen has completely faded to black.
Returns
- Boolean Whether the black fade in is at full alpha
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
trueduring shutdown, otherwisenil
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
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
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:1542Turns 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:2447Wraps text in markup font and color tags.
Parameters
- text String The text
- color Color optional, defaults to
nilColor of the text - scale Number optional, defaults to
1Size multiplier for thecwTooltipfont
Returns
- String The markup
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
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
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
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
falseto restore the original font
cw.core:OverrideMarkupDraw(markupObject, sCustomFont)
client gamemodes/catwork/gamemode/core/cl_kernel.lua:2390Replaces 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
nilFont 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
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.
Returns the plural of some text.
Currently returns the text unchanged.
Parameters
- text String The text
Returns
- String The text
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
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
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_GENERICOne of theLOGTYPE_*enums - text String The message
cw.core:RegisterBackgroundBlur(panel, fCreateTime)
client gamemodes/catwork/gamemode/core/cl_kernel.lua:2600Blurs 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:275Registers 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
Hides the active Derma tool tip.
Removes a background blur registered with cw.core:RegisterBackgroundBlur.
Parameters
- panel Panel The panel or string key of the blur
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
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:323On 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
nilValue to return when the file is missing or invalid; an empty table ifnil
Returns
- Any The stored table, or
failSafewhen 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
nilValue 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:283On 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
nilValue to return when the file is missing or invalid; an empty table ifnil
Returns
- Any The stored table, or
failSafewhen 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
nilValue returned when there is no data; defaults to an empty table
Returns
- Map The data
Defined in
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
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, ornilwhen 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:432Internal
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
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, ornilwhen 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
On the server
Returns whether a file exists in the current schema's data folder.
Parameters
- fileName String File name without extension, as passed to
cw.core:SaveSchemaData
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
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
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
Changes the case of the first character of a string.
Parameters
- text String The text
- bCamelCase Boolean
trueto lowercase the first character,falseto uppercase it
Returns
- String The new text
- Number The number of replacements made
Sets the notice panel.
Parameters
- noticePanel Panel The panel
cw.core:SetOnLayoutCallback(target, Callback)
client gamemodes/catwork/gamemode/core/cl_kernel.lua:2325Runs 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
Stores the recognise menu and gives it its title.
Parameters
- menuPanel Panel The menu
See also
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
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
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
truefor'true','yes'or'1', otherwisefalse
Returns the components of a color.
Parameters
- color Color The color
Returns
- Number Red
- Number Green
- Number Blue
- Number Alpha
Returns whether a custom crosshair is in use.
Returns
- Boolean The value of
cw.CustomCrosshair
Removes falsy entries from the array part of a table, in place.
Parameters
- baseTable List The table to clean
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:452Wraps 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:1855Pads a number with leading zeros.
Parameters
- number Number The number
- digits Number Minimum length of the result
Returns
- String The padded number