Nightinggale
Deity
- Joined
- Feb 2, 2009
- Messages
- 5,443
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.



ProfessionsInfos.xml is now completed & uploaded.
Actually it's not too bad and it seems close to working, but I can't quite figure out how to access all the pointers and references in the hash and array data structure it generates from XML. Well I'll attach the preliminary version of that here too if anyone has some insight.
except for fragments of Basic and Scheme which I'm not sure is used widely outside of Intro to CS courses
When modding XML content, in my experience having to also open several TXT_KEY files for editing of Descriptions and Pedia and Strategy and make sure you have the right tags pasted, etc can often slow modding substantially and create reference errors. Now that this basic script is working, for the pre-release version all the English text for each content item can be done right in the XML file for that content, and moved later. Before release it'll be possible to use a similar script to grab text content from these tags and replace it with an appropriate TXT_KEY, while writing that TXT_KEY tag and text content to a text/xml file. (IIRC Dazio and isabelxxx made a similar script for their mod which they said helped them a lot.)



The new tags don't appear yet in the M:C XML itself, and it's hard to tell from the schema where they should go. I tried placing <YieldDemands> above <iMinAreaSize> or above <ConstructSound> but keep getting fatal XML loading errors each time from being out of the order it's expecting.
it took some doing, but the game now reads and recognizes all the generated xml. 