Set the overhead text content||doc135471

September 20, 2022

Format

 Entity:setHeadText(x, y, txt) 
  • The class to which the function belongs:Entity

Description

Set the specified position above the head of the entity object to display the text content and synchronize it to other clients.


Precautions

  • If the x and y positions are both 0, the text content will replace the header name
  • The x and y positions are -2 to 2 for left to right, -3 to 1 for top to bottom

Parameters

Variable name type Description
x int Horizontal position, range [ -2, 2 ]
y int vertical position, range [ -3, 1 ]
txt string text content


Code Samples

On the server side of the entity objectmount script, register the entity object when it is createdCallback, set the display text at the specified position above the head of the entity object

Trigger.RegisterHandler(this:cfg(), "ENTITY_ENTER", function(context)
    local entity = context.obj1
    entity:setHeadText(0, -1, tostring(entity.objID))
end)