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

summaryrefslogtreecommitdiff
path: root/doc/lua/player.md
blob: fd8ebd498c383f6aab21b60a2362f0cd4507a5a8 (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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
The player table contains functions with privileged access to the player which run in a few contexts on the client such as scripted interface panes, quests, and player companions.

---

#### `EntityId` player.id()

Returns the player's entity id.

---

#### `String` player.uniqueId()

Returns the player's unique id.

---

#### `String` player.species()

Returns the player's species.

---

#### `String` player.gender()

Returns the player's gender.

---

#### `String` player.isAdmin()

Returns whether the player is admin.

---

#### `Json` player.getProperty(`String` name, `Json` default)

Returns the value assigned to the specified generic player property. If there is no value set, returns default.

---

#### `void` player.setProperty(`String` name, `Json` value)

Sets a generic player property to the specified value.

---

#### `void` player.addScannedObject(`String` name)

Adds the specified object to the player's scanned objects.

---

#### `void` player.removeScannedObject(`String` name)

Removes the specified object from the player's scanned objects.

---

#### `void` player.interact(`String` interactionType, `Json` config, [`EntityId` sourceEntityId])

Triggers an interact action on the player as if they had initiated an interaction and the result had returned the specified interaction type and configuration. Can be used to e.g. open GUI windows normally triggered by player interaction with entities.

---

#### `Json` player.shipUpgrades()

Returns a JSON object containing information about the player's current ship upgrades including "shipLevel", "maxFuel", "crewSize" and a list of "capabilities".

---

#### `void` player.upgradeShip(`Json` shipUpgrades)

Applies the specified ship upgrades to the player's ship.

---

#### `void` player.setUniverseFlag(`String` flagName)

Sets the specified universe flag on the player's current universe.

---

#### `void` player.giveBlueprint(`ItemDecriptor` item)

Teaches the player any recipes which can be used to craft the specified item.

---

#### `void` player.blueprintKnown(`ItemDecriptor` item)

Returns `true` if the player knows one or more recipes to create the specified item and `false` otherwise.

---

#### `void` player.makeTechAvailable(`String` tech)

Adds the specified tech to the player's list of available (unlockable) techs.

---

#### `void` player.makeTechUnavailable(`String` tech)

Removes the specified tech from player's list of available (unlockable) techs.

---

#### `void` player.enableTech(`String` tech)

Unlocks the specified tech, allowing it to be equipped through the tech GUI.

---

#### `void` player.equipTech(`String` tech)

Equips the specified tech.

---

#### `void` player.unequipTech(`String` tech)

Unequips the specified tech.

---

#### `JsonArray` player.availableTechs()

Returns a list of the techs currently available to the player.

---

#### `JsonArray` player.enabledTechs()

Returns a list of the techs currently unlocked by the player.

---

#### `String` player.equippedTech(`String` slot)

Returns the name of the tech the player has currently equipped in the specified slot, or `nil` if no tech is equipped in that slot.

---

#### `unsigned` player.currency(`String` currencyName)

Returns the player's current total reserves of the specified currency.

---

#### `void` player.addCurrency(`String` currencyName, `unsigned` amount)

Increases the player's reserve of the specified currency by the specified amount.

---

#### `bool` player.consumeCurrency(`String` currencyName, `unsigned` amount)

Attempts to consume the specified amount of the specified currency and returns `true` if successful and `false` otherwise.

---

#### `void` player.cleanupItems()

Triggers an immediate cleanup of the player's inventory, removing item stacks with 0 quantity. May rarely be required in special cases of making several sequential modifications to the player's inventory within a single tick.

---

#### `void` player.giveItem(`ItemDescriptor` item)

Adds the specified item to the player's inventory.

---

#### `bool` player.hasItem(`ItemDescriptor` item, [`bool` exactMatch])

Returns `true` if the player's inventory contains an item matching the specified descriptor and `false` otherwise. If exactMatch is `true` then parameters as well as item name must match.

---

#### `unsigned` player.hasCountOfItem(`ItemDescriptor` item, [`bool` exactMatch])

Returns the total number of items in the player's inventory matching the specified descriptor. If exactMatch is `true` then parameters as well as item name must match.

---

#### `ItemDescriptor` player.consumeItem(`ItemDescriptor` item, [`bool` consumePartial], [`bool` exactMatch])

Attempts to consume the specified item from the player's inventory and returns the item consumed if successful. If consumePartial is `true`, matching stacks totalling fewer items than the requested count may be consumed, otherwise the operation will only be performed if the full count can be consumed. If exactMatch is `true` then parameters as well as item name must match.

---

#### `Map<String, unsigned>` player.inventoryTags()

Returns a summary of all tags of all items in the player's inventory. Keys in the returned map are tag names and their corresponding values are the total count of items including that tag.

---

#### `JsonArray` player.itemsWithTag(`String` tag)

Returns a list of `ItemDescriptor`s for all items in the player's inventory that include the specified tag.

---

#### `void` player.consumeTaggedItem(`String` tag, `unsigned` count)

Consumes items from the player's inventory that include the matching tag, up to the specified count of items.

---

#### `bool` player.hasItemWithParameter(`String` parameter, `Json` value)

Returns `true` if the player's inventory contains at least one item which has the specified parameter set to the specified value.

---

#### `void` player.consumeItemWithParameter(`String` parameter, `Json` value, `unsigned` count)

Consumes items from the player's inventory that have the specified parameter set to the specified value, upt to the specified count of items.

---

#### `ItemDescriptor` player.getItemWithParameter(`String` parameter, `Json` value)

Returns the first item in the player's inventory that has the specified parameter set to the specified value, or `nil` if no such item is found.

---

#### `ItemDescriptor` player.primaryHandItem()

Returns the player's currently equipped primary hand item, or `nil` if no item is equipped.

---

#### `ItemDescriptor` player.altHandItem()

Returns the player's currently equipped alt hand item, or `nil` if no item is equipped.

---

#### `JsonArray` player.primaryHandItemTags()

Returns a list of the tags on the currently equipped primary hand item, or `nil` if no item is equipped.

---

#### `JsonArray` player.altHandItemTags()

Returns a list of the tags on the currently equipped alt hand item, or `nil` if no item is equipped.

---

#### `ItemDescriptor` player.essentialItem(`String` slotName)

Returns the contents of the specified essential slot, or `nil` if the slot is empty. Essential slot names are "beamaxe", "wiretool", "painttool" and "inspectiontool".

---

#### `void` player.giveEssentialItem(`String` slotName, `ItemDescriptor` item)

Sets the contents of the specified essential slot to the specified item.

---

#### `void` player.removeEssentialItem(`String` slotName)

Removes the essential item in the specified slot.

---

#### `ItemDescriptor` player.equippedItem(`String` slotName)

Returns the contents of the specified equipment slot, or `nil` if the slot is empty. Equipment slot names are "head", "chest", "legs", "back", "headCosmetic", "chestCosmetic", "legsCosmetic" and "backCosmetic".

---

#### `void` player.setEquippedItem(`String` slotName, `Json` item)

Sets the item in the specified equipment slot to the specified item.

---

#### `ItemDescriptor` player.swapSlotItem()

Returns the contents of the player's swap (cursor) slot, or `nil` if the slot is empty.

---

#### `void` player.setSwapSlotItem(`Json` item)

Sets the item in the player's swap (cursor) slot to the specified item.

---

#### `bool` player.canStartQuest(`Json` questDescriptor)

Returns `true` if the player meets all of the prerequisites to start the specified quest and `false` otherwise.

---

#### `QuestId` player.startQuest(`Json` questDescriptor, [`String` serverUuid], [`String` worldId])

Starts the specified quest, optionally using the specified server Uuid and world id, and returns the quest id of the started quest.

---

#### `bool` player.hasQuest(`String` questId)

Returns `true` if the player has a quest, in any state, with the specified quest id and `false` otherwise.

---

#### `bool` player.hasAcceptedQuest(`String` questId)

Returns `true` if the player has accepted a quest (which may be active, completed, or failed) with the specified quest id and `false` otherwise.

---

#### `bool` player.hasActiveQuest(`String` questId)

Returns `true` if the player has a currently active quest with the specified quest id and `false` otherwise.

---

#### `bool` player.hasCompletedQuest(`String` questId)

Returns `true` if the player has a completed quest with the specified quest id and `false` otherwise.

---

#### `Maybe<WorldId>` player.currentQuestWorld()

If the player's currently tracked quest has an associated world, returns the id of that world.

---

#### `List<pair<WorldId, bool>>` player.questWorlds()

Returns a list of world ids for worlds relevant to the player's current quests, along with a boolean indicating whether that quest is tracked.

---

#### `Maybe<Json>` player.currentQuestLocation()

If the player's currently tracked quest has an associated location (CelestialCoordinate, system orbit, UUID, or system position) returns that location.

---

#### `List<pair<Json, bool>>` player.questLocations()

Returns a list of locations for worlds relevant to the player's current quests, along with a boolean indicating whether that quest is tracked.

---

#### `void` player.enableMission(`String` missionName)

Adds the specified mission to the player's list of available missions.

---

#### `void` player.completeMission(`String` missionName)

Adds the specified mission to the player's list of completed missions.

---

#### `void` player.hasCompletedMission(`String` missionName)

Returns whether the player has completed the specified mission.

---

#### `void` player.radioMessage(`Json` messageConfig, [`float` delay])

Triggers the specified radio message for the player, either immediately or with the specified delay.

---

#### `String` player.worldId()

Returns a `String` representation of the world id of the player's current world.

---

#### `String` player.serverUuid()

Returns a `String` representation of the player's Uuid on the server.

---

#### `String` player.ownShipWorldId()

Returns a `String` representation of the world id of the player's ship world.

---

#### `bool` player.lounge(`EntityId` loungeableId, [`unsigned` anchorIndex])

Triggers the player to lounge in the specified loungeable entity at the specified lounge anchor index (default is 0).

---

#### `bool` player.isLounging()

Returns `true` if the player is currently occupying a loungeable entity and `false` otherwise.

---

#### `EntityId` player.loungingIn()

If the player is currently lounging, returns the entity id of what they are lounging in.

---

#### `double` player.playTime()

Returns the total played time for the player.

---

#### `bool` player.introComplete()

Returns `true` if the player is marked as having completed the intro instance and `false` otherwise.

---

#### `void` player.setIntroComplete(`bool` complete)

Sets whether the player is marked as having completed the intro instance.

---

#### `void` player.warp(`String` warpAction, [`String` animation], [`bool` deploy])

Immediately warps the player to the specified warp target, optionally using the specified warp animation and deployment.

---

#### `bool` player.canDeploy()

Returns whether the player has a deployable mech.

---

#### `bool` player.isDeployed()

Returns whether the player is currently deployed.

---

#### `RpcPromise` player.confirm(`Json` dialogConfig)

Displays a confirmation dialog to the player with the specified dialog configuration and returns an `RpcPromise` which can be used to retrieve the player's response to that dialog.

---

#### `void` player.playCinematic(`Json` cinematic, [`bool` unique])

Triggers the specified cinematic to be displayed for the player. If unique is `true` the cinematic will only be shown to that player once.

---

#### `void` player.recordEvent(`String` event, `Json` fields)

Triggers the specified event on the player with the specified fields. Used to record data e.g. for achievements.

---

#### `bool` player.worldHasOrbitBookmark(`Json` coordinate)

Returns whether the player has a bookmark for the specified celestial coordinate.

---

#### `List<pair<Vec3I, Json>>` player.orbitBookmarks()

Returns a list of orbit bookmarks with their system coordinates.

---

#### `List<Json>` player.systemBookmarks(`Json` systemCoordinate)

Returns a list of orbit bookmarks in the specified system.

---

#### `bool` player.addOrbitBookmark(`Json` systemCoordinate, `Json` bookmarkConfig)

Adds the specified bookmark to the player's bookmark list and returns `true` if the bookmark was successfully added (and was not already known) and `false` otherwise.

---

#### `bool` player.removeOrbitBookmark(`Json` systemCoordinate, `Json` bookmarkConfig)

Removes the specified bookmark from the player's bookmark list and returns `true` if the bookmark was successfully removed and `false` otherwise.

---

#### `List<Json>` player.teleportBookmarks()

Lists all of the player's teleport bookmarks.

---

#### `bool` player.addTeleportBookmark(`Json` bookmarkConfig)

Adds the specified bookmark to the player's bookmark list and returns `true` if the bookmark was successfully added (and was not already known) and `false` otherwise.

---

#### `bool` player.removeTeleportBoookmark(`Json` bookmarkConfig)

Removes the specified teleport bookmark.

---

#### `bool` player.isMapped(`Json` coordinate)

Returns whether the player has previously visited the specified coordinate.

---

#### `Json` player.mappedObjects(`Json` systemCoordinate)

Returns uuid, type, and orbits for all system objects in the specified system;

---

#### `List<String>` player.collectables(`String` collectionName)

Returns a list of names of the collectables the player has unlocked in the specified collection.