Skip to content

Commit 4890682

Browse files
committed
manual wip
1 parent 33b34f3 commit 4890682

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

MANUAL.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
## Identifiers
44

5-
Identifier is a packed 40-bit integer number. The first 20 bits are the index, and the last 20 bits are the version. To create a new identifier, use the `evolved.id` function.
5+
Identifiers are packed 40-bit integer numbers. The first 20 bits are the index, and the last 20 bits are the version. To create a new identifier, use the `evolved.id` function.
66

77
```lua
88
---@param count? integer
99
---@return evolved.id ... ids
1010
function evolved.id(count) end
1111
```
1212

13-
The `count` parameter is optional and defaults to `1`. The function returns one or more identifiers, depending on the `count` parameter. Maximum number of alive identifiers is `2^20-1` (1048575). After that, the function will throw an error `"| evolved.lua | id index overflow"`.
13+
The `count` parameter is optional and defaults to `1`. The function returns one or more identifiers, depending on the `count` parameter. The maximum number of alive identifiers is `2^20-1` (1048575). After that, the function will throw an error: "| evolved.lua | id index overflow".
1414

1515
Identifiers can be recycled. When an identifier is no longer needed, use the `evolved.destroy` function to destroy it. This will free up the identifier for reuse.
1616

@@ -39,7 +39,7 @@ function evolved.alive_all(...) end
3939
function evolved.alive_any(...) end
4040
```
4141

42-
Sometimes (for debugging purposes for example), it is necessary to extract the index and version from an identifier (or pack them back). The `evolved.pack` and `evolved.unpack` functions can be used for this purpose.
42+
Sometimes (for debugging purposes, for example), it is necessary to extract the index and version from an identifier (or pack them back). The `evolved.pack` and `evolved.unpack` functions can be used for this purpose.
4343

4444
```lua
4545
---@param index integer
@@ -53,7 +53,7 @@ function evolved.pack(index, version) end
5353
function evolved.unpack(id) end
5454
```
5555

56-
Here is an little example of how to use identifiers:
56+
Here is a little example of how to use identifiers:
5757

5858
```lua
5959
local evolved = require 'evolved'
@@ -70,7 +70,7 @@ assert(not evolved.alive(id)) -- check if the identifier is not alive now
7070

7171
## Entities, Fragments, and Components
7272

73-
First of all, we need to understand that entities and fragments are just identifiers. The differences between them are purely semantic. Entities are used to represent objects in the world, while fragments are used to represent types of components that can be attached to entities. Components, in the other hand, are any data that is attached to entities through fragments.
73+
First of all, we need to understand that entities and fragments are just identifiers. The differences between them are purely semantic. Entities are used to represent objects in the world, while fragments are used to represent types of components that can be attached to entities. Components, on the other hand, are any data that is attached to entities through fragments.
7474

7575
Here is a simple example of how to attach a component to an entity:
7676

@@ -102,9 +102,9 @@ assert(evolved.get(player, stamina) == 50)
102102

103103
We have created an entity called `player` and two fragments called `health` and `stamina`. We have attached the components `100` and `50` to the entity through our fragments. After that, we can retrieve the components using the `evolved.get` function.
104104

105-
We'll cover the `evolved.set` and `evolved.get` functions in more detail later in the section about modifying operations. For now, let's just say that they are used to setting and getting components from entities through fragments.
105+
We'll cover the `evolved.set` and `evolved.get` functions in more detail later in the section about modifying operations. For now, let's just say that they are used for setting and getting components from entities through fragments.
106106

107-
The main thing to understand here is that we can attach any data to any identifiers using another identifiers. And yes, since fragments are just identifiers, we can use them as entities too! This very useful for marking fragments with some metadata, for example.
107+
The main thing to understand here is that we can attach any data to any identifiers using other identifiers. And yes, since fragments are just identifiers, we can use them as entities too! This is very useful for marking fragments with some metadata, for example.
108108

109109
```lua
110110
local evolved = require 'evolved'
@@ -122,4 +122,4 @@ evolved.set(player, position, {x = 0, y = 0})
122122
evolved.set(player, velocity, {x = 0, y = 0})
123123
```
124124

125-
In this example, we have created a fragment called `serializable` and marked the fragments `position` and `velocity` as serializable. After that, we can write a function that will serialize entities. And this function will serialize only fragments that are marked as serializable. This is a very powerful feature of the library, and it allows us to create very flexible systems. Btw, fragments of fragments are usually called `traits`.
125+
In this example, we have created a fragment called `serializable` and marked the fragments `position` and `velocity` as serializable. After that, we can write a function that will serialize entities. And this function will serialize only fragments that are marked as serializable. This is a very powerful feature of the library, and it allows us to create very flexible systems. By the way, fragments of fragments are usually called `traits`.

0 commit comments

Comments
 (0)