Add vehicle listing support to admin client
The Admin Network has no native packet for listing individual vehicles, so list_vehicles() sends a "list_vehicles" command over the existing GameScript JSON channel and relies on a companion server-side script to reply with vehicle data via ServerGamescript. Requires subscribing to Gamescript updates (documented in docs/PROTOCOL.md) to receive the reply. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -322,6 +322,13 @@ class OpenTTDAdminClient:
|
||||
from .protocol import AdminUpdateType
|
||||
await self.poll(AdminUpdateType.CompanyStats, company_id)
|
||||
|
||||
async def list_vehicles(self, company_id=None):
|
||||
"""Request a list of vehicles via GameScript. company_id=None for all companies."""
|
||||
payload = {"command": "list_vehicles"}
|
||||
if company_id is not None:
|
||||
payload["company_id"] = company_id
|
||||
await self.send_gamescript(payload)
|
||||
|
||||
async def send_gamescript(self, json_data):
|
||||
"""Send a JSON string to the GameScript."""
|
||||
import json
|
||||
|
||||
Reference in New Issue
Block a user