A... well, not _useful_, but amusing script
Moderator: Forum Moderators
A... well, not _useful_, but amusing script
This is a short little shell script I wrote for campaign writers.
Can you figure out what it does?
Basically, it produces a file with all of the character names in the campaign. (All the stuff with ISOLD is just to determine if the WML is 1.4-era or 1.5.) It's supposed to be useful for getting a quick list of how many characters you have, without having to go through all the scenario files.
Here's the file it produces for HttT:
There's 133 names here - though, you'll notice "The Queen is Dead" and "The Scepter of Fire" appearing here, and those aren't character names. Why? Because name= isn't unique to character names, it's also used for scenario names and item names. I exclude scenario names with the eight leading " " characters (which necessitates the file is correctly indented, BTW), but that doesn't exclude items. This problem doesn't crop up for 1.4-style WML, since user_description= is unique.
Which means there's 131 unique named characters in HttT (unless there's a bug in my script).
Not exactly useful information, but kind of fun.
Code: Select all
#!/bin/bash
ISOLD=`grep user_description [0-9E]* | wc -l`
if [[ $ISOLD > 0 ]] ; then
grep user_description [0-9E]* | sed s/^.*user_description// | sort | uniq > listofnames
else
grep " name= _ " [0-9E]* | sed s/^.*_// | sort | uniq > listofnames
fi
Basically, it produces a file with all of the character names in the campaign. (All the stuff with ISOLD is just to determine if the WML is 1.4-era or 1.5.) It's supposed to be useful for getting a quick list of how many characters you have, without having to go through all the scenario files.
Here's the file it produces for HttT:
Code: Select all
"Agadla"
"Aigaion"
"Aimucasur"
"Apalala"
"Asheviere"
"Bellrok"
"Bona-Melodia"
"Brugg"
"Bugg"
"Chantal"
"Cicyn"
"Clarustus"
"Dafeis"
"Darglen"
"Delfador"
"Dwaba-Kukai"
"Dwar-Ni"
"Earooa"
"Elcmar"
"Elrian"
"El'rien"
"Eonihar"
"Everlore"
"Gaga-Breuk"
"Galdrad"
"Galga"
"Gamlel"
"Geldar"
"Gelgar"
"Ginvan"
"Gryphon Tender"
"Gwaba"
"Gwarloa"
"Gwimli"
"Gwoama"
"Haaf-Garga"
"Haf-Mal"
"Haldiel"
"Halgar Du'nar"
"Haliel-Maga"
"Haralamdum"
"Heford"
"Heldaga"
"Herbert"
"Inalai"
"Jarla"
"Jarmal-Gorg"
"Josephus"
"Kaba"
"Kalenz"
"Keh Ohn"
"Kior-Dal"
"Knafa-Tan"
"Knafa-Telfar"
"Kojun Herolm"
"Konrad"
"Kwaboo"
"Lionel"
"Li'sar"
"Lord Bayar"
"Mabooa"
"Maga-Knafa"
"Malatus"
"Managa'Gwin"
"Merlunius"
"Mokho Kimer"
"Mokolo Qimur"
"Moremirmu"
"Mother Gryphon"
"Mounted Dwarf"
"Mriram"
"Muff Argulak"
"Muff Jaanal"
"Muff Malal"
"Na-alga"
"Nepba"
"Nethuns"
"Oceania"
"Parandra"
"Reglok"
"Relgorn"
"Robert"
"Secadius"
"Seimus"
"Selda-Mana"
"Shuuga-Mool"
"Simyr"
"Sir Alric"
"Sir Daryn"
"Sir Kalm"
"Sir Kaylan"
"Sir Ruga"
"Syryn"
"Szerkz"
"Tarcyn"
"The Queen is Dead"
"The Scepter of Fire"
"Tindolean"
"Tini"
"Triram"
"Ulfdain"
"Unan-Ka'tall"
"Uradredia"
"Urag-Tifer"
"Urug-Tan"
"Urug-Telfar"
"Usadar Q'kai"
"Veocyn"
"Warven"
"Xakae"
"Xnamas"
"Yran"
"Yredd"
Which means there's 131 unique named characters in HttT (unless there's a bug in my script).
Not exactly useful information, but kind of fun.
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
And I hate stupid people.
The World of Orbivm
Re: A... well, not _useful_, but amusing script
Unfortunately it assumes that translatable strings are in the
format, I usually put mine in the
format myself, and any format with non-linebreaking whitespace should work.
This should fix that issue (though you might have to set -E also, I don't have 1.5 to test it with here)
Code: Select all
key= _ "text"
Code: Select all
key=_"text"
Code: Select all
#!/bin/bash
ISOLD=`grep user_description [0-9E]* | wc -l`
if [[ $ISOLD > 0 ]] ; then
grep user_description [0-9E]* | sed s/^.*user_description// | sort | uniq > listofnames
else
grep " name=\s*_\s*" [0-9E]* | sed s/^.*_// | sort | uniq > listofnames
fi
Re: A... well, not _useful_, but amusing script
You can correct this with a little Perl magic.turin wrote: There's 133 names here - though, you'll notice "The Queen is Dead" and "The Scepter of Fire" appearing here, and those aren't character names. Why? Because name= isn't unique to character names, it's also used for scenario names and item names. I exclude scenario names with the eight leading " " characters (which necessitates the file is correctly indented, BTW), but that doesn't exclude items. This problem doesn't crop up for 1.4-style WML, since user_description= is unique.
Code: Select all
david@david-laptop:~/wesnoth/data/campaigns/Heir_To_The_Throne/scenarios$ perl -e 'while(<>) { $match = 0 if /\[[^\/].*\]/; $match = 1 if /\[unit\]/; print if $match and /name= _/; }' *.cfg | sort | uniq
name= _ "Aigaion"
name= _ "Apalala"
name= _ "Bellrok"
name= _ "Bugg"
name= _ "Cicyn"
name= _ "Darglen"
name= _ "Delfador"
name= _ "Delfador"
name= _ "Earooa"
name= _ "Elcmar"
name= _ "Elrian"
name= _ "Eonihar"
name= _ "Everlore"
name= _ "Gamlel"
name= _ "Gamlel"
name= _ "Gamlel"
name= _ "Gelgar"
name= _ "Gelgar"
name= _ "Gelgar"
name= _ "Ginvan"
name= _ "Gryphon Tender"
name= _ "Gwaba"
name= _ "Gwarloa"
name= _ "Gwimli"
name= _ "Gwoama"
name= _ "Haldiel"
name= _ "Heldaga"
name= _ "Inalai"
name= _ "Jarla"
name= _ "Kaba"
name= _ "Kalenz"
name= _ "Keh Ohn"
name= _ "Kwaboo"
name= _ "Li'sar"
name= _ "Mabooa"
name= _ "Moremirmu"
name= _ "Moremirmu"
name= _ "Mounted Dwarf"
name= _ "Mriram"
name= _ "Nepba"
name= _ "Nethuns"
name= _ "Oceania"
name= _ "Reglok"
name= _ "Seimus"
name= _ "Simyr"
name= _ "Syryn"
name= _ "Tarcyn"
name= _ "Tindolean"
name= _ "Tini"
name= _ "Triram"
name= _ "Ulfdain"
name= _ "Veocyn"
name= _ "Warven"
name= _ "Xakae"
name= _ "Xnamas"
name= _ "Yran"
name= _ "Yredd"
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
Re: A... well, not _useful_, but amusing script
What I'd like to see is for someone to recall whose names those are of.
edit: This turned out to be my 133th post. Coincidence?...
edit: This turned out to be my 133th post. Coincidence?...
Re: A... well, not _useful_, but amusing script
I call shenanigans. You definitely hijacked mod powers to change your post count =o
Re: A... well, not _useful_, but amusing script
OK, perl scripts have been introduced to this topic, it is now officially over my head. I think I can decipher what that script says, but I'm not really sure... anyway, cool.
For I am Turin Turambar - Master of Doom, by doom mastered. On permanent Wesbreak. Will not respond to private messages. Sorry!
And I hate stupid people.
The World of Orbivm
And I hate stupid people.
The World of Orbivm
Re: A... well, not _useful_, but amusing script
Ahh you should try to learn some Perl. It's a very natural extension of shell scripting and offers almost unlimited power for text processing!turin wrote:OK, perl scripts have been introduced to this topic, it is now officially over my head. I think I can decipher what that script says, but I'm not really sure... anyway, cool.
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
Re: A... well, not _useful_, but amusing script
Adding a little awk magic gets rid of whitespace-duplicates:
Code: Select all
perl -e 'while(<>) { $match = 0 if /\[[^\/].*\]/; $match = 1 if /\[unit\]/; print if $match and /user_description= _/; }' *.cfg | awk '{print $3}' | sort | uniq
Re: A... well, not _useful_, but amusing script
Hmm, Not all, but some I can recall, I think. I played the german version, so maybe I'm a bit handicapped by translations changing some names.Trau wrote:What I'd like to see is for someone to recall whose names those are of.
Code: Select all
name= _ "Bugg"
Code: Select all
name= _ "Delfador"
Code: Select all
name= _ "Elrian"
Code: Select all
name= _ "Gryphon Tender"
name= _ "Mounted Dwarf"
Code: Select all
name= _ "Haldiel"
Code: Select all
name= _ "Kalenz"
name= _ "Li'sar"
Code: Select all
name= _ "Moremirmu"
Code: Select all
name= _ "Ulfdain"
Hmm, quite few that I know without looking at the code (or savegames/replays). Where did Konrad disappear?