MATT Infinite Loops - ironmonk88/monks-module-wiki GitHub Wiki

Infinite Loops

Infinite loops are the result of either a circle being built in your action flow, or a tile causing an event that causes the tile to trigger itself again, causing the event again, and so on.

$\color{red}{\textsf{Do Not Do This!}}$

https://github.com/ironmonk88/monks-module-wiki/blob/74aef2bf1126fcda856c1cb6a7f514d149eae240/MATT/Infinite_Loops/Infinite_Loops_01.png

Above is a theoretical (by which I mean I'm not testing it) tile setup that will crash your Foundry instantly upon loading in. It makes use of the Landing and Jump to Landing actions, and is triggered on Scene Change.

In order to fix this, you would have to set your Foundry to safe mode and delete the tile.

$\color{red}{\textsf{Also Don't Do This}}$

https://github.com/ironmonk88/monks-module-wiki/blob/74aef2bf1126fcda856c1cb6a7f514d149eae240/MATT/Infinite_Loops/Infinite_Loops_Zombie_Apocalypse_Example.gif

Example of a tile that creates tokens within itself, which triggers on Token Creation to create another token, resulting in a zombie apocalypse your Foundry data going crazy.

Causing Infinite Loops

Landings and any of the various logic functions that redirect the action flow to landings can cause an infinite loop if the landing is placed before the jump/redirect to that landing.

Other ways to cause infinite loops include doing something that will trigger the tile and cause the resulting action again (these are not all possible ways to create an infinite loop, just some examples).

  • An On Token Create trigger that Creates a Token within the tile.
  • An On Rotate trigger that Rotates a token within the tile.
  • An On Elevation Change trigger that changes the Elevation of a token within the tile.

Using Infinite Loops

Several sample tiles such as the [Clock](/ironmonk88/monks-module-wiki/wiki/ST-Clock) or [Lighthouse](/ironmonk88/monks-module-wiki/wiki/ST-Lighthouse) use infinite loops; you need to make sure there's enough actions & delay involved in the loop so it isn't trying to run everything all at once. There isn't a magic number, but usually a 0.2 second delay will be enough; this can vary depending on your PC/hosting method processing power.

Having an infinite loop running while editing tiles will usually cause all your changes to be lost, if the scene document gets re-written before any changes you made were saved.

Having infinite loops running can impact your Foundry performance.

Interrupting Infinite Loops

  • Deactivate the tile; either by right-clicking and doing it manually, or with another tile using the Activate/Deactivate action.
  • Another tile can use Stop All Remaining Actions targeting the looping tile; this may have some timing issues depending on where in the loop the stop is triggered.

Page Last Updated

MATT 11.22