Etarc Coders Club

Mandatory XKCD reference:

6 Likes

NP++ can handle format for various coding, including xml, which you select through the ā€˜Languageā€™ tab. I still do it this way, even though I should have likely coded up something by now to let Google sheet handle it all. The language files are pretty consistent when it comes to format, so Iā€™d likely rarely have to adjust a script. I do use scripts for some other NMS files. Just been lazy and a dislike for Google Apps Script. Not to mention the awkward way the decompiled exml files are generated. All tags are property tags, instead of properly named tags as youā€™d expect.

1 Like

For example:

<?xml version="1.0" encoding="utf-8"?>
<!--File created using MBINCompiler version (5.04.0.2)-->
<Data template="TkLocalisationTable">
  <Property name="Table">
    <Property value="TkLocalisationEntry.xml">
      <Property name="Id" value="SCAN_NO_TECH" />
      <Property name="English" value="No scan technology installed &lt;IMG&gt;SLASH&lt;&gt;" />
      <Property name="French" value="" />
      <Property name="Italian" value="" />
      <Property name="German" value="" />
      <Property name="Spanish" value="" />
      <Property name="Russian" value="" />
      <Property name="Polish" value="" />
      <Property name="Dutch" value="" />
      <Property name="Portuguese" value="" />
      <Property name="LatinAmericanSpanish" value="" />
      <Property name="BrazilianPortuguese" value="" />
      <Property name="SimplifiedChinese" value="" />
      <Property name="TraditionalChinese" value="" />
      <Property name="TencentChinese" value="" />
      <Property name="Korean" value="" />
      <Property name="Japanese" value="" />
      <Property name="USEnglish" value="" />
    </Property>
  </Property>
</Data>

So using a script makes it hard to reference tags, and instead requires some smart work-around using the attributes. I believe there was once a reason for doing it this way though, have to blame MBINCompiler for that, which is otherwise great!

3 Likes

Why didnā€™t they tell us in school, ā€œone day you will need to mod game files and get 1337 streetcred from gamers! So, do your regex homework!ā€

I have never seen a ā€œregex that just worksā€, lol. Only regexes that needed to be corrected a dozen times to hammer them into shape.

We are having the same conversations at work, plus, Iā€™m a wiki admin for another game and extracting values from the gameā€™s XML files for it (probably very similar to what you are doing). When itā€™s a one-off or rare task, I also use ā€œregular expression groupsā€ in NotePad++, as the others recommend here.

When I want to fully automate a complex search and replace in XML, I use a python library called beautifulsoup - which also uses regular expressions, and it would not be easier for todd to get started than just doing it in NotePad++. But maybe keep it in the back of your head.

Unfortunately regular expressions are not taught in two minutes in a forum post, still, I found them worth learning ā€“ for exactly what you are doing.

If you have specific questions like these, I guess just ask us and we give you the expression. Have you tried describing your request to a Large Language Model? They can generate regex and adjust them too when you ask for corrections.

6 Likes

I scrolled back and noticed that apparently I have been adding to my script for over a year already! (I found the missing values; mass is calculated by adding up the masses of the ingredients, and Wattage appears as one of three values depending on block type. I am still working on calculating inventory capacity.) Turns out, 10 years old games are not very consistent. :wink:

In the last few months, I have been working on integrating a wikimedia feature which may also be of interest to the NMS wiki, itā€™s called Cargo: You use it when you add properties or a recipe to the wiki, then you can have the infobox put the values also into a database.

And then on the page about one of the materials, you could add a table that lists all products made with this material; this table then updates itself when you update the recipes elsewhere! Or for NMS ship or suit upgrades, you could describe their stats on their pages, and on a higher level page, you could have a sortable table to compare them all!

To use it, I need to update the Template and also hundreds of existing wiki pages to the new info box format. So Iā€™m experimenting with a python scriptā€¦ that sends bot API calls ā€¦ that can do bulk search and replace ā€¦ across a whole wiki. :exploding_head: (PS: Iā€™m not running the script on the live wiki, but on a test wiki, for now.) :grimacing:

3 Likes