subtledoctor Posted August 4, 2017 Share Posted August 4, 2017 BG2EE ships with one entry missing from kitlist.2da: the GRIZZLY_BEAR kit has no KITIDS value. If I do something like this: FOR (row = 1; row < rows; ++row) READ_2DA_ENTRY row 9 1 value END...then the whole mod install craps out when it hits the row with nothing to READ in that column. But, I really need to read the values in that column (for other kits before and after GRIZZLY_BEAR). Also, I'm told that several mods are adding kits that leave that column blank. So is there a way I can repair the table before doing my READ? I'm trying to wrap my head around how that could possibly be done, when even encountering the gap causes a "read out of bounds" error. I've tried a simple SET_2DA_ENTRY on the known broken row, but that craps out too. And anyway there is the issue of other unknown mods causing more broken rows to be added before my mod is installed. Link to comment
subtledoctor Posted August 4, 2017 Author Share Posted August 4, 2017 It would be insane to just append a whole new column to the file... right? Link to comment
Roxanne Posted August 4, 2017 Share Posted August 4, 2017 Repair would really mean something is broken here? I would rather understand your text with these meanings Fixing kitlist.2da >>> Enhancing kitlist.2da (for mod purpose) Missing >>> optional column left blank Broken rows >>>blank lines not suitable for your purpose Link to comment
Jarno Mikkola Posted August 4, 2017 Share Posted August 4, 2017 Yeah, well it's is broken, Not that you can read this message, but anyways. It would be insane to just append a whole new column to the file... right? Well, depends if you do it correctly, then you can AND probably should even ... aka it will not leave markers to correct file, and it fixes only the erroneous/missing .ids. So the originally correct files won't get extended with another exact copy of the previous column. You read the kit.ids file, and then read the kitlist.2da file and if the file fails to read, you insert the variable into it. As the first action ... and debug it as "checking kitlist.2da's validity" or what ever cheese you wish. And then run what ever you intended to do. Link to comment
Mike1072 Posted August 4, 2017 Share Posted August 4, 2017 READ_2DA_ENTRY value value value variable The first value is the row, the second is the column and the third is the required column count. The variable specified is set to the entry on the given column of the given row, but only column with at least as many columns as the required column count are considered. In your example, you're attempting to read the 10th column from rows that have at least 1 column. You should specify a required column count of at least 10 to skip rows that have fewer columns. Link to comment
Jarno Mikkola Posted August 4, 2017 Share Posted August 4, 2017 Aka ? FOR (row = 1; row < rows; ++row) READ_2DA_ENTRY row 9 10 value END And if that fails, just ... WRITE_2DA_ENTRY row 9 10 ~kitnumberfromkitidsfileentry~ Link to comment
CamDawg Posted August 4, 2017 Share Posted August 4, 2017 For missing table entries, I usually play around with REPLACE_TEXTUALLY Instead; this is how Fixpack deals with a few CLABs with missing columns. If you know the bad kits, it becomes even easier to find and replace the rows you're looking for. For GRIZZLY_BEAR in particular something like this should work: REPLACE_TEXTUALLY ~\(^[0-9]+[ %TAB%]+GRIZZLY_BEAR[ %TAB%]+[0-9]+[ %TAB%]+[0-9]+[ %TAB%]+[0-9]+[ %TAB%]+[^ %TAB%]+[ %TAB%]+[0-9]+[ %TAB%]+0x[0-9A-F]+[ %TAB%]+[0-9]+[ %TAB%%LNL%%MNL%%WNL%]*\)$~ ~\1 0x00004027~ I just wrote this on the fly, so you'll probably need to adjust the regexp a bit, but this should fix the line if it's missing the kitids entry and ignore it if it's already fixed. Link to comment
subtledoctor Posted August 5, 2017 Author Share Posted August 5, 2017 In your example, you're attempting to read the 10th column from rows that have at least 1 column. You should specify a required column count of at least 10 to skip rows that have fewer columns.So, what I posted was a quick approximation. The actual code that was failing was more like FOR (row=1; row<rows; ++row) BEGIN READ_2DA_ENTRY row 9 9 value ENDI forgot about the "0th" column - that one of those two 9s actually means "10." For missing table entries, I usually play around with REPLACE_TEXTUALLY That's what I'm doing for my quick-and-dirty fix right now, but only for the last two entries - regexp hurts more head too much to do without spending some real thinking me on it. But my "fix" is bad in that, if someone adds the entry before me, it will then add an 11th column for that one row. Link to comment
K4thos Posted August 5, 2017 Share Posted August 5, 2017 Already posted solution here. Both propsed approaches will do the job. subtledoctor, there is no way that weidu will fail installation during column reading, like you said in that topic, if you set minimum columns to correct number in READ_2DA_ENTRY (that's what this third argument is for). Keep in mind that column number (second argument) counting starts from 0 and minimum columns (third argument) counting starts from 1. edit: code from second solution is now also available as patch and action functions: http://gibberlings3.net/forums/index.php?showtopic=28835&page=3&do=findComment&comment=255693 Link to comment
kjeron Posted August 5, 2017 Share Posted August 5, 2017 You could also read the columns with READ_2DA_ENTRIES_NOW instead of READ_2DA_ENTRY, since it won't fail if the column entry is missing, and doesn't require altering the file. The column is optional, only required by kits that are to be select-able at CHARGEN. Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.