TweakDB

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

TweakDB methods

DebugStats

TweakDB:DebugStats() -> nil

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.

TweakDB:DebugStats()

GetRecord

TweakDB:GetRecord(recordName: string) -> TweakDBRecord

TweakDB:GetRecord(recordID: TweakDBID) -> TweakDBRecord

Get a TweakDB record by name or ID.

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

GetRecords

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

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

grenades = TweakDB:GetRecords("gamedataGrenade_Record")

Query

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

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

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

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

GetFlat

TweakDB:GetFlat(flatName: string) -> object

TweakDB:GetFlat(flatID: TweakDBID) -> object

Get a TweakDB flat by name or ID.

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

SetFlat

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

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

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

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

SetFlatNoUpdate

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

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

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

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

Update

TweakDB:Update(recordName: string) -> boolean

TweakDB:Update(recordID: TweakDBID) -> boolean

TweakDB:Update(recordHandle: TweakDBRecord) -> boolean

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

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

CreateRecord

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

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

CloneRecord

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

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

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

DeleteRecord

TweakDB:DeleteRecord(recordName: string) -> boolean

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