Skip to content

Return of Reckoning

Wiki

RoR Wiki

API:AttachWindowToWorldObject

From RoR Wiki

UI Lua API · WorldObject functions
Version: WAR 1.4.8

Makes a window follow a world object (a player, creature or other object) on screen.

AttachWindowToWorldObject(windowName, worldObjectId)

Arguments

windowName
string – Name of the window to attach.
worldObjectId
number – ID of the world object, as given by the game data and events.

Returns

Nothing.

Details

  • The window is added to the object's list of attached windows. One object can have several windows, and the client does not check whether the window is already in the list.
  • Every frame, the client projects each attached object's position to the screen. For each attached window:
    • the window is shown when the point is on screen and hidden when it is not;
    • when the projected point moves, the window is moved so that it is centred horizontally on the point with its bottom edge on the point, then kept inside the screen.
  • For player objects the point is taken from the character's model when one is available.
  • When the object no longer exists, its attachments are removed automatically. The window itself is not destroyed.
  • The function needs at least two arguments and only reads the last two.

Errors

  • Error in function call 'AttachWindowToWorldObject': window %s does not exist

Example

Attaching an event-text anchor to its target, from default/easystem_eventtext/source/system_eventtext.lua:

-- Have to use MoveWindowToWorldObject() like
--   MoveWindowToWorldObject(self.m_Anchor, self.m_TargetObject, self.m_AttachHeight)
--   if we want to have scaled attachment?  Or modify AttachWindowToWorldObject() at some point.
AttachWindowToWorldObject(anchorWindowName, targetObjectNumber)

See also