Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/cli/src/subcommands/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub fn cli() -> Command {
Arg::new("client-lang")
.long("client-lang")
.value_parser(clap::value_parser!(Language))
.help("The programming language for the generated client module bindings (e.g., typescript, csharp, python). If not specified, it will be detected from the project."),
.help("The programming language for the generated client module bindings (e.g., typescript, csharp, rust, unrealcpp). If not specified, it will be detected from the project."),
)
.arg(common_args::server().help("The nickname, host name or URL of the server to publish to"))
.arg(common_args::yes())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ slug: /intro/language-support

## Server Database Modules

SpacetimeDB modules define your database schema and server-side business logic. Modules can be written in three languages:
SpacetimeDB modules define your database schema and server-side business logic. Modules can be written in four languages:

- **[Rust](../../00200-core-concepts/00100-databases.md)** - High performance, compiled to WebAssembly [(Quickstart)](../00200-quickstarts/00500-rust.md)
- **[C#](../../00200-core-concepts/00100-databases.md)** - Great for Unity developers, compiled to WebAssembly [(Quickstart)](../00200-quickstarts/00600-c-sharp.md)
- **[TypeScript](../../00200-core-concepts/00100-databases.md)** - Ideal for web developers, runs on V8 [(Quickstart)](../00200-quickstarts/00400-typescript.md)
- **[C++](../../00200-core-concepts/00100-databases.md)** - Fits Unreal and C++ workflows, compiled to WebAssembly [(Quickstart)](../00200-quickstarts/00700-cpp.md)

## Client SDKs

Expand Down
31 changes: 31 additions & 0 deletions docs/docs/00200-core-concepts/00300-tables/00550-event-tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ slug: /tables/event-tables

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import { CppModuleVersionNotice } from "@site/src/components/CppModuleVersionNotice";

In many applications, particularly games and real-time systems, modules need to notify clients about things that happened without storing that information permanently. A combat system might need to tell clients "entity X took 50 damage" so they can display a floating damage number, but there is no reason to keep that record in the database after the moment has passed.

Expand Down Expand Up @@ -60,6 +61,21 @@ pub struct DamageEvent {
}
```

</TabItem>
<TabItem value="cpp" label="C++">

<CppModuleVersionNotice />

```cpp
struct DamageEvent {
Identity entity_id;
uint32_t damage;
std::string source;
};
SPACETIMEDB_STRUCT(DamageEvent, entity_id, damage, source)
SPACETIMEDB_TABLE(DamageEvent, damage_event, Public, true)
```

</TabItem>
</Tabs>

Expand Down Expand Up @@ -128,6 +144,21 @@ fn attack(ctx: &ReducerContext, target_id: Identity, damage: u32) {
}
```

</TabItem>
<TabItem value="cpp" label="C++">

<CppModuleVersionNotice />

```cpp
SPACETIMEDB_REDUCER(attack, ReducerContext ctx, Identity target_id, uint32_t damage) {
// Game logic...

// Publish the event
ctx.db[damage_event].insert(DamageEvent{target_id, damage, "melee_attack"});
return Ok();
}
```

</TabItem>
</Tabs>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ Start development mode with auto-regenerate client module bindings, auto-rebuild

Default value: `src/module_bindings`
* `--module-path <MODULE-PATH>` — Path to the SpacetimeDB server module, relative to current directory. Defaults to `<project-path>/spacetimedb`.
* `--client-lang <CLIENT-LANG>` — The programming language for the generated client module bindings (e.g., typescript, csharp, python). If not specified, it will be detected from the project.
* `--client-lang <CLIENT-LANG>` — The programming language for the generated client module bindings (e.g., typescript, csharp, rust, unrealcpp). If not specified, it will be detected from the project.

Possible values: `csharp`, `typescript`, `rust`, `unrealcpp`

Expand Down Expand Up @@ -659,4 +659,3 @@ Run `spacetime version --help` to see all options.
This document was generated automatically by
<a href="https://crates.io/crates/clap-markdown"><code>clap-markdown</code></a>.
</i></small>

4 changes: 3 additions & 1 deletion skills/cpp-server/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ FIELD_PrimaryKeyAutoInc(entity, id)
FIELD_Index(entity, name)
```

Options: `SPACETIMEDB_TABLE(Type, accessor, Public|Private)`
Options:
- `SPACETIMEDB_TABLE(Type, accessor, Public|Private)`: regular table
- `SPACETIMEDB_TABLE(Type, accessor, Public|Private, true)`: event table

Field constraints:
- `FIELD_PrimaryKey(accessor, field)`: primary key
Expand Down
Loading