Page 1 of 1

Warning to modders about new prototype and entity tags

Posted: Sat Mar 09, 2019 10:16 pm
by Omnifarious
The new prototypes and entity tags for use in station names and the like is very nice, except for one huge problem. The `[stuff]` syntax looks to Lua's `string.find` and `string.match` like the syntax for matching a set of characters, and so these functions will act strangely if given these tags as a string to search for. For `string.find` it's possible to call it like this: `string.find(string_to_search, string_to_look_for, 1, true)` to force a plain text search.

This represents a latent bug as this means that string with `%` or `[` and `]` in them were always problems. It's just that people didn't have reasons to use those characters so much.

The default behavior of Lua's `string.find` of doing pattern matching by default seems like a surprising default.