A... well, not _useful_, but amusing script

General feedback and discussion of the game.

Moderator: Forum Moderators

Post Reply
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

A... well, not _useful_, but amusing script

Post by turin »

This is a short little shell script I wrote for campaign writers.

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
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:

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"
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.
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
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: A... well, not _useful_, but amusing script

Post by AI »

Unfortunately it assumes that translatable strings are in the

Code: Select all

key= _ "text"
format, I usually put mine in the

Code: Select all

key=_"text"
format myself, and any format with non-linebreaking whitespace should work.

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
This should fix that issue (though you might have to set -E also, I don't have 1.5 to test it with here)
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Re: A... well, not _useful_, but amusing script

Post by Dave »

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.
You can correct this with a little Perl magic. :)

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
Trau
Posts: 119
Joined: October 21st, 2007, 7:34 pm

Re: A... well, not _useful_, but amusing script

Post by Trau »

:shock: 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?... :twisted:
Jozrael
Posts: 1034
Joined: June 2nd, 2006, 1:39 pm
Location: NJ, USA.

Re: A... well, not _useful_, but amusing script

Post by Jozrael »

I call shenanigans. You definitely hijacked mod powers to change your post count =o
User avatar
turin
Lord of the East
Posts: 11662
Joined: January 11th, 2004, 7:17 pm
Location: Texas
Contact:

Re: A... well, not _useful_, but amusing script

Post by turin »

OK, perl scripts have been introduced to this topic, it is now officially over my head. :P 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
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Re: A... well, not _useful_, but amusing script

Post by Dave »

turin wrote:OK, perl scripts have been introduced to this topic, it is now officially over my head. :P I think I can decipher what that script says, but I'm not really sure... anyway, cool.
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!
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
AI
Developer
Posts: 2396
Joined: January 31st, 2008, 8:38 pm

Re: A... well, not _useful_, but amusing script

Post by AI »

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
User avatar
pauxlo
Posts: 1047
Joined: September 19th, 2006, 8:54 pm

Re: A... well, not _useful_, but amusing script

Post by pauxlo »

Trau wrote:What I'd like to see is for someone to recall whose names those are of.
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.

Code: Select all

            name= _ "Bugg"
Bugg was this orc archer, which got a sea orc in Bay of Pearls.

Code: Select all

            name= _ "Delfador"
The main mage :-)

Code: Select all

            name= _ "Elrian"
The loyal mage we rescue on the mage island.

Code: Select all

                    name= _ "Gryphon Tender"
                    name= _ "Mounted Dwarf"
The first one was the shaman which tried to tame the gryphon, the second one the first dwarf sitting on such?

Code: Select all

            name= _ "Haldiel"
This is the loyal horseman from the second scenario.

Code: Select all

            name= _ "Kalenz"
            name= _ "Li'sar"
Two of the main characters, which don't really like each other in the beginning ...

Code: Select all

            name= _ "Moremirmu"
This is this white mage I never get, since I never go to isle of damned, playing the shaman-only variant lately (and isle of damned is not doable with recruiting only shamans, since you can't recruit them there ...)

Code: Select all

            name= _ "Ulfdain"
This is the ulfserker rescueable in this lost generals cave, isn't it? (I only can recall this name since it contains "Ulf" ...)

Hmm, quite few that I know without looking at the code (or savegames/replays). Where did Konrad disappear?
Post Reply