Skip to content

Developer Utilities

marcavis edited this page Feb 14, 2016 · 17 revisions

The Frogatto engine comes with several useful developer utilities integrated into it. Utilities are always invoked using the command line arguments, --utility=<utility_name> <args>. This page contains examples for Linux.

Query Utility

The query utility is useful for processing Frogatto's FSON files with FFL. It simply takes a directory or file and will recursively process all .cfg files, executing a given formula on each. If that formula simply returns data values it will output the values, if the formula returns commands, it will execute those commands on the file.

Example: finding all objects with over 10 hitpoints:

./anura --utility=query modules/frogatto/data/objects 'if(hitpoints > 10, {(id): (hitpoints)})'

Example: doubling all objects' hitpoints:

./anura --utility=query modules/frogatto/data/objects 'set(hitpoints, hitpoints*2)'

Example: moving every 'lever' object 18 pixels up, and 6 pixels to the left:

./anura --utility=query modules/frogatto/data/level/ "map(filter(doc.character, value.type = 'lever'), [add(value.y, -18), add(value.x, -6)])"

The visit_objects() function is very useful in some cases. It returns a list of all {} objects within a node. e.g. if one wanted to find the values of all image: attributes found within objects, one might simply do this:

./anura --utility=query modules/frogatto/data/objects 'map(visit_objects(doc), value.image)' | sort | uniq -c

Notes

When the query utility modifies files, it does its best to preserve the file's current comments, spacing, and other attributes. It's not perfect, but it works reasonably well most of the time.

Render Level Utility

The render level utility outputs a level as an image it takes a level name and output file and renders them. It defaults to the module's level/ folder when looking for level files.

./anura --utility=render_level titlescreen.cfg titlescreen.png
Something went wrong with that request. Please try again.