widget

comment

A widget is an "interactive game object" with HP, possibly an inventory etc.

Types unit, destructable, item extend from widget. Widget is the parent type and unit etc. are the descendant types (children).

Therefore all API functions that accept widget as a type, will also work with any of the children types.

However if doesn't work the other way around, then you need to explicitly cast the type by pushing it through a hashtable, this is called "downcasting":

  1. Put the widget object in a hashtable
  2. Retrieve it as unit/destructable/item - needed since 1.24b, source

Example (Lua):

hasht = InitHashtable() -- for type-casting
SaveWidgetHandle(hasht, 1, 1, widgetHandle) -- put as widget
itemHandle = LoadItemHandle(hasht, 1, 1) -- retrieve as item

See TriggerRegisterDeathEvent for a full practical example.

patch

1.00

Source
common.j
Source code
type widget             extends     agent  // an interactive game object with life