Skip to content
hugh greene edited this page Jun 20, 2022 · 1 revision

In Game Maker and in ENIGMA, other is a keyword representing another instance involved in a block of code. This varies by context:

  • In a collision event, other represents the instance with which the current instance is colliding (literally the other object involved).
  • In a with() statement, the scope is changed, and other represents the instance owning the calling scope. For example, if object0 says with (object1) { newscope }, other will be an instance of object0 inside newscope.
  • In an "applied" Action tile, other behaves the same way as in with(), referring to the calling instance.

Implementation

ENIGMA stores the current scope's calling instance in enigma::instance_event_iterator. Alongside that, it keeps a stack of struct iterator_level, which always contains a pointer to instance_event_iterator at its bottom. Finally, it stores enigma::instance_other to directly represent the most recently lost scope.

This stack is most easily manipulated by instantiating struct enigma::with_iter. In fact, that structure operates with() entirely:

  #define with(x) for (enigma::with_iter ENIGMA_WITHITER(enigma::fetch_inst_iter_by_int(x),enigma::instance_event_iterator->inst); \
    enigma::instance_event_iterator; enigma::instance_event_iterator = enigma::instance_event_iterator->next)

Upon instantiation, with_iter pushes the iterator_level stack with the variables mentioned above. Upon deconstruction, it pops the stack, restoring both variables to their original state.

Clone this wiki locally