Script Variables

Revision as of 04:12, 13 September 2023 by XnKradst (talk | contribs) (Created page with "Instead of regular JavaScript variables and properties (not to be confused with buildings), Commander Wars uses what are known as '''Script Variables''' to store data that can then be accessed across multiple functions. For example, let's say you want to make a CO that keeps track of the number of attacks made during a turn. While normal JavaScript variables and properties might suffice, they come with a couple issues: *They are not stored in game saves. This means if...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Instead of regular JavaScript variables and properties (not to be confused with buildings), Commander Wars uses what are known as Script Variables to store data that can then be accessed across multiple functions.

For example, let's say you want to make a CO that keeps track of the number of attacks made during a turn. While normal JavaScript variables and properties might suffice, they come with a couple issues:

  • They are not stored in game saves. This means if you save, restart the game and reload, the game won't remember whatever values were stored.
  • They are shared across all instances of the same CO, meaning if two players play the same CO in the same match, they'll both share the same values stored in those properties.

(page is work-in-progress)