Skip to content

Commit f7c7475

Browse files
Force67gitbook-bot
authored andcommitted
GITBOOK-90: change request with no subject merged in GitBook
1 parent a130cd0 commit f7c7475

File tree

7 files changed

+247
-0
lines changed

7 files changed

+247
-0
lines changed

SUMMARY.md

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
* [First time launch](guides/client-setup/using-vortex-mod-manager-vmm/playing-skyrim-together-reborn/first-time-launch.md)
4848
* [Connecting to a server](guides/client-setup/using-vortex-mod-manager-vmm/playing-skyrim-together-reborn/connecting-to-a-server.md)
4949
* [Server setup](guides/server-guide/README.md)
50+
* [Page 1](guides/server-guide/page-1.md)
5051
* [ReadMe first](guides/server-guide/readme-first.md)
5152
* [Terminology](guides/server-guide/terminology.md)
5253
* [Overview](guides/server-guide/overview.md)
@@ -98,6 +99,11 @@
9899
* [The STRUI doesn't appear when I press RIGHT CTRL or F2](guides/troubleshooting/the-strui-doesnt-appear-when-i-press-right-ctrl-or-f2.md)
99100
* [The server list is not appearing](guides/troubleshooting/the-server-list-is-not-appearing.md)
100101
* [My game opens to a black screen for 2-10 seconds and then closes](guides/troubleshooting/black-screen-and-then-close.md)
102+
* [Scripting](guides/scripting/README.md)
103+
* [Core Math functions](guides/scripting/core-math-functions.md)
104+
* [Player functions](guides/scripting/player-functions.md)
105+
* [GameServer](guides/scripting/gameserver.md)
106+
* [Components](guides/scripting/components.md)
101107

102108
## General information
103109

guides/scripting/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Scripting
2+
3+
The ST server provides a set of scripting functions that you can use to customize and extend its functionality. To get started with scripting, create a subfolder in the server's "/resources/" directory with the name of your resource. Within that folder, create a "something.manifest" file that includes the following components:
4+
5+
```
6+
[Resource]
7+
name = "Example Resource"
8+
version = 1.0.0
9+
apiset = 1.0.0
10+
description = "Official skyrim together example resource"
11+
keywords = ["example", "resource"]
12+
license = "MIT"
13+
repository = ""
14+
homepage = "https://skyrim-together.com/"
15+
entrypoint = "main.lua"
16+
```
17+
18+
Once you have created the manifest file, you can place your script file in the same folder. It's important to note that the main script file must have the same name as the "entrypoint" property in the script manifest. With these files in place, your script will be loaded by the ST server and its functionality will be available for use.

guides/scripting/components.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Components
2+
3+
The Server achitecture uses components, since it is based on an ECS (Entity Component System) architecture.
4+
5+
In simple terms, imagine a video game world with many characters, items, and environmental objects. Each of these objects can have different attributes and behaviors, such as appearance, movement, health, and interactions with other objects. In a traditional programming approach, managing all these objects and their interactions can become complex and difficult.
6+
7+
Now, lets focus on components: Components are the attributes or properties of an entity. For example, a character entity may have components like position, health, and inventory. Components are designed to be small and reusable, which means they can be easily combined and shared between different entities.
8+
9+
Currently only the movementcomponent is exposed:
10+
11+
To get the `MovementComponent` instance for an entity, use the following Lua code:
12+
13+
```lua
14+
local entity = ... -- Replace this with the target entity
15+
local movementComponent = GetMovementComponent(entity)
16+
```
17+
18+
**Interact with the MovementComponent** After obtaining the movement component, you can access its properties using the dot (.) notation. For example:
19+
20+
```lua
21+
local position = movementComponent.Position
22+
local rotation = movementComponent.Rotation
23+
local direction = movementComponent.Direction
24+
local sent = movementComponent.Sent
25+
```
26+
+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# Core Math functions
2+
3+
### Table of Contents
4+
5+
1. Creating Vectors and Matrices
6+
2. Accessing Vector Components
7+
3. Vector and Matrix Operations
8+
4. Binding Core Math Functions
9+
10+
### Creating Vectors and Matrices
11+
12+
#### Creating `vec2` objects
13+
14+
```lua
15+
local v1 = vec2()
16+
local v2 = vec2(1.0)
17+
local v3 = vec2(1.0, 2.0)
18+
```
19+
20+
#### Creating `vec3` objects
21+
22+
```lua
23+
local v1 = glm.vec3()
24+
local v2 = glm.vec3(1.0)
25+
local v3 = glm.vec3(1.0, 2.0, 3.0)
26+
```
27+
28+
#### Creating `vec4` objects
29+
30+
```lua
31+
local v1 = glm.vec4()
32+
local v2 = glm.vec4(1.0)
33+
local v3 = glm.vec4(1.0, 2.0, 3.0, 4.0)
34+
```
35+
36+
#### Creating `mat3` objects
37+
38+
```lua
39+
local m1 = glm.mat3()
40+
local m2 = glm.mat3(1.0)
41+
local m3 = glm.mat3(glm.mat4())
42+
local m4 = glm.mat3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)
43+
```
44+
45+
### Accessing Vector Components
46+
47+
#### Accessing `vec2` components
48+
49+
```lua
50+
local x = vec2.x
51+
local y = vec2.y
52+
```
53+
54+
#### Accessing `vec3` components
55+
56+
```lua
57+
local x = vec3.x
58+
local y = vec3.y
59+
local z = vec3.z
60+
```
61+
62+
#### Accessing `vec4` components
63+
64+
```lua
65+
local x = vec4.x
66+
local y = vec4.y
67+
local z = vec4.z
68+
local w = vec4.w
69+
```
70+
71+
### Vector and Matrix Operations
72+
73+
#### Addition
74+
75+
```lua
76+
local result = vecA + vecB
77+
local result = vecA + scalar
78+
local result = scalar + vecA
79+
```
80+
81+
#### Subtraction
82+
83+
```lua
84+
local result = vecA - vecB
85+
local result = vecA - scalar
86+
local result = scalar - vecA
87+
```
88+
89+
#### Multiplication
90+
91+
```lua
92+
local result = vecA * vecB
93+
local result = vecA * scalar
94+
local result = scalar * vecA
95+
local result = matA * vecA
96+
```
97+
98+
#### Division
99+
100+
```lua
101+
local result = vecA / vecB
102+
local result = vecA / scalar
103+
local result = scalar / vecA
104+
```
105+
106+
#### Constants
107+
108+
```lua
109+
local pi = glm.pi
110+
local half_pi = glm.half_pi
111+
local quarter_pi = glm.quarter_pi
112+
local two_pi = glm.two_pi
113+
```
114+
115+
#### Functions
116+
117+
```lua
118+
local sqrt_result = glm.sqrt(x)
119+
local pow_result = glm.pow(x, y)
120+
local exp_result = glm.exp(x
121+
```

guides/scripting/gameserver.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# GameServer
2+
3+
GameServer is a singleton instance. To fetch use, use the following lua:
4+
5+
```lua
6+
local gameServer = GameServer:get()
7+
```
8+
9+
**Interact with the GameServer** After obtaining the game server instance, you can call methods from the `GameServer` class using the dot (.) notation. For example:
10+
11+
```lua
12+
gameServer:Kill(playerId)
13+
gameServer:Kick(playerId)
14+
local serverTick = gameServer:GetTick()
15+
```
16+
17+
**Send a chat message** To send a chat message from the server to a specific player, use the `SendChatMessage` method:
18+
19+
```lua
20+
local connectionId = 1 -- Replace this with the target player's connection ID
21+
local message = "Hello from the server!"
22+
gameServer:SendChatMessage(connectionId, message)
23+
```
24+
25+
Note that the message will be automatically sanitized to remove any HTML tags.
26+

guides/scripting/player-functions.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Player functions
2+
3+
4+
5+
**Access Player properties and methods** After fetching a player instance, you can access its properties and methods using the dot (.) notation. For example, to get the player's username, use:
6+
7+
```lua
8+
local username = newPlayer:GetUsername()
9+
```
10+
11+
Similarly, you can call other methods available in the `Player` class, such as:
12+
13+
```lua
14+
local id = newPlayer:GetId()
15+
local character = newPlayer:GetCharacter()
16+
local level = newPlayer:GetLevel()
17+
```
18+
19+
To set properties, use the same dot notation:
20+
21+
```lua
22+
newPlayer:SetUsername("NewUsername")
23+
newPlayer:SetLevel(5)
24+
```
25+
26+
**Interact with the PlayerManager** The `PlayerManager` allows you to interact with multiple players. To get the global instance of the `PlayerManager`, use:
27+
28+
```lua
29+
local playerManager = PlayerManager:get()
30+
```
31+
32+
Now you can call methods from the `PlayerManager` class:
33+
34+
```lua
35+
local playerCount = playerManager:Count()
36+
local player = playerManager:GetByConnectionId(connId)
37+
local allPlayers = playerManager:GetAllPlayers()
38+
```
39+
40+
**Iterate over all players** The `GetAllPlayers` function returns a table (Lua's version of an array) containing all players. To iterate over all players and perform actions, use a loop:
41+
42+
```lua
43+
local allPlayers = playerManager:GetAllPlayers()
44+
for _, player in ipairs(allPlayers) do
45+
local username = player:GetUsername()
46+
print("Player username: " .. username)
47+
end
48+
```

guides/server-guide/page-1.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Page 1
2+

0 commit comments

Comments
 (0)