element.var
Reads a named value from an element.
Signature
element.var(ref: ElementRef, name: HostValue, sticky?: AbiValue): HostValue
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
ref | ElementRef | Required | The element it works on, usually self. |
name | HostValue | Required | The name of the value to read. |
sticky | AbiValue | Optional | Marks the read so your result recalculates when this value changes. |
Returns
HostValue The value. Cast it to the type you expect.
Example
const hp: number = element.var(self, "hp") as number;
