update parser docs for templates

This commit is contained in:
Sky Johnson 2025-07-29 08:53:40 -05:00
parent 19bc67233b
commit 44949f9529

View File

@ -90,6 +90,42 @@ Organize related fields with automatic prefixing:
``` ```
## Templates
Define reusable field groups that can be injected into packets:
```xml
<!-- Define template -->
<template name="position">
<f32 name="x,y,z">
<f32 name="heading">
</template>
<template name="appearance">
<color name="skin_color,hair_color,eye_color">
<str16 name="face_file,hair_file">
</template>
<!-- Use templates in packets -->
<packet name="PlayerUpdate">
<version number="1">
<i32 name="player_id">
<template use="position">
<i8 name="level">
<template use="appearance">
</version>
</packet>
```
Templates work with groups for prefixing:
```xml
<group name="current">
<template use="position">
</group>
<!-- Creates: current_x, current_y, current_z, current_heading -->
```
## Arrays ## Arrays
```xml ```xml
@ -125,6 +161,7 @@ Organize related fields with automatic prefixing:
| Attribute | Description | Example | | Attribute | Description | Example |
|-----------|-------------|---------| |-----------|-------------|---------|
| `name` | Field name(s), comma-separated | `"id,account_id"` | | `name` | Field name(s), comma-separated | `"id,account_id"` |
| `use` | Template name to inject | `"position"` |
| `if` | Conditional parsing expression | `"flag:has_guild"` | | `if` | Conditional parsing expression | `"flag:has_guild"` |
| `size` | Fixed array size for `char` type | `"10"` | | `size` | Fixed array size for `char` type | `"10"` |
| `count` | Array size variable | `"var:item_count"` | | `count` | Array size variable | `"var:item_count"` |
@ -210,6 +247,17 @@ playerName := result["player_name"].(common.EQ2String16).Data
## Complete Example ## Complete Example
```xml ```xml
<!-- Define reusable templates -->
<template name="position">
<f32 name="x,y,z">
<f32 name="heading">
</template>
<template name="appearance">
<color name="skin_color,hair_color,eye_color">
<str16 name="face_file,hair_file">
</template>
<substruct name="StatBonus"> <substruct name="StatBonus">
<i8 name="stat_type"> <i8 name="stat_type">
<i32 name="base_value" type2="f32" type2_if="stat_type==6"> <i32 name="base_value" type2="f32" type2_if="stat_type==6">
@ -221,7 +269,8 @@ playerName := result["player_name"].(common.EQ2String16).Data
<i32 name="player_id,account_id"> <i32 name="player_id,account_id">
<str16 name="player_name"> <str16 name="player_name">
<i8 name="level,race,class"> <i8 name="level,race,class">
<color name="skin_color,hair_color" if="version>=562"> <template use="position">
<template use="appearance" if="version>=562">
<str16 name="guild_name" if="flag:has_guild"> <str16 name="guild_name" if="flag:has_guild">
<i32 name="guild_id" if="flag:has_guild&level>=10"> <i32 name="guild_id" if="flag:has_guild&level>=10">
<i8 name="stat_count"> <i8 name="stat_count">