Custom Command IDs

Currently in S44:

CMD_UPGRADE = 31140 + number of upgrade defs CMD_MORPH_STOP = 32210 CMD_MORPH = 31210 + number of morph defs CMD_PLANES = 34400 + number of sortie defs CMD_SMOKE = 35520 CMD_TURN = 35521 CMD_CLEARMINES = 35522 CMD_AREAATTACK = 39954

I was thinking of perhaps making some table in GG such that each custom command ID was SOME_BASE_NUMBER + NUMBER_OF_COMMANDS_ALREADY_DEFINED to avoid having to keep track of these, though that then might make it hard to reference them in widgets or whatever, so the table should probably keep track of what they are too. i.e.

local CMD_SMOKE = GG.NextCommandID GG.Commands["CMD_SMOKE"] = CMD_SMOKE GG.NextCommandID = GG.NextCommandID + 1

(I don’t fully understand GG and _G and passing stuff to unsynced in this manner)

The alternative is to have a Commands.h.lua which contains them all in one place and is included into each gadget with a custom command.

GG is a normal table with the only “special” property that there is only one such table, shared between all gadgets.

_G is a reference to the table with all globals. This table can be accessed in unsynced though the `magical’ SYNCED table.


In each gadget:

local CMD_SMOKE = GG.NextCommandID _G.Commands["CMD_SMOKE"] = CMD_SMOKE GG.NextCommandID = GG.NextCommandID + 1

In a widget that needs the command:

local smokeCommandID = SYNCED.Commands["CMD_SMOKE"]