Modding new ingredients/properties (bug or my error?)

6 posts / 0 new
Last post
#1
Modding new ingredients/properties (bug or my error?)

I've just got back into NeoScavenger after a break and was thrilled to see modding working!

However, I've hit one snag so far trying it myself... when I try to add a new ingredient for crafting, it seems the game doesn't recognize it the way it does everything else in my mod folder/file. It DOES work, however, if I add the ingredient to my "override" ("0") folder/file and give it a number higher than anything in the game already.

Examples:

WORKS:
(added to my "override" neogame.xml file in folder named "0")

<table name="ingredients"> <column name="nID">100</column> <column name="strName">Waterproof container</column> <column name="strRequiredProps">8&amp;9</column> <column name="strForbidProps"></column> </table> <table name="recipes"> <column name="nID">3</column> <column name="strName">sterilized water (pill)</column> <column name="strSecretName">sterilized water (pill) (pure)</column> <column name="strTools">1x100</column> <column name="strConsumed">1x4+1x5</column> <column name="strDestroyed"></column> <column name="nTreasureID">20</column> <column name="fHours">0.1</column> <column name="nReverse">0</column> <column name="nHiddenID">0</column> <column name="bIdentify">1</column> <column name="bTransferComponents">0</column> <column name="vAlsoTry">75</column> <column name="nTempTreasureID">3</column> </table>

DOES NOT WORK:
(added to my mod's folder neogame.xml file; mod/folder named "Banjo")

<table name="ingredients"> <column name="nID">1</column> <column name="strName">Waterproof container</column> <column name="strRequiredProps">0:8&amp;0:9</column> <column name="strForbidProps"></column> </table>

(added to my "override" neogame.xml file in folder named "0")

<table name="recipes"> <column name="nID">3</column> <column name="strName">sterilized water (pill)</column> <column name="strSecretName">sterilized water (pill) (pure)</column> <column name="strTools">1xBanjo:1</column> <column name="strConsumed">1x4+1x5</column> <column name="strDestroyed"></column> <column name="nTreasureID">20</column> <column name="fHours">0.1</column> <column name="nReverse">0</column> <column name="nHiddenID">0</column> <column name="bIdentify">1</column> <column name="bTransferComponents">0</column> <column name="vAlsoTry">75</column> <column name="nTempTreasureID">3</column> </table>

Either way, everything *else* in my test mod (new encounters and treasuretables in "Banjo" and scavenging loot and item tweaks in "0") work fine, which is what's making me wonder if there's a bug with the game reading "ingredients" from a mod... or if I've just missed something obvious here (maybe how to label ingredients or properties when using a mod?). :)

Oh, and a separate question while I'm here: is it possible to "override" another mod's values as long as you load your own mod after the one you want to override (e.g. using "modname:??" for the entries you want to override in an override/"0" folder)?

My Mods:SaveMan|Fishing|Shouldered|Bottles

Looks like this was a bug. In cases where a mod overrides a base data type with 1-based ID (as opposed to a 0-based ID), the game was accidentally assigning the 0-based ID anyway. This caused IDs to be off by one for things like ingredients. And in this case, the ID pointed to empty data, so the recipe didn't work.

I've made some changes to handle this, which should be available in builds after 0.9922b.

As for overriding another mod's values, I'm not sure if this is possible. You can definitely override another mod's override just by loading yours last. However, there isn't a way to say "my mod's ID=1 should change this other mod's ID=1."

The one exception that comes to mind is if you create a new mod with the same name as the mod you want to override, and just give it a different folder name, then load it later in the list. This might do what you're suggesting, but I've never tried it.

Thanks for the heads-up!

Dan Fedor - Founder, Blue Bottle Games

Thanks mate. Glad to hear it wasn't my stupidity and that it'll be fixed.

As for mod overriding, I was hoping that you'd be able to do something like using "Modname:value" (the way mods access vanilla data with "0:value", but the idea of making a new mod with the same name does seem easier.

I'd actually tried what you suggested already on a wild hunch (made a new mod with just one entry in it and gave it the same mod name but a different folder in the getmods load list and loading it later) but it had a *very* weird effect: when loading the mods on startup it got slower... and slower... and ended up around 80% loading 1% every few minutes until it finally stalled at 99%; never had that happen before! I'm going to try again, though, as I'm not sure if this was due to a bug in my mod or the whole method not working.

EDIT: Tested replacing one single treasuretable in the M(m)MoD and the same crash happened: game loading slows at "loading images" for the original mod, then freezes at 99%. :( Could it be getting confused that two mods have the same name, yet one has no images?

My Mods:SaveMan|Fishing|Shouldered|Bottles

Hm, that sounds like a recursive dependency or code issue. I.e. the game is loading A, which requires B, which in turn requires A, etc. That would explain the asymptotic behavior of the loading bar (and slowing loading speed).

As a test, I tried making a simple mod that adds a new creature type, and overrides the cryo dogman spawn with this new creature. Then, I copied this mod's folder, and changed the name of the creature to something else. The getmods.php loads in this order:

nRows=3&strModName0=SampleMod&strModURL0=SampleModFolder&strModName1=SampleMod&strModURL1=SampleModFolderCopy&strModName2=0&strModURL2=0

When I load that, it completes the loading process normally, and the creature has the expected name from SampleModFolderCopy instead of SampleModFolder.

So it seems to be loading as it should. Are you able to do something similar?

Dan Fedor - Founder, Blue Bottle Games

Thanks for looking into this!

So, some further testing. This is a bit long, but I wanted to be thorough and explain everything I tried to narrow this down:

THINGS TRIED:

1) Made a simple mod (folder and mod name = "TestMod") that added just one single new item (a new necklace). Also made a simple "0" override mod that only modifies the cryo initial loot and added the new item to it. Loaded both mods. WORKED. New item shows up at cryo hex on the ground as expected.

2) Made a second mod (folder name "TestModCopy", mod name "TestMod") that did nothing except modify the one item in "TestMod" by changing the name (and nothing else) of my new necklace. Added the mod to the load order after the first TestMod entry but before the "0" vanilla override that changed the cryo hex. Loaded. WORKED. New item shows up at cryo hex with the name as changed by the "TestModCopy" folder override instead of the name given by the "TestMod" folder original.

3) On a hunch, I went back and edited my first "TestMod" necklace item with one difference: I gave it a new graphic (previously used "0:ItmTalisman.png". This time it used "ItmCrossNecklace.png" that I made and put in the img subfolder as is normal (and added it to getimages.php). I then removed "TestModCopy" from the mod load order to make sure I hadn't made any mistakes. Loaded the game. WORKED. New necklace item showed up with the new graphic, as specified in "TestMod".

4) Now I re-added "TestModCopy" to the mod load order as in step 2 (where it worked). The expected result on loading the game should be the new necklace item appears, has the new ("TestModCopy") name and the "ItmTalisman.png" graphic since I didn't change that in "TestModCopy", only "TestMod" (which should be overridden now). Loaded the game. FAILED. Slowed down loading at around 70%. Froze at 99%.

5) Tried the reverse of steps 3 & 4: "TestMod" (loaded first) now had the "vanilla" talisman item image. "TestModCopy" had the new/overriding "ItmCrossNecklace.png". Loaded the game twice, first with just "TestMod", then with both "TestMod" and "TestModCopy". Both times WORKED. The first time, the new necklace had the talisman graphic and "TestMod" name. Second time it had the ItmCrossNecklace.png graphic and the name from "TestModCopy".

6) Just to make sure, I went back and altered both mods so that the ONLY difference between them now was that they had different names for the item (and so now both used "ItmCrossNecklace.png" for their image, added to both getimages.php and img subfolders). Loaded. FAILED. Slowed and crashed at 99%.

7) Tried again with both mods looking for "ItmCrossNecklace.png" (item name is the only difference) but this time only put the actual png files in "TestModCopy/img" folder (getimages.php and img subfolder of "TestMod" are empty). Loaded. WORKED! Item has override name from "TestModCopy" and used ItmCrossNecklace image (from "TestModCopy/img" folder) as expected.

8) Finally, tried the reverse of 7: both mod versions look for "ItmCrossNecklace.png" but the images are only in "TestMod/img" (the original mod that is to be overridden). "TestModCopy/img" is empty. Loaded. FAILED! Slowed and crashed at 99%.

CONCLUSIONS:

So, it seems the problem is if you try to overwrite a mod that has custom images. It doesn't seem to matter if the overriding mod is trying to change those graphics or not touching them, and it seems to work fine if the override mod has new graphics but the original one does not.

Can you replicate this issue? Maybe try just assigning your new creature a new image (from "SampleModFolder/img") and see if it still loads as before or if it now crashes?

My Mods:SaveMan|Fishing|Shouldered|Bottles

Ah, I found it now. Thanks!

It looks like there was a bug in the code that caused a duplicate mod to overwrite the original mod's data set, which caused an infinite loop when loading images. I've added some special case code to handle that situation, and I was able to make the mod copy work with both mods having images but different names.

Thanks again for the detailed info!

Dan Fedor - Founder, Blue Bottle Games