m
no edit summary
m (catfix, Replaced: <br>{{ood → {{Ood) |
mNo edit summary |
||
| Line 86: | Line 86: | ||
Well, let's look at FACTION_STANDING_INCREASED. According to GlobalStrings.lua, this says "Reputation with %s increased by %d." Well, to make it work like the strings at the top, we'd need to replace %s and %d with (.+). But how do we do that? Here's how: | Well, let's look at FACTION_STANDING_INCREASED. According to GlobalStrings.lua, this says "Reputation with %s increased by %d." Well, to make it work like the strings at the top, we'd need to replace %s and %d with (.+). But how do we do that? Here's how: | ||
newpattern = string.gsub(string.gsub( | newpattern = string.gsub(string.gsub(FACTION_STANDING_INCREASED, "(%%s)", "(.+)"), "(%%d)", "(.+)") | ||
start, end, faction, amount = string.find(string, newpattern) | start, end, faction, amount = string.find(string, newpattern) | ||
This example will properly parse the string, and return all the information we need. How was this achieved? By using a % in front of the %s, it tells it to look for %s in stead of a space, which is what %s would normally be looking for. This way, even though we have to hardcode in the strings we want, we can also don't have to bother with translations. | This example will properly parse the string, and return all the information we need. How was this achieved? By using a % in front of the %s, it tells it to look for %s in stead of a space, which is what %s would normally be looking for. This way, even though we have to hardcode in the strings we want, we can also don't have to bother with translations. | ||
[[Category:HOWTOs|Parse Event Messages]] | [[Category:HOWTOs|Parse Event Messages]] | ||