3D Texts lets staff put texts and pictures on the surfaces of the map. They are placed and removed with the Text Tool and the Picture Placer of the tool gun, or from code with SurfaceText:add_text and SurfaceText:add_picture. The server keeps them in SurfaceText.texts and SurfaceText.pictures, saves them with the plugin data and sends them to every client, which draws them in the world and fades them out with distance.

Summary

Hooks

Loads the stored 3D texts and pictures when the framework loads its data.
Sends all stored 3D texts and pictures to the player who has just initialized.
Draws every placed 3D text and picture within fade range of the local player, plus a placement preview while the texts or pictures tool is equipped.
Registers the 'texts' and 'pictures' level design permissions.
Saves the 3D texts and pictures when the framework saves its data.

Methods

Adds a 3D picture, saves it and broadcasts it to all clients.
Adds a 3D text, saves it and broadcasts it to all clients.
Draws a preview of the picture configured in the pictures tool at the spot the local player is looking at.
Draws a translucent preview of the text configured in the texts tool at the spot the local player is looking at.
load()server
Reads the 3D texts and pictures from the plugin data storage, replacing the currently stored ones.
Asks the player's client to find the 3D picture they are looking at and request its removal.
Asks the player's client to find the 3D text they are looking at and request its removal.
save()server
Writes all 3D texts and pictures to the plugin data storage.
Finds the 3D picture hit by the trace and asks the server to remove it.
Finds the 3D text hit by the trace and asks the server to remove it.

Hooks

SurfaceText:LoadData()

server plugins/3dtexts/plugin/sh_plugin.lua:45

Implements hook LoadData

Loads the stored 3D texts and pictures when the framework loads its data.

SurfaceText:PlayerInitialized(actor)

server plugins/3dtexts/plugin/sh_plugin.lua:39

Implements hook PlayerInitialized

Sends all stored 3D texts and pictures to the player who has just initialized.

Parameters

  • actor Player

SurfaceText:PostDrawOpaqueRenderables(depth, skybox)

client plugins/3dtexts/plugin/cl_hooks.lua:20

Draws every placed 3D text and picture within fade range of the local player, plus a placement preview while the texts or pictures tool is equipped.

Parameters

  • depth Boolean whether the depth pass is being drawn
  • skybox Boolean whether the skybox is being drawn

SurfaceText:RegisterPermissions()

shared plugins/3dtexts/plugin/sh_plugin.lua:21

Implements hook RegisterPermissions

Registers the 'texts' and 'pictures' level design permissions.

SurfaceText:SaveData()

server plugins/3dtexts/plugin/sh_plugin.lua:50

Implements hook SaveData

Saves the 3D texts and pictures when the framework saves its data.

Methods

SurfaceText:add_picture(data)

server plugins/3dtexts/plugin/sh_plugin.lua:117

Adds a 3D picture, saves it and broadcasts it to all clients. Serverside only. Does nothing unless url, width and height are all present.

SurfaceText:add_picture({
  url         = 'https://example.com/poster.png',
  width       = 512,
  height      = 512,
  fade_offset = 0,
  pos         = trace.HitPos,
  normal      = trace.HitNormal,
  angle       = angle -- built the same way as for SurfaceText:add_text
})

Parameters

  • data Map picture data: url, width, height, pos, normal, angle and optional fade_offset

SurfaceText:add_text(data)

server plugins/3dtexts/plugin/sh_plugin.lua:92

Adds a 3D text, saves it and broadcasts it to all clients. Serverside only. Does nothing unless text, pos, angle, style and scale are all present.

local trace = actor:GetEyeTrace()
local angle = trace.HitNormal:Angle()
angle:RotateAroundAxis(angle:Forward(), 90)
angle:RotateAroundAxis(angle:Right(), 270)

SurfaceText:add_text({
  text        = 'Sample Text',
  style       = 5,                      -- 1 to 10, see the texts tool
  scale       = 1,
  color       = Color(255, 255, 255),
  extra_color = Color(255, 0, 0, 100),  -- background / shadow color
  fade_offset = 0,
  pos         = trace.HitPos,
  normal      = trace.HitNormal,
  angle       = angle
})

Parameters

  • data Map text data: text, style, scale, color, extra_color, pos, normal, angle and optional fade_offset

SurfaceText:draw_picture_preview()

client plugins/3dtexts/plugin/cl_hooks.lua:244

Draws a preview of the picture configured in the pictures tool at the spot the local player is looking at. A red box is drawn instead if the URL is not a png or jpg image.

SurfaceText:draw_text_preview()

client plugins/3dtexts/plugin/cl_hooks.lua:180

Draws a translucent preview of the text configured in the texts tool at the spot the local player is looking at.

SurfaceText:load()

server plugins/3dtexts/plugin/sh_plugin.lua:62

Reads the 3D texts and pictures from the plugin data storage, replacing the currently stored ones. Serverside only.

SurfaceText:remove_picture(actor)

server plugins/3dtexts/plugin/sh_plugin.lua:139

Asks the player's client to find the 3D picture they are looking at and request its removal. Serverside only; does nothing if the player lacks the 'pictures' permission.

Parameters

  • actor Player

SurfaceText:remove_text(actor)

server plugins/3dtexts/plugin/sh_plugin.lua:130

Asks the player's client to find the 3D text they are looking at and request its removal. Serverside only; does nothing if the player lacks the 'texts' permission.

Parameters

  • actor Player

SurfaceText:save()

server plugins/3dtexts/plugin/sh_plugin.lua:55

Writes all 3D texts and pictures to the plugin data storage. Serverside only.

SurfaceText:trace_remove_picture(trace)

client plugins/3dtexts/plugin/sh_plugin.lua:209

Finds the 3D picture hit by the trace and asks the server to remove it. Clientside only.

Parameters

  • trace Map trace result, e.g. from Player:GetEyeTraceNoCursor

Returns

  • Boolean true if a picture was hit and its removal was requested

SurfaceText:trace_remove_text(trace)

client plugins/3dtexts/plugin/sh_plugin.lua:176

Finds the 3D text hit by the trace and asks the server to remove it. Clientside only.

Parameters

  • trace Map trace result, e.g. from Player:GetEyeTraceNoCursor

Returns

  • Boolean true if a text was hit and its removal was requested

Defined in