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

summaryrefslogtreecommitdiff
path: root/doc/lua/quest.md
blob: 68010c073deae4e62a8643b6735ae0b783cfda3c (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# quest

The `quest` table contains functions relating directly to the quest whose script its run in.

---

#### `String` quest.state()

Returns the current state of the quest.

Possible states:
* "New"
* "Offer"
* "Active"
* "Complete"
* "Failed"

---

#### `void` quest.complete()

Immediately completes the quest.

---

#### `void` quest.fail()

Immediately fails the quest.

---

#### `void` quest.setCanTurnIn(`bool` turnIn)

Sets whether the quest can be turned in.

---

#### `String` quest.questId()

Returns the quest id.

---

#### `String` quest.templateId()

Returns the ID of the template used to make this quest.

---

#### `uint64_t` quest.seed()

Returns the seed used to generate the quest.

---

#### `Json` quest.questDescriptor()

Returns the quest descriptor including parameters.

---

#### `Json` quest.questArcDescriptor()

Returns the quest arc descriptor.

---

#### `Vec2F` quest.questArcPosition()

Returns the quest arc position. (?)

---

#### `String` quest.worldId()

Returns the world id for the quest arc.

---

#### `String` quest.serverUuid()

Returns the server uuid for the quest.

---

#### `QuestParameters` quest.parameters()

Returns all quest parameters.

---

#### `void` quest.setParameter(`String` name, `Json` value)

Sets a quest parameter.

---

#### `void` quest.setIndicators(`List<String>` indicators)

Set a list of quest parameters to use as custom indicators.

Example:
```
-- define indicators
local entityIndicator = {
  type = "entity",
  uniqueId = "techscientist"
}
local itemIndicator = {
  type = "item",
  item = "perfectlygenericitem"
}
local itemTagIndicator = {
  type = "itemTag",
  tag = "weapon"
}
local itemListIndicator = {
  type = "itemList",
  items = [ "perfectlygenericitem", "standingturret" ]
}
local monsterTypeIndicator = {
  type = "monsterType",
  typeName = "peblit"
}

-- set quest parameters for the indicators
quest.setParameter("entity", entityIndicator)
quest.setParameter("item", itemIndicator)
quest.setParameter("itemTag", itemTagIndicator)
quest.setParameter("itemList", itemListIndicator)
quest.setParameter("monsterType", monsterTypeIndicator)

-- add the set quest parameters to the indicators list
quest.setIndicators({"entity", "item", "itemTag", "itemList", "monsterType"})
```

---

#### `void` quest.setObjectiveList(`JsonArray` objectives)

Set the objectives for the quest tracker. Objectives are in the format {text, completed}

Example:
```lua
quest.setObjectiveList({
  {"Gather 4 cotton", true},
  {"Eat 2 cotton", false}
})
```

---

#### `void` quest.setProgress(`float` progress)

Sets the progress amount of the quest tracker progress bar. Set nil to hide. Progress is from 0.0 to 1.0.

---

#### `void` quest.setCompassDirection(`float` angle)

Set the angle of the quest tracker compass. Setting nil hides the compass.

---

#### `void` quest.setTitle(`String` title)

Sets the title of the quest in the quest log.

---

#### `void` quest.setText(`String` text)

Set the text for the quest in the quest log.

---

#### `void` quest.setCompletionText(`String` completionText)

Sets the text shown in the completion window when the quest is completed.

---

#### `void` quest.setFailureText(`String` failureText)

Sets the text shown in the completion window when the quest is failed.

---

#### `void` quest.setPortrait(`String` portraitName, `JsonArray` portrait)

Sets a portrait to a list of drawables.

---

#### `void` quest.setPortraitTitle(`String` portraitName, `String` title)

Sets a portrait title.

---

#### `void` quest.addReward(`ItemDescriptor` reward)

Add an item to the reward pool.