Skip to content

Auto-define aliases for arguments based on function arg names #36

@ndahn

Description

@ndahn

I feel like the most alien "feature" of EMEVD is that numerical hodgepodge used to initialize events. It would be nice if Darkscript could (optionally?) create a preamble where all numbers used to initialize events are assigned to variables. The names could be based on the function args they are assigned to. For example:

// before
$InitializeEvent(0, 12020700, 12020710, 12021711, 12021710);
$InitializeEvent(0, 12023710, 12020700, 12020701);
$InitializeCommonEvent(0, 90005752, 12021710, 200, 120, 3);

// after 
// variable names are based on the function arg names they are passed to
// suffix to distinguish between items
const chrEntityId_0 = 12020710;
const assetEntityId_0 = 12021711;
const assetEntityId2_0 = 12021710;
const chrEntityId_1 = 12020700;
const chrEntityId2_1 = 12020701;

$InitializeEvent(0, 12020700, chrEntityId_0, assetEntityId_0, assetEntityId2_0);
$InitializeEvent(0, 12023710, chrEntityId_1, chrEntityId2_1);
// I'd argue that stuff like dummy poly IDs, sfx IDs and non-ints should not be aliased
$InitializeCommonEvent(0, 90005752, assetEntityId2_0, 200, 120, 3);

This has 3 advantages:

  1. it's much easier to change entity IDs and flags
  2. it's much easier to assign meaningful aliases and see where stuff is referenced
  3. it's much easier to see what everything passed to a function is supposed to be

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions