CidBahamut Posted October 28 Posted October 28 I'm doing a simple mod to add a new wand to the game and trying to add it to a store and I'm having no luck after following the tutorials. Can someone take a look at my code and tell me where I'm going wrong? When I install the mod the new wand shows up in the store file when I open it in Infinity Engine, but when I go into the game it doesn't appear in the shop. Can store files not be updated mid-run? Is there some hidden hard cap on how many inventory items a store can have and I"m running into that? I just can't puzzle out what's going wrong or where to find a thread to start pulling on to figure this out. Everything I can see points to "this wand should show up in the store", but it doesn't. I can spawn the wand in just fine using CLUAConsole, so it isn't like the wand file is busted or not making it into the game. Spoiler /*=========================== Initial config block ===========================*/ BACKUP "WandOfKnock/backup" AUTHOR "Cid" AUTO_EVAL_STRINGS /*-------------------------------- Language Options --------------------------------*/ LANGUAGE "English" //language as presented to user "English" //name of subdirectory in which TRA files are stored for this language //"mymod/Language/English/setup.tra" //all files that get immediately loaded "%MOD_FOLDER%/Language/English/setup.tra" //all files that get immediately loaded /*=================================== Wand of Knock - CBWAND01.ITM ===================================*/ BEGIN "Wand of Knock" DESIGNATED 100 /*------------------------ Add Wand file to game ------------------------*/ PRINT "Adding Wand of Knock item file..." COPY "%MOD_FOLDER%/Items/WandOfKnock.ITM" "override/CBWAND01.ITM" SAY NAME2 @101 SAY IDENTIFIED_DESC @102 BUT_ONLY_IF_IT_CHANGES /*------------------------ Add wand to store ------------------------*/ //Arledrian's store, guy above Gaelan Bayle' PRINT "Adding Wand of Knock to store..." COPY_EXISTING "arled.sto" "override" ADD_STORE_ITEM "cbwand01" //add wand of knock LAST //position; append item to the end of store's stock #25 //charges on ability 1 #0 //charges on ability 2 #0 //charges on ability 3 "IDENTIFIED" //flag for stolen and identification statuses #3 //stack, how many of these are available to purchase BUT_ONLY_IF_IT_CHANGES Quote
jmerry Posted October 28 Posted October 28 I see it. Or, at least, I see one possible reason for things to break. 4 hours ago, CidBahamut said: COPY "%MOD_FOLDER%/Items/WandOfKnock.ITM" "override/CBWAND01.ITM" SAY NAME2 @101 SAY IDENTIFIED_DESC @102 BUT_ONLY_IF_IT_CHANGES What does his do, exactly? First, you copy the item from your mod's resources to the game files. Second, you update the name and description; search dialog.tlk for the appropriate text, return a reference to it or extend dialog.tlk, then write that reference to the item's fields. Finally, you ask a question. Did you change this item since you opened it? If yes, save the new copy. If no, don't save it. And that last point - that you don't save the new copy if you didn't make any changes, might be your problem here. I can easily see a circumstance in which you already have that text in your dialog.tlk and used references to it in building the item. Then the SAY operations would detect the existing instances of those strings and write data that just replicates what's already there - no change. Which means no save. Which means that the item doesn't exist when it comes time to add it to the store. ADD_STORE_ITEM doesn't check that the item actually exists, so it puts a reference to a nonexistent item in the store; you can see that in NI, but in-game it'll probably just be an error message. The fix? Don't use BUT_ONLY_IF_IT_CHANGES here. BUT_ONLY is not boilerplate that can be thrown around to close a COPY operation with no consequences. It has a specific meaning, and should only be used when that reason is actually useful - or at least not harmful. If you're copying files from your mod resources to the game resources, and your later stuff expects those files to exist as game resources, that is a situation in which you absolutely should not use BUT_ONLY. In the absence of BUT_ONLY, your next ACTION will close the COPY. Here, that's the PRINT command. Or if you took that out, the COPY_EXISTING immediately after. Quote
CidBahamut Posted October 29 Author Posted October 29 @jmerry Ok, but here's the wrinkle: the item does exist in the game. I am able to create it via CLUAConsole, so the file CBWAND01.ITM is present in the override folder by the end of the installation process. Even if it weren't being written and simply existed from a previous iteration of me trying to bang out this mod, the file would still exist in the override folder to be used when it came time to patch the store. Also the store offers no error message or empty item slot. It just has exactly the same inventory as it does in the vanilla game. Out of curiosity what would be the correct use case for BUT_ONLY_IF_IT_CHANGES? My understanding of it was that it was mostly to prevent duplicative writes when crunching gargantuan mod installs or otherwise used to increase efficiency but wouldn't actually hurt anything by being included. On the surface it reads as if it will only fail to write when the files already exist in the desired configuration already. (I think the term I'm looking for here is idempotence but don't quote me on that). Basically it couldn't hurt to put it in. Is it something more along the lines of if the .ITM doesn't actively get copied then it doesn't exist within the scope of the component even though it exists within the override folder already? All that aside, I tried removing all instances of BUT_ONLY_IF_IT_CHANGES and the results are exactly the same, so it's not that. Spoiler /*=========================== Initial config block ===========================*/ BACKUP "WandOfKnock/backup" AUTHOR "Cid" AUTO_EVAL_STRINGS /*-------------------------------- Language Options --------------------------------*/ LANGUAGE "English" //language as presented to user "English" //name of subdirectory in which TRA files are stored for this language //"mymod/Language/English/setup.tra" //all files that get immediately loaded "%MOD_FOLDER%/Language/English/setup.tra" //all files that get immediately loaded /*=================================== Wand of Knock - CBWAND01.ITM ===================================*/ BEGIN "Wand of Knock" DESIGNATED 100 /*------------------------ Add Wand file to game ------------------------*/ PRINT "Adding Wand of Knock item file..." COPY "%MOD_FOLDER%/Items/WandOfKnock.ITM" "override/CBWAND01.ITM" SAY NAME2 @101 SAY IDENTIFIED_DESC @102 /*------------------------ Add wand to store ------------------------*/ //Arledrian's store, guy above Gaelan Bayle PRINT "Adding Wand of Knock to store..." COPY_EXISTING "arled.sto" "override" ADD_STORE_ITEM "cbwand01" //add wand of knock LAST //position; append item to the end of store's stock #25 //charges on ability 1 #0 //charges on ability 2 #0 //charges on ability 3 "IDENTIFIED" //flag for stolen and identification statuses #3 //stack, how many of these are available to purchase Quote
Daulmakan Posted October 29 Posted October 29 Store (.STO) files are stored in the savegame itself, so if you already visited that store ingame before installing the mod, you won't notice any changes. Try starting a new game and checking it again. Quote
jmerry Posted October 29 Posted October 29 On second thought, that. Yeah, the problem is almost certainly a case of you calling up an instance of the store that was already in the save file so the game didn't check the base resource. As for the BUT_ONLY ... the comparison isn't between the final state and the resource as it existed before in game. The comparison is between the final state and the file as it was opened - a small, but vital, difference. Using it with a COPY command from your mod's folder is unwise and can result in bugs with resources not being created. (Unless you don't want to save it; I use 2DAs like that sometimes to read in a table of data) I am much freer with applying BUT_ONLY to a COPY_EXISTING command; there, if we don't save, the resource already exists. And the initial state is the resource as it already exists, so it's truly harmless; I would use it in the second part of this mini-mod with arled.STO. Quote
CidBahamut Posted October 29 Author Posted October 29 20 hours ago, Daulmakan said: Store (.STO) files are stored in the savegame itself, so if you already visited that store ingame before installing the mod, you won't notice any changes. Try starting a new game and checking it again. This was it. Thank you for that insight, you've saved me a lot of headache. It makes sense in retrospect since the contents of the store would change over the course of the game they'd instantiate it once and then keep a saved copy of it to reflect what you purchased. I assume the same would be true of containers like chests and crates. Out of curiosity do you happen to know if it instantiates the store at the start of the game vs the first time you have to access the resource? Also is there anywhere this sort of thing is documented for future reference? There's nothing listed in the IESDP which was the only place I could think of to look for clues when I was trying to troubleshoot this on my own. Quote
argent77 Posted October 29 Posted October 29 (edited) Stores are included in saved games only after you opened them for the first time (same with item bags). Containers on maps are part of the area, so they are included in the save when you enter the area for the first time. Edited October 29 by argent77 Quote
Daulmakan Posted October 29 Posted October 29 26 minutes ago, CidBahamut said: Also is there anywhere this sort of thing is documented for future reference? There's nothing listed in the IESDP which was the only place I could think of to look for clues when I was trying to troubleshoot this on my own. I don't think so, no. I remember encountering this same issue myself when I started modding and found the answer somewhere in a forum reply. I concur it merits adding to the IESDP, at the very least to avoid people hitting this particular stone (I've seen it a non-trivial number of times). Argent's comment for containers could be included in the proper section as well. Once you've come across, it's trivial to remember it onwards, but debugging it for the first time could be pretty annoying and time consuming. Quote
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.