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

summaryrefslogtreecommitdiff
path: root/doc/lua/openstarbound/world.md
blob: 8e0fef3fa2d2fc8ee1f3b02fe218489bec807b6a (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
# World

The world table now contains extra bindings.

---

#### `bool` world.isServer()

Returns whether the script is running on the server or client.

---

#### `bool` world.isClient()

Returns whether the script is running on the server or client.

---

The following additional world bindings are available only for scripts running on the client.

---

#### `entityId` world.mainPlayer()

Returns the entity ID of the player hosting the world.

---

#### `Vec2F` world.entityAimPosition(`entityId` entityId)

Returns the current cursor aim position of the specified entity.

---

#### `bool` world.inWorld()

Returns whether any players are in the world.

---

The following additional world bindings are available only for scripts running on the server.

---

#### `void` world.setExpiryTime(`float` expiryTime)

Sets the amount of time to persist a ephemeral world when it is inactive.

---

#### `string` world.id()

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

---

#### `Maybe<LuaValue>` world.callScriptContext(`String` contextName, `String` function, `String` contextName, [`LuaValue` args ...])

Calls a function in the specified world script context.

---

#### `?` world.sendPacket(`?` ?)

?

---

#### `bool` world.replaceMaterials(`List<Vec2I>` positions, `String` layerName, `String` materialName, [`int` hueShift], [`bool` enableDrops])

Attempts to replace existing materials with the specified material in the specified positions and layer. Positions with no preexisting material will be skipped. Returns `true` if the placement succeeds and `false` otherwise.

---

#### `bool` world.replaceMaterialArea(`Vec2F` center, `float` radius, `String` layerName, `String` materialName, [`int` hueShift], [`bool` enableDrops])

Identical to world.replaceMaterials but applies to tiles in a circular radius around the specified center point.

---