Re: counting characters in lua
Hi,
thats pretty simple. You need to get the # signs out of the string, either by creating a trigger for it, or parsing it out of the already available string inside a script. Lets take the following for example:
s = 'Summon rift entity: ##'
Now you need to create a small regular _expression_ from scratch that will handle all lines which start with something textual (any amount of characters), followed by a colon, followed by a whitespace and the amount of # you seek (at least once). That might look like the following:
regexp = '%w*: (#+)'
Now you can use string.match() to get the hashtags out of your text:
hashtags = string.match(s, regexp)
Now, the hashtag itself solves our problem here . The hashtag sign in lua returns the amount of items within a collection, like the amount of number-indices in a table, or the amount of characters in a string. Thus, the following will work:
amount = #hashtags
amount will now contain the amount of hashtags found in your text. The same procedure can be used directly within a trigger, you'll just have to configure it to parse as a regular _expression_ and use the wildcard %1 instead of the hard-formatted text above:
s = '%1'
Hope that helps.
Best Regards.
Hijacker
-- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector