Daxtreme Posted February 28, 2018 Posted February 28, 2018 (edited) hey guys, I'm still a beginner at weidu modding and I was wondering how I would go about reading a .cre file's string name, see if it matches, then if it does, change another cre file's string name? Basically I'm making a small mod that has to check if another mod has changed the name of a cre file's name. If it did, then I change another cre file's name to match it. I know how to write a cre's file, but not how to check it! Here's what I have so far, the WRITE part. I change "mage18a" name to "Cowled Wizard" ACTION_IF FILE_EXISTS_IN_GAME ~mage18a.cre~ BEGIN COPY_EXISTING ~mage18a.cre~ ~override~ LPF SANITIZE_CRE RET ok = ok END PATCH_IF ok BEGIN WRITE_LONG 0x0008 10006 WRITE_LONG 0x000c 10007 END BUT_ONLY END I simply have no idea how to READ and put an IF statement along with it Like If (NOT) ~cowenf2.cre~ NAME = 10006 THEN change ~mage18a.cre~ NAME to 10006 (I think I got that part right above) Hopefully that makes any sense Edited February 28, 2018 by Daxtreme Quote
Mike1072 Posted February 28, 2018 Posted February 28, 2018 If you want the two names to match, I'd take whatever value exists in cowenf2 and write it to mage18a. COPY_EXISTING ~cowenf2.cre~ ~override~ READ_LONG 0x08 name READ_LONG 0x0c tooltip BUT_ONLY COPY_EXISTING ~mage18a.cre~ ~override~ WRITE_LONG 0x08 name WRITE_LONG 0x0c tooltip BUT_ONLY Quote
Daxtreme Posted February 28, 2018 Author Posted February 28, 2018 (edited) no that's not quite it! I need to check if it was changed first. If it hasn't been changed, do nothing! Only change the name of the other cre file if the first has been changed But thanks, so READ_LONG 0x08 returns the string name (as numbers) of a cre? Awesome! Edited February 28, 2018 by Daxtreme Quote
Mike1072 Posted February 28, 2018 Posted February 28, 2018 If the string you are looking for is added by a mod, the strref will differ across installations, so you can't do a numerical comparison. You'd have to fetch the string with READ_STRREF instead and do a string comparison to see if the text matches. If the string is part of the vanilla game, its strref number will always be the same, so you can just check if the number in the file matches the known value. This has a benefit in that it works regardless of the game's language. To do a numeric comparison, you can use name == 123. The opposite would be name != 123. To do a string comparison, you can use ~%name%~ STRING_EQUAL ~abc~. The opposite would be NOT ~%name%~ STRING_EQUAL ~abc~. Throw it in a PATCH_IF or ACTION_IF depending on the context. COPY_EXISTING ~cowenf2.cre~ ~override~ READ_LONG 0x08 name READ_LONG 0x0c tooltip BUT_ONLY ACTION_IF (name == 123) BEGIN COPY_EXISTING ~mage18a.cre~ ~override~ WRITE_LONG 0x08 name WRITE_LONG 0x0c tooltip BUT_ONLY END Quote
Daxtreme Posted February 28, 2018 Author Posted February 28, 2018 (edited) Oh that's great! Since it's a vanilla string, that's what I'm gonna do! Basically -- ACTION_IF NOT (name == 10006) BEGIN // Check if name has been changed from Vanilla name COPY_EXISTING blablabla I guess tooltip is the 2nd name field? What do you mean PATCH_IF vs ACTION_IF? What's the difference? Thanks a lot! edit: Holy crap I just realized that I was using NearInfinity version.... 1.32 That one was released in 2010! Haha jeez, this is gonna be such a huge jump! Thanks to Roxanne for mentioning the Dialog Tree format in a help thread and me realizing I didn't have the tree view in question EDIT2: Here's what I came up with, pretty sure it's correct: COPY_EXISTING ~cowenf2.cre~ ~override~ READ_LONG 0x08 name READ_LONG 0x0c tooltip BUT_ONLY ACTION_IF (name != 10006) BEGIN COPY_EXISTING ~mage16c.cre~ ~override~ LPF SANITIZE_CRE RET ok = ok END PATCH_IF ok BEGIN WRITE_LONG 0x0008 10006 WRITE_LONG 0x000c 10007 END BUT_ONLY END Thanks for your help! I think I'm gonna get the hang of this soon (I wrote some lua a few years back) Edited March 1, 2018 by Daxtreme 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.