Mod authors, making a better tomorrow.

10 posts / 0 new
Last post
#1
Mod authors, making a better tomorrow.

Intro

Going to keep this short.

As your mod gets more lines of code, it gets harder to maintain.

Unless you adopt a set of self-imposed rules to follow while making your mod, having a poor plan makes your mod harder to read, fix, update, and do. Maintainability is critically important.

Lay's Plan

All you need to do, is 4 things.

Spoiler: Highlight to view
IMAGE(https://i.imgur.com/JmnmT9e.png)
Spoiler: Highlight to view
IMAGE(https://i.imgur.com/VWhg0ih.png)
Spoiler: Highlight to view
Categorize your IDs; For each code block you create, give it's ID a specific branch of numbers.
IMAGE(https://i.imgur.com/Kh5IEvK.png)

for example:
IMAGE(https://i.imgur.com/Ux92T9q.png)

Spoiler: Highlight to view
IMAGE(https://i.imgur.com/strL01y.png)

Summary

1) Name the services/features your mod provides.
2) Tag all blocks of code with one of those named comments.
3) Lead ID's with specific numbers, making them easier to read and "find".
4) Structure your "Itemtype" ID's for the same purpose as #3; it makes Search and Replace easier.

With those 4 things, you can now "find" anything with zero clutter in the search results; remembering, understanding, and following an entire feature set is now simple.

Video

(Study my mod "Overhaul" for a complete and current example.)

OverHaul Mod
DevKit is an upgraded BBC mod.
Improve your mods.

reserved.

OverHaul Mod
DevKit is an upgraded BBC mod.
Improve your mods.

reserved.

OverHaul Mod
DevKit is an upgraded BBC mod.
Improve your mods.

I did something similar, but went a different tack.
It can be applied to vanilla data files, and doesn't need to renumber existing mods.

(OPTIONAL, but I like doing this for organization)
For all mods, split the neogame.xml into separate files under a 'data' subfolder, based on table names, like this:

Spoiler: Highlight to view
For example, you have "Overhaul" in "\NEO Scavenger\mods\Overhaul"
The "neogame.xml" is under "\NEO Scavenger\mods\Overhaul\AddOn"
Create the folder "\NEO Scavenger\mods\Overhaul\AddOn\data"
For each unique <table name="something" > create a file "something.xml" in the new "data" subfolder.
Paste in the XML header and footer!
(That's all the stuff that comes before the first table, and the "</database></pma_xml_export>" at the end.)
Copy all the "something" tables from neogame.xml to their "something.xml" file.
Do this for every table.
rename "neogame.xml" to "neogame.backup".

There is a regex search-replace I use in Notepad++ to make files easier to search.
In both vanilla and in mods, do the following:

Spoiler: Highlight to view
Open all XML files in Notepad++.
Open search-replace.
Set to regex.
Check the box for ". matches newline"
Use the search string:
^(\s*)(<table name="((?!gamevars|itemtypes)[^"]*)">\s+<column name="[^"]*">([^<]*)</column>\s+.*?"(strName|strDesc|strPropertyName)">([^<]*)</column>)
Use the replace string:
\1<!--\3:\4; \6 -->\n\1\2
Click "Replace in all Opened documents".
Save all, close all.

This will put a comment above every table that shows the ID and the internal name or description.
Examples:
<!--camptypes:10; Clearbone Valley Basement -->
<!--battlemoves:8; Advance Under Cover -->
<!--attackmodes:31; arrow stab: crude broadhead -->
<!--treasuretable:51; abandoned apartment building scavenged items -->
<!--itemprops:25; radioactive -->
<!--ingredients:6; fireproof, waterproof container -->
<!--encounters:5; Merga Wraith Appears -->

This lets you easily search files (for example, with FileLocator Lite) and easily find the ID and name/description on the same line.
Just search for literal string ":123;" where 123 is the ID you want.
Or get the entire ID list by searching with the regular expression <!--[^: ]*:

It works on most XML files, including neogame.xml.
There are certain tables it ignores, either because they are special or because they have no name/description:
barterhexes
headlines
dmcplaces
gamevars
itemtypes

The itemtypes table needs to be handled differently, because nGroupID.nSubgroupID is the real identifier used.

Spoiler: Highlight to view
Open only the "itemtypes.xml" or "neogame.xml" file in Notepad++.
Instructions as above for search/replace, but
Use this search string:
^(\s*)(<table name="itemtypes">\s*<column name="id">([^<]*)</column>\s*<column name="nGroupID">([^<]*)</column>\s*<column name="nSubgroupID">([^<]*)</column>\s*<column name="strName">([^<]*)</column>\s*<column name="strDesc">([^<]*)</column>)
Use this replace string:
\1<!--itemtypes:\4.\5;\3;\6; \7 -->\n\1\2

This creates a line above all itemtypes tables that looks like this:
<!--itemtypes:91.4;34;skill: eagle eye; can see one hex further than normal, light and line of sight permitting, and can detect hidden things easier -->
<!--itemtypes:11.4;35;bottle; &quot;Erie&quot; brand plastic water bottle -->
<!--itemtypes:5.5;42;bag; Pearson &quot;Yukon&quot; canvas backpack -->

All other tables are ignored, so it can safely be run on any xml file without damage.

I'll try revising my method, informed by yours, and see if they come together well.
Assigning prefixes for the different tables' id, that is certainly a good idea.

i might understand what this is doing.

i'd like to see a video or something to know for sure because i'm having a hard time imagining it...but it's doing what i think it is...well i would like to see a video of you doing this with the improvements you added to it. (hmm i should probably add a video to the OP showing how i implement mine.)

though mine isn't easy to apply to already existing mods, i'm making a program right this very moment that will take any existing mod, and auto-replace the ID's to this new convention automatically.

a prototype of it can be seen here: https://youtu.be/WNgKhCX4B48

OverHaul Mod
DevKit is an upgraded BBC mod.
Improve your mods.

Will do.
Great that you're making a program to apply with ID change!

I found a bug in my regex, so it's removed until I fix it. Regex is oh so fun to debug.

I'm starting to write a quick little editor for the XML files, mostly a helper that looks up the names and descriptions of a selected value. Only in design phase right now.

All this effort we're putting into a game that hasn't been updated in 2 years. ;-)

hey i made that video showing my convention in action, check out the video for me? https://www.youtube.com/watch?v=OtS1H_IIYv8&feature=youtu.be

OverHaul Mod
DevKit is an upgraded BBC mod.
Improve your mods.

not sure you got this message, so i'll just post it again:

1) Yes i was thinking about it while making the video.

please, it doesn't have to be polished like my video, you can even stumble through it...but get me a video showing what you're talking about. i had a hard time following what you were saying and i'd just like to see it. just literally, throw a video together in 720p or even 480, or...actually you can even just stream it in a private message on the Discord. ya that'll work. let's just get on the game's official Discord group and you can share the desktop or notepad app in a private chat.

https://discord.gg/23R7K5K

my Discord name is Layarion, you can right click my name in the group to message me.

2) i did a thorough quality check on how the OP reads. Check it out muh man! it's so slick now.

OverHaul Mod
DevKit is an upgraded BBC mod.
Improve your mods.

Looks good, gives a good use-case and good example.
Hopefully we can get people into this!

Have you thought about my change for itemtype ids?
Using 3 digit groupid appended with 3 digit subgroupid?
No prefix is needed, since it is 6 digits total and everything else is 5.

1) Yes i was thinking about it while making the video.

please, it doesn't have to be polished like my video, you can even stumble through it...but get me a video showing what you're talking about. i had a hard time following what you were saying and i'd just like to see it. just literally, throw a video together in 720p or even 480, or...actually you can even just stream it in a private message on the Discord. ya that'll work. let's just get on the game's official Discord group and you can share the desktop or notepad app in a private chat.

https://discord.gg/23R7K5K

my Discord name is Layarion, you can right click my name in the group to message me.

2) i did a thorough quality check on how the OP reads. Check it out muh man! it's so slick now.

OverHaul Mod
DevKit is an upgraded BBC mod.
Improve your mods.