This is a "cheat sheet" for the SnowStateVis system by YellowAfterlife!

Check out the GitHub page for more information.

Click on sections to expand/collapse them.
Quick display controls: Categories · Sections · Everything ·

Setting up
  1. Import the YYMPS file (from Releases) to your project.
    If you don't usually debug your project on desktop, you can omit the included files (and see the subsequent section)
  2. Add obj_snowstatevis to your first room
    (and make sure that you don't destroy/deactivate it on accident)

If you are solely or primarily debugging your project on web/mobile/consoles, you can set up a separate "server" project:

  1. Create a new GameMaker project
  2. Import the YYMPS file (from Releases) to your project.
    Import both the scripts and included files.
  3. Add obj_snowstatevis to your room
  4. Set want_client to false in obj_snowstatevis' Create event.
Using
  1. Use ssv_client.add(...) to register the state machines that you want to be observable in the watcher
  2. Run your game
  3. If you're testing on web/mobile/consoles, run the server project that you've created during setup.
  4. Open http://127.0.0.1:2080 in a web browser to access the watcher.
Watcher UI

It's a fairly simple web application, all things considered:

  • On the left, you have a list of state machines that are currently active in the connected games.
    You can watch/unwatch individual FSMs by ticking/un-ticking checkboxes next to their names.
  • Each watched state gets its own little panel containing the name and a state graph.
    The panels can be resized and will scroll if necessary.
  • The active state is highlighted in red.
  • A recent transition is indicated with a fading red arrow.
  • If multiple states and arrows are highlighted/flicker, your state machine is likely stuck and is changing states rapidly.
  • Clicking on a state-block forces a transition to that state.
    Note that this triggers a fsm.change() directly and can be used to transition between states that otherwise have no direct route between them.

API:

obj_snowstatevis
obj_snowstatevis

This is a helper object that sets up the system's server and client as necessary.

It defines the following global variables:

ssv_server

A SnowStateVisServer.

This will be undefined if we're running on web or it has been disabled.

ssv_client

A SnowStateVisClient.

If disabled (read: connect has not been called), this is not undefined but quietly backs out of any attempts to interact with it.

SnowStateVisServer
SnowStateVisServer

You shouldn't usually have to deal with it since obj_snowstatevis will create one for you, but you may.

new SnowStateVisServer(web_http_port, web_ws_port, game_tcp_port, game_ws_port)

Initializes a coordination server.

The ports don't really matter so long as they are different and you remember which one is which (you'll need this later).

server.start()

Starts up the server, usually called on game start / after creating it.

server.async_network()

Should be called in Async - Network event.

SnowStateVisClient
SnowStateVisClient

Setup (handled by obj_snowstatevis):

new SnowStateVisClient(name)

Initializes a game-side client/connection to the coordination server.

name is shown in the watcher(s).

connect(url, ws_port, tcp_port)

Starts connecting to the server. Ports are the same as game_ws_port and game_tcp_port that have been specified when creating a server.

update()

Should be called once per frame.

async_network()

Should be called in Async - Network event.

FSMs (handled by you):

add(fsm, name, ?transitions)

Registers a SnowState machine (fsm) to be displayed on the watcher(s).

name is for display.

transitions (optional) is a struct containing source➜destination(s) states, for example:

var name = object_get_name(object_index) + " " + string(int64(id));
ssv_client.add(fsm, name, {
    idle: ["up", "down"],
    up: "idle",
    down: "idle",
});

The system will automatically pick up transitions that have been added to SnowState machine using fsm.add_transition().

remove(fsm_or_name)

Removes a previously registered SnowState machine by either a reference or a name (as set in add).

This makes it disappear from the watchers.