You may have already spotted a flaw in this table. If the chest lid is closed and locked and anything interacts with it, it rattles and goes (back) into state 0. The problem comes when the Key at Lock is removed, and it puts the chest lid from state 1 back into state 0. In that case, it shouldn’t rattle. Rather than creating a separate state for every possible scenario, you will be cheating a bit, by creating a means to process the state without triggering its associated actions.
Another important convention you will be following: objects only contain metadata/information about their own transition actions. To trigger both the action object and the auxiliary objects into the specified state, you will be creating a lookup table. The information, or metadata, for the states and their associated actions will be similar to that in Table 9-2. Eventually, it will hold all of the information associated with the state, including short and long
descriptions to be displayed on mouseover and anything else required by the game. The only thing you will have to save for each action object is its current state, a simple integer.
Table 9-2. ChestLid Metadata