Warning to modders about new prototype and entity tags

Place to post guides, observations, things related to modding that are not mods themselves.
User avatar
Omnifarious
Filter Inserter
Filter Inserter
Posts: 278
Joined: Wed Jul 26, 2017 3:24 pm
Contact:

Warning to modders about new prototype and entity tags

Post 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.
Post Reply

Return to “Modding discussion”