Loop

From mugen-net
Revision as of 16:45, 23 April 2019 by Jesuszilla (talk | contribs) (Initial commit)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A loop, in traditional computer programming, allows for a sequence of statements to be declared only once, yet those statements may be executed several times in succession.[1] This allows for code reuse, leading to fewer possible sources of bugs.

Limitations

M.U.G.E.N itself does not provide a straightforward method to users for creating loops, however, they are possible. The only limitation is that the number of iterations cannot exceed 2500, as it relies on ChangeState at Time <= 0 to accomplish the task. 2500 is an arbitrary limit chosen by Elecbyte in order to limit the number of times a user can change into the same state from itself in order to prevent the user from accidentally creating an indefinite loop, which could otherwise freeze execution of the engine, causing one or more players to not respond to any further commands from either the player or the developer.

Usage

Loops are useful for iterating over data (typically in an array, which is roughly equivalent to the variable list M.U.G.E.N provides developers) and performing some operation on that data one element at a time.

References

Template:Reflist