An implementation of the Babylonian Programming System for Godot.
Currently, Babylonian/G can be installed as a Godot plugin using one of two methods.
Clone this repository and remove anything outside addons/babylonian
that you don't need.
- Clone this repository somewhere and copy the
addons/babylonian
directory into your project. If needed, create theaddons
directory in your project first. - Open the plugin list via
Project > Project Settings... > Plugins
and then click onenable
next to thebabylonian
plugin.
demo.mp4
The system contains two parts: probes and examples. The former can be used to visualize the values of expressions in real-time. The latter allows recreation of specific game scenarios.
We have also included a simple platformer game in platformer.tscn
which can be used to experiment with probes and examples, but is not essential to the functionality of the plugin.
To attach a probe to any expression, simply wrap the expression with either B.probe(...)
or B.game_probe(...)
. Use the former if you only want to see the probe next to the line of code in the editor. Use the latter if you also want to see the probe directly in the game. Alternatively, choose Wrap in probe from the context menu after selecting the expression you want to probe (Currently, this method only supports B.probe
and not B.game_probe
).
The probe itself also always returns the expression that it is wrapping, therefore you can also use probes inside if conditions, for example. Probes can be created or modified while a game is running in the background, which is very useful for testing or debugging purposes.
Additionaly, you can also create multiple widgets for a single probe by passing a second parameter called group
. For each distinct value that is passed as the group
, a new widget is created which only shows values passed with the group
. This is useful when you have multiple instances of a class and still want to probe an expression: you can simply pass self
as the group
. Then, a widget is created for each instance of the class and each widget only shows the value for the corresponding instance. As a special case, if you pass a Node2D
as the group
and you use B.game_probe
, the in-game widgets will be attached to their corresponding nodes and will follow them when they move.
We currently support probes for colors, floats, strings and vectors. We automatically try to convert other data type to the ones that are supported, so most other data types can also be visualized, even though they may not have additional features characteristic to that data type.
- Start the game.
- In the top right, you'll find a UI for creating and restoring examples.
- Prepare your example (e. g. walk to a spot which you want to examine).
- Choose an example mode:
Mode Explanation Snapshot only Captures the state of the entire game Input Recording only Starts capturing all user input and stops after you press Stop recording in the top left Snapshot & Input Recording Takes a snapshot first, then immediately starts Input Recording - Press Start example or Ctrl+S.
- If your selected mode includes Input Recording:
- Perform the user input (e. g. jump around).
- Press Stop recording or Ctrl+S.
- The new example appears below the UI:
- The number (1) indicates the index of the example slot.
- The parentheses indicate the mode of the example: S stands for Snapshot and R for Input Recording.
- The [last] brackets show the last used slot.
- The input box contains the name of the example (Example 1). You can rename the example by typing in the input box. After you renamed the example, press Esc to prevent further user input from reaching the input box.
- The Loop checkbox is used when restoring the example, see below. It is only present for examples that include an input recording.
- The Save button is used to store the example on disk. When you click it, a file save dialog opens.
- The Restore button is used to apply the example.
- If the example includes a snapshot, the game state it captured will be restored.
- If the example includes an input recording, it will be played back.
- If Loop is enabled, the example will be restored again after the playback of the input recording has completed. This will repeat indefinitely.
- Playback of an input recording (looped or not) can be stopped using the Stop playback button in the top left.
- The Delete button is used to remove the example slot. This will not delete an example from disk.
- You can now restore the example using the Restore button (see above). You can also use a keyboard shortcut. First, press Ctrl+R, then
- Ctrl+1 through Ctrl+9 to load the example slot with the corresponding index. Ctrl+0 loads example slot 10. More than 10 example slots are not supported using this keyboard shortcut.
- Ctrl+R to load the example slot annotated with [last].
Examples can be saved to disk (see above). They will be saved as JSON files in the examples
directory in the top-level of your project.
- The checkbox Save next example to disk has the same effect as immediately pressing the Save button after a new example has been created.
- Examples can be loaded from disk using the Load from disk button. It opens a file picker dialog and loads the selected example into a new example slot.
- Multiple probes per line of code are unsupported. This also includes line continuations using a
\
at the end of the line. - It is currently not possible to serialize Godot's
RID
, which can break the snapshotting/example system on certain games. - After stopping the playback of an input recording, any keys pressed by the recording at this time remain pressed. You have to press the keys manually to release them.
- Sometimes, the UI for the examples system is scaled inappropriately.