> For the complete documentation index, see [llms.txt](https://wiki.redmodding.org/cyber-engine-tweaks/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.redmodding.org/cyber-engine-tweaks/cet-functions-deprecated/tweakdb-deprecated.md). Agents can also search and read this documentation through its [MCP server](https://wiki.redmodding.org/cyber-engine-tweaks/~gitbook/mcp).

# TweakDB (Deprecated)

Methods for interacting with TweakDB, the game's internal data store.

TweakDB is like the game’s database for gameplay features. It’s not actually code itself, but very large amounts of data structures, many of which link together, to make coherent gameplay elements.

TweakDB has two main elements: Flats, and Records Flats are just like a single piece of data, like a number, a string, a pointer to a record, etc. Records are like a collection of flats. Records have possible types, like a character record or a clothing record. The type of record determines what set of flats the record has.

An example of these gameplay features nearly entirely contained in TweakDB, would be the damaging quickhacks like Overheat, Contagion, and Short Circuit. The quickhack item to unlock them is in tweakdb, as well as the process of unlocking, making them show up on enemies, the uploading process, the status effect applied, all the special effects possible, as well as the stats to customize all of these things. Almost anything about these quickhacks can be changed in TweakDB.

{% hint style="info" %}
To transform a TweakDBID into a gameItemID, call `ItemId.FromTDBID(tbdID)`
{% endhint %}

## DebugStats

Print info about the TweakDB. Displays the number of flats, records, and queries, the size in bytes of flatDataBuffer, and the number of created records.

#### Definition

```swift
TweakDB:DebugStats() -> nil
```

#### Usage example

```lua
TweakDB:DebugStats()
```

{% hint style="info" %}
GameItemIdTo get a TweakDBId's human-readable record name rather than its hash, use `id.value`!
{% endhint %}

## GetRecord

Get a TweakDB record by name or ID.

#### Definitions

```swift
TweakDB:GetRecord(recordName: string) -> TweakDBRecord
```

```swift
TweakDB:GetRecord(recordID: TweakDBID) -> TweakDBRecord
```

#### Usage example

```lua
sticky_frag = TweakDB:GetRecord("Items.GrenadeFragSticky")
```

## GetRecords

Get a table of all TweakDB records under a given type.

#### Definition

```swift
TweakDB:GetRecords(recordTypeName: string) -> table<TweakDBRecord>
```

#### Usage example

```lua
grenades = TweakDB:GetRecords("gamedataGrenade_Record")
```

## Query

Get a TweakDB query by name or ID. Returns a table of TweakDBIDs.

#### Definitions

```swift
TweakDB:Query(queryName: string) -> table<TweakDBID>
```

```swift
TweakDB:Query(queryID: TweakDBID) -> table<TweakDBID>
```

#### Usage example

```lua
grenade_ids = TweakDB:Query("Query.GrenadeNoFaction")
```

## GetFlat

Get a TweakDB flat by name or ID.

#### Definitions

```swift
TweakDB:GetFlat(flatName: string) -> object
```

```swift
TweakDB:GetFlat(flatID: TweakDBID) -> object
```

#### Usage example

```lua
jump_stamina_cost = TweakDB:GetFlat("player.staminaCosts.jump")
```

## SetFlat

Set a TweakDB flat by name or ID and update it. Returns whether the flat was successfully set.

#### Definitions

```swift
TweakDB:SetFlat(flatName: string, newValue: object) -> boolean
```

```swift
TweakDB:SetFlat(flatID: TweakDBID, newValue: object) -> boolean
```

#### Usage example

```lua
success = TweakDB:SetFlat("player.staminaCosts.jump", 7.5)
```

## SetFlatNoUpdate

Set a TweakDB flat by name or ID without updating it. Returns whether the flat was successfully set.

#### Definitions

```swift
TweakDB:SetFlatNoUpdate(flatName: string, newValue: object) -> boolean
```

```swift
TweakDB:SetFlatNoUpdate(flatName: TweakDBID, newValue: object) -> boolean
```

#### Usage example

```lua
success = TweakDB:SetFlatNoUpdate("player.staminaCosts.jump", 7.5)
```

## Update

Update (flush data of) a TweakDB record by name, ID, or handle. Returns whether the update was successful.

#### Definitions

```swift
TweakDB:Update(recordName: string) -> boolean
```

```swift
TweakDB:Update(recordID: TweakDBID) -> boolean
```

```swift
TweakDB:Update(recordHandle: TweakDBRecord) -> boolean
```

#### Usage example

```lua
success = TweakDB:Update("player.staminaCosts.jump")
```

## CreateRecord

Create a new TweakDB record. Returns whether the record was created successfully.

#### Definitions

```swift
TweakDB:CreateRecord(recordName: string, recordTypeName: string) -> boolean
```

```swift
TweakDB:CreateRecord(recordID: TweakDBID, recordTypeName: string) -> boolean
```

## CloneRecord

Clone an existing record identified by `clonedRecordName` or `clonedRecordID` to a new record named `recordName` or with a `TweakDBID` of `recordID`. Returns whether the record was cloned successfully. If a record named `recordName` or with ID `recordID` already exists, this method will fail.

#### Definitions

```swift
TweakDB:CloneRecord(recordName: string, clonedRecordName: string) -> boolean
```

```swift
TweakDB:CloneRecord(recordName: string, clonedRecordID: TweakDBID) -> boolean
```

```swift
TweakDB:CloneRecord(recordID: TweakDBID,  clonedRecordName: string) -> boolean
```

```swift
TweakDB:CloneRecord(recordID: TweakDBID,  clonedRecordID: TweakDBID) -> boolean
```

## DeleteRecord

Delete an existing TweakDB record. Returns whether the record was deleted successfully.

#### Definitions

```swift
TweakDB:DeleteRecord(recordName: string) -> boolean
```

```swift
TweakDB:DeleteRecord(recordID: TweakDBID) -> boolean
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://wiki.redmodding.org/cyber-engine-tweaks/cet-functions-deprecated/tweakdb-deprecated.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
