Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/doc/lua/entity.md
blob: dc3ebd768d05b2fc14ef05b27f0508a75eb532b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# entity

The *entity* table contains functions that are common among all entities. Every function refers to the entity the script context is running on.

Accessible in:

* companion system scripts
* quests
* tech
* primary status script
* status effects
* monsters
* npcs
* objects
* active items

---

#### `EntityId` entity.id()

Returns the id number of the entity.

---

#### `LuaTable` entity.damageTeam()

Returns a table of the entity's damage team type and team number. Ex: {type = "enemy", team = 0}

---

#### `bool` entity.isValidTarget(`EntityId` entityId)

Returns whether the provided entity is a valid target of the current entity. An entity is a valid target if they can be damaged, and in the case of monsters and NPCs if they are aggressive.

---

#### `Vec2F` entity.distanceToEntity(`EntityId` entityId)

Returns the vector distance from the current entity to the provided entity.

---

#### `bool` entity.entityInSight(`EntityId` entityId)

Returns whether the provided entity is in line of sight of the current entity.

---

#### `Vec2F` entity.position()

Returns the position of the current entity.

---

#### `String` entity.entityType()

Returns the  type of the current entity.

---

#### `String` entity.uniqueId()

Returns the unique ID of the entity. Returns nil if there is no unique ID.

---

#### `bool` entity.persistent()

Returns `true` if the entity is persistent (will be saved to disk on sector unload) or `false` otherwise.