Author Topic: Scripts for level maintainers  (Read 433 times)

0 Members and 1 Guest are viewing this topic.

Online Simon

  • Administrator
  • Posts: 1975
    • View Profile
    • Lix
Scripts for level maintainers
« on: June 29, 2016, 06:13:39 am »
Are you on Linux? Make your life easy with scripts de luxe!

Even though Windows users tend to avoid shellscripting -- if you're cmd-savvy, a Powershellist, or use Python, I encourage you to share your Windows scripts.

Strip level from replays

You maintain replays for your awesome level pack. Replays may include a copy of their level. Lix has weird rules on whether to run the replay against the included level, or against the pointed-to level. To guarantee that Lix uses the pointed-to level at any time, strip the level from each replay file.

geoo and I have come up independently with solutions. Both solutions rely on how all levels' first lines begin with $BUILT<space>. The editor consistently saves like this, but it's not specced anywhere.

geoo's Python script is attached to this post. It creates new replay files without the levels. Alternatively, the following bash one-liner modifies replays in place. It doesn't keep backups. It recurses through subdirectories.

find . -name \*.txt -exec sed -i '/\$BUILT /Q' {} \;

Sum initial lix

From all levels recursively found within the current directory, we extract the number of lix, then compute the sum.

find . -name '*.txt' -exec grep "\#INITIAL " {} \; | awk '{s+=$2}END{print s}'

Mass-verify replays

Verify all levels recursively found in the given directory replays/path/to/your/dir. Lix will check all replays against their pointed-to level, then output which replays solve, or don't solve.

This command is the same in any Windows or Linux shell:

lix --coverage replays/path/to/your/dir

-- Simon
« Last Edit: August 28, 2017, 12:43:37 pm by Simon »

Online Simon

  • Administrator
  • Posts: 1975
    • View Profile
    • Lix
Re: Scripts for level maintainers
« Reply #1 on: July 16, 2016, 06:17:23 pm »
Delete all failing replays

You maintain a collection of replays in replays/path/to/your/dir. Over time, some are failing. You want to delete exactly the replays that point to a good level, yet don't solve that level.

This solution relies on the order of Lix's --verify output: The first comma-separated field contains (FAIL), and the second field contains the failing replay's filename.

Unix tools:
lix --verify replays/path/to/your/dir/ \
    | grep ^\(FAIL\) \
    | awk 'BEGIN { FS = "," }; { print $2; }' \
    | while read failingreplay; do rm "$failingreplay"; done


-- Simon
« Last Edit: July 31, 2017, 07:08:23 am by Simon »

Online Simon

  • Administrator
  • Posts: 1975
    • View Profile
    • Lix
Re: Scripts for level maintainers
« Reply #2 on: August 28, 2017, 08:07:53 am »
lix2gif: Export Lix animation as animated gif

Requires ImageMagick's convert to cut the source bitmap into pieces, then gifsicle to compose the animation. It's probably possible to do it all with just convert, but I haven't researched further. gifsicle does the job perfectly, the only problem would be that it's an extra dependency.

bash script (click to show/hide)



For example, the script produces the above animation from eater.T.png.

-- Simon
« Last Edit: August 28, 2017, 10:34:27 am by Simon »