Summary
Hooks
Hooks
Adds a surface text under a new ID, saves the list and sends the text to every client.
Does nothing when any of text, pos, angle, style or scale is missing.
cwSurfaceTexts:AddText({
text = 'Nexus',
style = 1,
color = Color('#FFFFFF'),
extraColor = Color('#FF0000'),
angle = angle,
pos = trace.HitPos,
normal = trace.HitNormal,
scale = 1
})
Parameters
- data Map The text:
text,pos(Vector),normal(Vector),angle(Angle),style(1-6),scale,color,extraColor(the box color) and an optionalfadeOffset
cwSurfaceTexts:ClockworkInitPostEntity()
server gamemodes/catwork/plugins/surfacetexts/plugin/sv_hooks.lua:14Implements hook ClockworkInitPostEntity
Called after Catwork has loaded all of its entities; loads the saved surface texts.
Loads the current map's surface texts and ID counter from the schema data.
cwSurfaceTexts:PlayerSendDataStreamInfo(player)
server gamemodes/catwork/plugins/surfacetexts/plugin/sv_hooks.lua:8Implements hook PlayerSendDataStreamInfo
Called when a player's data stream info should be sent; sends them every surface text.
Parameters
- player Player The player receiving the data
cwSurfaceTexts:PostDrawOpaqueRenderables(bDrawingDepth, bDrawingSkybox, bDrawing3DSkybox)
client gamemodes/catwork/plugins/surfacetexts/plugin/cl_hooks.lua:19Called after opaque renderables are drawn; draws the surface texts and the text tool's preview.
While the local player holds the texts tool, a faded preview of the configured text is drawn where
they are looking. Every stored text within 1024 units plus its fadeOffset is drawn, fading out over
its last 256 units. Styles add layers: 2 and up a darkened copy behind the text (except style 3), 3
and up a black shadow, 5 and up a background box, and 6 makes the box pulse. Skips the depth and 3D skybox
passes.
Parameters
- bDrawingDepth Boolean Whether this is the depth pass
- bDrawingSkybox Boolean Whether the skybox is being drawn
- bDrawing3DSkybox Boolean Whether the 3D skybox is being drawn
Removes the surface text an admin is looking at.
Asks the player's client to find the text under their crosshair with cwSurfaceTexts:RemoveAtTrace,
which sends it back for removal. Does nothing for non-admins.
Parameters
- player Player The admin removing the text
cwSurfaceTexts:RemoveAtTrace(trace)
client gamemodes/catwork/plugins/surfacetexts/plugin/cl_plugin.lua:32Asks the server to remove the first surface text a trace runs through.
A text is hit when the trace crosses the line along its width and the hit position is within
5 * scale units of its height. The server removes it only if the player is an admin.
Parameters
- trace Map A trace result, such as from
GetEyeTraceNoCursor
Returns
- Boolean Whether a text was hit and a removal request was sent
Saves the surface texts and the ID counter to the schema data for the current map.
Implements hook SaveData
Called when Catwork saves its data; saves the surface texts.