Nightinggale
Deity
- Joined
- Feb 2, 2009
- Messages
- 5,381
People have tried to trace the origin and there are indications that it came from Syracuse. There is even a specific name to that trace, which is Archimedes. We will never know for sure, but I do say that it isn't unlikely. First of all he had the brain to come up with it. Also we do know very little of his father, but what we do know is that he was an astronomist and that he might have been as brilliant as Archimedes. At least he was viewed as a great astronomist who discovered new science, though we lost what precisely he discovered.lol too true. The Greeks didn't make that mistake and got right to it with the Antikythera Mechanism. (or was it the Progenitors all along...)![]()
For all we know he figured out how to speak with the Progenitors

I considered using perl, but I have used it very little. I decided on using bash because it has ok string handling and it is very easy and fast to write scripts. The downsite is that they are s l o w and that bash doesn't work natively in windows. However I haven't kept up to date with how to get bash in windows. I know cygwin should provide support for it, but I guess there are simpler ways to get it. Didn't TortoiseGit come with a bash installer btw? Maybe I should investigate this.Being inspired by your C++ generating script, I decided to start looking into the possibility of developing a simple script for XML generation using Perl XML::Simple . I think it may be possible to create a script that can read any XML file as a template (e.g. a file containing one standard XML entry for Yield or Unit or Profession etc), then read a second file listing content items to insert (eg list of all Professions); and then generate an XML file with one entry for each content item, while populating the content name across several tags appropriately for each content item (e.g. generating all the required tags for description and Pedia TXT_KEY references, dds icon file paths, etc.) It may take a little while to devise this and not 100% sure I can get one working (with my already rudimentary Perl skills being as rusty as the Antikythera mechanism), but if it's possible to get something like this working I think it could really accelerate development of total conversion mods/modmods and avoid tons of error-prone manual XML cut-and-paste.
![]()
If you have bash in windows (I think you can get it if you want), then you could write a script like this:
Spoiler :
#!/bin/bash
#first line tells where the bash exe is. The line might be different on different computers
# lines starting with # are comments
# the print commands. They print the number of tabs you want and then the argument, followed by a newline
function print1 {
function print2 {
function print3 {
function print4 {
function print5 {
# the real script
while TAGNAME in `cat input.txt`
do
#first line tells where the bash exe is. The line might be different on different computers
# lines starting with # are comments
# the print commands. They print the number of tabs you want and then the argument, followed by a newline
function print1 {
printf "\t"
echo "$1"
}echo "$1"
function print2 {
printf "\t\t"
echo "$1"
}echo "$1"
function print3 {
printf "\t\t\t"
echo "$1"
}echo "$1"
function print4 {
printf "\t\t\t\t"
echo "$1"
}echo "$1"
function print5 {
printf "\t\t\t\t\t"
echo "$1"
}echo "$1"
# the real script
while TAGNAME in `cat input.txt`
do
# this is a loop and it creates a variable called TAGNAME with the content of each line of input.txt
# first we make a new variable of the type name in lowercase
TYPE_lower=`echo "${TAGNAME}" | tr '[:upper:]' '[:lower:]'`
print2 "<ProfessionInfo>"
print3 "<Type>${TAGNAME}</Type>"
print3 "<Description>${TYPE_lower#*_}</Description>"
print3 "<Civilopedia>TXT_KEY_UNIT_${TAGNAME#*_}_PEDIA</Civilopedia>"
print3 "<Strategy>TXT_KEY_${TAGNAME}_STRATEGY</Strategy>"
# you get the idea with the copy paste from CIV4ProfessionInfos.xml
done
# first we make a new variable of the type name in lowercase
TYPE_lower=`echo "${TAGNAME}" | tr '[:upper:]' '[:lower:]'`
print2 "<ProfessionInfo>"
print3 "<Type>${TAGNAME}</Type>"
print3 "<Description>${TYPE_lower#*_}</Description>"
print3 "<Civilopedia>TXT_KEY_UNIT_${TAGNAME#*_}_PEDIA</Civilopedia>"
print3 "<Strategy>TXT_KEY_${TAGNAME}_STRATEGY</Strategy>"
# you get the idea with the copy paste from CIV4ProfessionInfos.xml
As you can see you just write the text you want it to print. If you want a variable, you just write ${name} and it will replace ${name} with whatever the content of name is before executing the line.
I used another variable call, which is ${name#*_}. It removes the first _ and everything before it, meaning PROFESSION_COLONIST becomes COLONIST.
There are all sorts of commands here: http://tldp.org/LDP/abs/html/string-manipulation.html
Actually to get Description right, it should be something like:
Spoiler :
TYPE_lower=`echo "${TAGNAME}" | tr '[:upper:]' '[:lower:]'`
TYPE_lower=${TYPE_lower#*_}
TYPE_upper=${TAGNAME#*_}
Description=${TYPE_upper:0:1}${TYPE_lower:1}
TYPE_lower=${TYPE_lower#*_}
TYPE_upper=${TAGNAME#*_}
Description=${TYPE_upper:0:1}${TYPE_lower:1}
Sure it's way more advanced than just the copy paste in the loop, but it will remove everything from before the _ and then it will print the first character from the uppercase string and then all the characters except the first from the lowercase string. However it shows the powers of bash string handlilng and gives an idea of what can be done with a fairly simple approach. Remember we generated 4 XML lines, which are different for each unit with those few lines and they are all based on just the name of the profession. We could also start the loop with
TAGNAME="PROFESSION_${TAGNAME}"
That way it assumes PROFESSION is missing in the txt input file.
This script has no understanding of what XML is, but it's so crude that it will not have to know. It just generates output, which happens to be able to be copy pasted into an XML document.
When executing the script, you could type something like "script.sh > output.txt". The red part makes it write the output to the file output.txt instead of on the screen. This could make copy pasting a lot easier.