Closed KiwiHawk closed 3 years ago
i knew there was reason why i did prefer table.remove over nil, but problem is, there are people who make stuff like this #52 but guess for prerequesites we can assume nobody will do that.
other option will be just make copy of table, so it will have no gaps, but i like easier way.
I think jacob is mistaken. Lua doesn't have an array type, only table. So his argument that the specification says "table of string" rather than "array of string" I believe is invalid. They provided an example in the page he referenced. His code doesn't follow this example. Just because the base game doesn't reject his input, doesn't mean it's correct.
He is correct that table.remove(labinputs, _i) only works when _i is a number. Because of this, when using table.remove in a loop, it should always be in an ipairs() loop rather than pairs().
Bob's remove prerequisites function uses table.remove with ipairs(). Angel's function copies to a new table. I would be happy if you change your function to use either of these methods.
resolved with 69322a8f04b79ec934f1e0f33d5bb4872691b4d7
Your recent change mexmer/ScienceCostTweakerM@2d23af3 is now leaving gaps in prerequisites tables. When Iterating over a table with ipairs(), it will stop if it encounters a gap in the table. Bob's library functions to remove prerequisites (among others) stop working.
Please change revert back to calling table.remove and change the loops from using pairs() to ipairs(). You will not have an issue with non numeric indexes as ipairs() will skip them.