Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: stnschk.pl A perl script to find differences between RAWs and stonsesense  (Read 1910 times)

Maklak

  • Bay Watcher
    • View Profile

When I was helping to write stonsesense config for MLF mod, I was frustrated by not knowing which creatures were missing or what body parts could be used to colour sprites or what plants were missing from stonesense. So I wrote a perl script to answer questions like these. You might find it useful if you intend to write stonesense config for a mod, otherwise don't bother. Currently I can check for missing / non-existent plants (sorted by type: tree, crop, grass) as well as creatures with body parts and castes and finally non-existent equipment.

Download: https://dl.dropboxusercontent.com/u/71287918/Scripts/chkstns.pl

This script runs in command line (no GUI) and you need perl to use it. It will write to standard output, but you can redirect it to a file. Supported output types are "txt", "html", "bbcode" (what this forum uses) and "wiki" (but html works for wikis too). You can type
$ perl -w stnschk.pl -h
for help, but here is a run-down of some useful options:

Write output to a html file to view it in a web browser.
$ perl -w chkstns.pl -i=<stonesense_dir> -r=<RAW_dir> --html >out.html

Get information about a specific creature.
$ perl -w chkstns.pl -i=<stonesense_dir> -r=<RAW_dir> --det=2 | grep "DWARF"

Be more verbose.
$ perl -w chkstns.pl -i=<stonesense_dir> -r=<RAW_dir> --det=1 -list -wr >out.txt

I have no idea how to add checking building and terrain, so please tell me if you know. Comments, bug reports and feature requests are also welcome.

If you liked this, you might want to check some of my other scripts: http://www.bay12forums.com/smf/index.php?topic=126953.0

EDIT: Version 1.01 is out, with more readable html output.
EDIT: Version 1.02 is out. It is less verbose by default.
EDIT: Version 1.03 is out. It checks for misspelled professions (but not for those not allowed in entity.txt)

Here is some sample output (slightly outdated now):

WARNING: Redefinition of BIRD_CHICKEN in "stonesense/creatures/caravan_animals.xml" :3. Previously defined in "stonesense/creatures/large_128/domestic.xml" :85.
WARNING: Redefinition of BIRD_DUCK in "stonesense/creatures/caravan_animals.xml" :54. Previously defined in "stonesense/creatures/large_128/domestic.xml" :102.
WARNING: Redefinition of SHEEP in "stonesense/creatures/caravan_animals.xml" :103. Previously defined in "stonesense/creatures/large_128/domestic.xml" :43.
WARNING: Redefinition of GOAT_MOUNTAIN in "stonesense/creatures/wild_animals.xml" :54. Previously defined in "stonesense/creatures/large_128/wild.xml" :4.
WARNING: Redefinition of CAT in "stonesense/creatures/Wildlife.xml" :4. Previously defined in "stonesense/creatures/beefmo_domestics.xml" :206.
[...]



Listing files and read objects:

Stonesense files:
stonesense/buildings/AnimalTrap.xml
stonesense/buildings/ArmorStand.xml
stonesense/buildings/Ashery.xml
stonesense/buildings/Bed.xml
stonesense/buildings/Blueprint.xml
stonesense/buildings/Bowyers.xml
stonesense/buildings/Bridge.xml
stonesense/buildings/Butchers.xml
stonesense/buildings/Cabinet.xml
stonesense/buildings/Cage.xml
stonesense/buildings/CageTrap.xml
stonesense/buildings/caravan_1.png
stonesense/buildings/caravan_1.xml
stonesense/buildings/Carpenter.xml
stonesense/buildings/Chair.xml
stonesense/buildings/Chest.xml
stonesense/buildings/Clothiers.xml
stonesense/buildings/Coffin.xml
stonesense/buildings/Craftsdwarfs.xml
stonesense/buildings/Door.xml
stonesense/buildings/DoorsAndFloodgates.png
stonesense/buildings/Dyers.xml
stonesense/buildings/Farm.xml
stonesense/buildings/FarmersWorkshop.xml
stonesense/buildings/Fishery.xml
[...]

Files in Stonesense that appear to be unused. Some of theym can be required anyway, others (especially in subdirectories) may be deleted to reduce size. Make a backup before deleting anything.
stonesense/buildings/bgibs.png
stonesense/buildings/doorsAndWindows.png
stonesense/buildings/INFO generic.txt
stonesense/buildings/Table.xml~
stonesense/buildings/Workshop.txt
stonesense/colors/Colors_Grass_vherid.xml
stonesense/creatures.png
stonesense/creatures/clothed_Dwarves.xml
stonesense/creatures/color_dwarves.png
stonesense/creatures/color_Dwarves.xml
stonesense/creatures/color_poni.png
stonesense/creatures/color_poni.xml
stonesense/creatures/color_poni2.png
stonesense/creatures/color_poni_caste.xml
stonesense/creatures/color_ponibig.png
stonesense/creatures/color_ponibig_2.png
stonesense/creatures/dwarves.png
stonesense/creatures/Dwarves.xml
stonesense/creatures/elfs.png
stonesense/creatures/elfs.xml
stonesense/creatures/elves.png
stonesense/creatures/Elves.xml
stonesense/creatures/elves_hair.png
stonesense/creatures/elves_skin.png
stonesense/creatures/gobbos.png
[...]



Comparing RAWs and stonesense config:

Trees in RAWs, missing in xml (important): ACACIA

Bushes in RAWs, missing in xml: APPLESAUCE BERRY_SUN CELERY CHOCOLATE CHOCOLATEM COCOA COCOA_BEAN COTTON DANDELION FLAX GOLDENROD_FLOWERS JUTE PONY_APPLE PONY_APPLE_BASKET PONY_APPLE_QUALITY PONY_GRASS_WHEAT PONY_PROCESSED_WHEAT PONY_STRAW POTATO RADISH ROOT_CARROT SILK_ROSE SLIVER_BARB STRAWBERRY SUGAR_BEETS SUGAR_CANE SUNFLOWER SWEET_CHOCOLATE TURNIPS WATER WINTER LETTUCE

Grasses in RAWs, missing in xml (unimportant): BABY TOES SUCCULENT BAMBOO, ARROW BAMBOO, GOLDEN BAMBOO, HEDGE BENTGRASS BLUE SEDGE BUBBLE BULBS CARPETGRASS CATTAIL CAVE MOSS CLOUDBERRY COMMON REED COTTONGRASS DALLISGRASS DOG'S TOOTH GRASS DOWNY GRASS DROPSEED GRASS EYEBALL FESCUE GRASS FIELD SEDGE FLOOR FUNGI GRAMA HAIR GRASS KNOTGRASS MARSH THISTLE MEADOW-GRASS MEADOWSWEET MOUNTAIN AVENS NEEDLE GRASS PEBBLE PLANTS PURPLE MOOR GRASS REEDGRASS RUSH RYEGRASS SATINTAIL SAWGRASS VELVET GRASS WHITE MOUNTAIN HEATHER WORMY TENDRILS ZOYSIA

Checking creatures in xml for errors...
These creatures are defined in xml, but not in the RAWs. Unless some ot them are hardcoded, it should be safe to remove them from stonesense: "BIRD_EAGLE_GIANT", "CAVE_LOBSTER", "DEMON", "DWARF", "ELF", "FORGOTTEN_BEAST", "FROG_DEMON", "GOBLIN", "HORSE", "HUMAN", "KIWI_MAN", "KOBOLD", "LEECHMAN", "SLUGMAN", "SNAILMAN", "SPIRIT_OF_FIRE", "TENTACLE_DEMON", "TITAN", "TREANT", "WEREWOLF", "WHALE", "WIZARD"
Done checking creatures in xml.

Creatures in RAWs, missing in xml (important) (Skipped varieties: Vermin Giants Men ): "CHIMERA", "EQUIPMENT_WAGON"
« Last Edit: December 05, 2013, 09:13:52 am by Maklak »
Logged
Quote from: Omnicega
Since you seem to criticize most things harsher than concentrated acid, I'll take that as a compliment.
On mining Organics
Military guide for FoE mod.
Research: Crossbow with axe and shield.
Dropbox referral

Deon

  • Bay Watcher
  • 💀 💀 💀 💀 💀
    • View Profile
Re: stnschk.pl A perl script to find differences between RAWs and stonsesense
« Reply #1 on: November 27, 2013, 03:15:25 pm »

This is a great script. I will be adding sprites for creatures from my mods for Stonesense soon, it will help me a lot. Thank you!
Logged
▬(ஜ۩۞۩ஜ)▬
✫ DF Wanderer ✫ - the adventure mode crafting and tweaks
✫ Cartographer's Lounge ✫ - a custom worldgen repository

Maklak

  • Bay Watcher
    • View Profile
Re: stnschk.pl A perl script to find differences between RAWs and stonsesense
« Reply #2 on: November 27, 2013, 06:48:34 pm »

> This is a great script. I will be adding sprites for creatures from my mods for Stonesense soon, it will help me a lot. Thank you!
I suggest that you first list missing creatures, then use the -det=2 and grep by ID to get a list of body parts and castes for creatures you want detailed. List of equipment is provided with -det=1

Ah, good, someone who has a use for this. I thought this was so specialised that hardly anyone would care.

Well, if you have any suggestions or error reports please tell me.
The current TODO list has just "Add a command line option to get rid of that pesky Redefinition of a creature warning" and "Make sure FoE salvage is qualified as trees, not crops". Speed is not an issue, but I've run a profiler anyway and time is spent mostly reading data (can't be helped) and on regexps (can sometimes be tuned, but it isn't easy). I think that the output is too verbose, but I changed default settings to silence most of it, so it's tolerable now. Done. 

I would like to know how to check buildings and terrain, but the stonesense people are silent lately. Unless someone helps me make any breakthroughs here, proposes a sensible feature or finds a bug, I think I'm done working on this script and version 1.02 is final.
« Last Edit: November 28, 2013, 07:31:35 am by Maklak »
Logged
Quote from: Omnicega
Since you seem to criticize most things harsher than concentrated acid, I'll take that as a compliment.
On mining Organics
Military guide for FoE mod.
Research: Crossbow with axe and shield.
Dropbox referral