Skip to main content

on_string_table

Attribute Macro on_string_table 

Source
#[on_string_table]
Expand description

Marks a method as a string table update handler.

This handler is called when string tables are updated. String tables contain game data like player names, modifiers, effects, etc. Optionally filter to specific table names.

§Parameters

The handler can receive:

  • ctx: &Context (optional) - Current replay state
  • table: &StringTable - The updated string table
  • modified: &[i32] - Indices of rows that were modified

§Filtering

Pass a table name to only handle that table:

#[on_string_table("userinfo")]
fn on_userinfo(&mut self, table: &StringTable, modified: &[i32]) -> ObserverResult {
    // Only called when userinfo table updates
    Ok(())
}

§Examples

§Track all string table updates

#[on_string_table]
fn on_table_update(&mut self, ctx: &Context, table: &StringTable, modified: &[i32]) -> ObserverResult {
    println!("[{}] Table {} updated: {} rows", ctx.tick(), table.name(), modified.len());
    Ok(())
}

§Monitor specific table

#[on_string_table("ActiveModifiers")]
fn on_modifiers(&mut self, table: &StringTable, modified: &[i32]) -> ObserverResult {
    println!("Active modifiers changed: {} rows", modified.len());
    Ok(())
}