The brackets () identify it as a group, so we can tell the MATCH to only write that part to the variable
the dot is a wildcard for almost everything
the plus makes it repeating
and the questionmark makes the plus lazy, so it tries matching just one at first, then two, then three, and so on
so essentially, this should happen
MATCH(%CHAT%,"§dWelcome §e(.+?)§f§d to the server!",&newplayer,1); §dWelcome §emart3323§f§d to the server!
--------------------------------------------------------------------------------------- §dWelcome §e(m)§ <-Failed to match §, trying more iterations of . §dWelcome §e(ma)§<-Failed to match §, trying more iterations of . §dWelcome §e(mar)§<-Failed to match §, trying more iterations of . §dWelcome §e(mart)§<-Failed to match §, trying more iterations of . §dWelcome §e(mart3)§<-Failed to match §, trying more iterations of . §dWelcome §e(mart33)§<-Failed to match §, trying more iterations of . §dWelcome §e(mart332)§<-Failed to match §, trying more iterations of . §dWelcome §e(mart3323)§f§d to the server! <- Successful match found
--------------------------------------------------------------------------------------- Writing first group, which is (mart3323), to variable &newplayer
So someone posted a code similar to the one I wanted, I copied it of course. I tried to make it kick the players but it collided somehow with out chat color codes. So I decided to make it alert me instead and tell me who did it but that did not work either.'
How do I make it so the logged part says <NAME> CURSED? (Not caps)
You need to change the Log to Log(&b%&@name%)
and the regex to something that captures the name according to the way your server formats chat
see the last few pages of this thread for a few examples of that
Okay, i went onto the server and captured the first 8 lines of chat i got.
i think this is the one you're trying to match
§dWelcome §emart3323§f§d to the server!
It seems there's a white colour code there for no reason, doesn't change what it looks like, but breaks the match
try with this...
§dWelcome §e(.+?)§f§d to the server!
IFMATCHES(%CHAT%,"§dWelcome §e(.+?)§f§d to the server!");
MATCH(%CHAT%,"§dWelcome §e(.+?)§f§d to the server!",&newplayer,1);
ECHO("Hello %&newplayer%! Welcome to the server!");
ENDIF;
<entry key="&capture6">§eWelcome mart3323 to the server!</entry>
<entry key="&capture5">§fType §c/help§f for a list of commands.</entry>
<entry key="&capture4">Currently online: §2ChasityV§f, §2braidertom§f, §2MadHadda§f, §elaurajaye§f, §emart3323§f</entry>
<entry key="&capture3"/>
<entry key="&capture2">§2Please check out our NEW TF2 server. tf2.safehavenserver.net§f</entry>
<entry key="&capture1">§emart3323 joined the game.</entry>
<entry key="&capture0">§dWelcome §emart3323§f§d to the server!</entry>
<entry key="&capture8">§6[LOTTERY] §fDraw in: §c11 hours, 48 minutes, and 33 seconds</entry>
<entry key="&capture7">§0§0§2§e§f Welcome, §emart3323§f§c!</entry>
Wow, thanks a bunch man! Finally working! Now I don't have to bother with welcoming new players all the time
That happens if you use your ~ key to open whatever you're writing into
it's one of those special keys that waits for you to press something after it and then tries to combine the two
for example, if i press ~ in a text box once, nothing happens; if i press o after that, i get õ
and so on
is your macro activate key the one to the left of 1 for example?
How can I check with RegEx if ther is 0, 1 or 2 color codes in my string?
I have:
[§[a-f0-9]]{0,2}
But it doesnt work correct.
The regex you have doesn't make sense because Java will just treat it as a union so the inner brackets are redundant. However it makes more sense if you make the outer brackets into parentheses then it makes more sense:
(§[a-f0-9]){0,2}
This defines a subpattern of "section char followed by a-f or 0-9" which is a colour code, and the repetition quantifier is between zero and 2 occurrences, so it will match any of the 3 following cases:
§a
§a§a
eg. it will match if you have 3 consecutive colour codes but not if there are characters in between. If this is what you want then great. If you need it to match colour codes which are spaced out, then it gets complicated very quickly. Expand the spoiler if you still want to try:
You can use the metacharacter "." (full stop) to match any single character and use a quantifier to get it to eat up more than one character, what you really want is for it to match any number of characters including none (which would be {0,}) and fortunately there's a pre-defined quantifier "*" (asterisk) which does this.
We also use the special quantifier "?" which means {0,1} to allow both matches to succeed or fail.
(§[a-f0-9](.*§[a-f0-9])?)?
but you'll notice that this seems to match even with more than 2 colour codes? This is because by default the * quantifier is "greedy" and will consume as many characters as possible. this means it consumes the whole string until it finds a colour code but won't stop there if there is a longer string that will still match! This means you need to tell it to be "ungreedy" and consume only as many characters as required to make the rest of the pattern a match. You use the modifier "?" to do this (which gets confusing because regex uses "?" in so many different ways).
(§[a-f0-9](.*?§[a-f0-9])?)?
We can clean this up a little now because we have repetition in our pattern:
(.*?§[a-f0-9]){0,2}
Unfortunately this will still match for more than 2 colour codes, because it will match once it finds 2 codes, but if there are more in the string they will be ignored and won't cause the pattern to fail. What we must do now is only allow the match to succeed if no more colour codes can be found in the string, to do this, use a negative lookahead assertion (which unfortunately raises yet another (different) usage of "?"):
(.*?§[a-f0-9]){0,2}(?!.*?§[a-f0-9])
I'm not even sure if this will work because I'm not in a position to test it right now, it may need some tweaking. But that's the gist of it. I can't think of a simpler way to be honest.
The regex you have doesn't make sense because Java will just treat it as a union so the inner brackets are redundant. However it makes more sense if you make the outer brackets into parentheses then it makes more sense:
(§[a-f0-9]){0,2}
This defines a subpattern of "section char followed by a-f or 0-9" which is a colour code, and the repetition quantifier is between zero and 2 occurrences, so it will match any of the 3 following cases:
§a
§a§a
eg. it will match if you have 3 consecutive colour codes but not if there are characters in between. If this is what you want then great. If you need it to match colour codes which are spaced out, then it gets complicated very quickly. Expand the spoiler if you still want to try:
Thanks!
EDIT:
Another Question, how can i use the STORE Command?
Another Question, how can i use the STORE Command?
STORE currently only stores places, so the only valid first parameter is "place", the second parameter is the name of a place to store. The current coordinates are used:
STORE("place","Name of place");
STOREOVER behaves exactly the same as STORE but overwrites the place if a place with a matching name is found:
Hey Mod Creator, I installed this mod and it comes up saying it worked but when i tried to bind /home and /spawn to 1 and 2 on the num pad(respectively) and when i pressed the buttons nothing happened. Can you please help me?
How i create a macro to get name on that chat format:
[g] [TAG] CLAN.NICK ?
with so many tags, i'm sure you also have color codes..., there's no way to ignore them i'm afraid..
you could capture a line though, so we know where the colour codes are
go onto the server and have someone with all those tags say "capturetg"
If some of those tags are optional then find someone that has none of them, and have him say "capturengt"
then go to your globalvars.xml and copy&paste us what @&capture (and @&capture2) contains
Hey Mod Creator, I installed this mod and it comes up saying it worked but when i tried to bind /home and /spawn to 1 and 2 on the num pad(respectively) and when i pressed the buttons nothing happened. Can you please help me?
Try pressing them when you're in the sneak+macro activate menu (the one with the keys)
if it works correctly, it should open that button for editing
it's generally a good idea to press the button you want to bind to instead of clicking on it, but it takes some getting used to
I'm using this script I got from an earlier post as an AFK system.
$${
IFMATCHES(%CHAT%,"Alan"); <- replace this (green) part
wait(1);
echo("&4AFK");
ENDIF;
}$$
Problem is it keeps spamming "AFK" in the chat.
It detects your name when you say AFK..., hopefully though, you usually have some brackets around the name of the player who talks, so you should make it check for your name, surrounded ONLY by spaces or punctuation
"[,.\s\b]alan[,.!?\s\b]"
This should go without saying, but this script will run whether you're really AFK or not, so you should have another trigger to turn it off
i'll just presume you left that unmentioned because it wasn't relevant
Is there any way to like filter out all the chat or something to have like a chat toggle key?
Unfortunately, not right now, but something like that has been suggested a few times and would be great to have
especially if you can have an intermediate mode where chat is not displayed, but is received by scripts, and you can have those decide what to log you and what not to
Right now? It's not working at all, not even after I toggle it. :/
Well, i just noticed i forgot to escape a few special characters..., but even with those it should react to
<user> chat chat alan, chat
and the like...
The brackets () identify it as a group, so we can tell the MATCH to only write that part to the variable
the dot is a wildcard for almost everything
the plus makes it repeating
and the questionmark makes the plus lazy, so it tries matching just one at first, then two, then three, and so on
so essentially, this should happen
MATCH(%CHAT%,"§dWelcome §e(.+?)§f§d to the server!",&newplayer,1);
§dWelcome §emart3323§f§d to the server!
---------------------------------------------------------------------------------------
§dWelcome §e(m)§ <-Failed to match §, trying more iterations of .
§dWelcome §e(ma)§<-Failed to match §, trying more iterations of .
§dWelcome §e(mar)§<-Failed to match §, trying more iterations of .
§dWelcome §e(mart)§<-Failed to match §, trying more iterations of .
§dWelcome §e(mart3)§<-Failed to match §, trying more iterations of .
§dWelcome §e(mart33)§<-Failed to match §, trying more iterations of .
§dWelcome §e(mart332)§<-Failed to match §, trying more iterations of .
§dWelcome §e(mart3323)§f§d to the server! <- Successful match found
---------------------------------------------------------------------------------------
Writing first group, which is (mart3323), to variable &newplayer
'Cause tomorrow spring is here
You need to change the Log to Log(&b%&@name%)
and the regex to something that captures the name according to the way your server formats chat
see the last few pages of this thread for a few examples of that
'Cause tomorrow spring is here
Wow, thanks a bunch man! Finally working! Now I don't have to bother with welcoming new players all the time
One warning with that, it won't display chat history the way pressing t does
but under any button, just put /a $$?
and under options untick "remember parameters"
That happens if you use your ~ key to open whatever you're writing into
it's one of those special keys that waits for you to press something after it and then tries to combine the two
for example, if i press ~ in a text box once, nothing happens; if i press o after that, i get õ
and so on
is your macro activate key the one to the left of 1 for example?
'Cause tomorrow spring is here
your [acronym:(estonian)]chinese[/acronym] might confuse some people, but you're welcome =P
'Cause tomorrow spring is here
I have:
But it doesnt work correct.
Macro/Keybind mod Wiki
The regex you have doesn't make sense because Java will just treat it as a union so the inner brackets are redundant. However it makes more sense if you make the outer brackets into parentheses then it makes more sense:
This defines a subpattern of "section char followed by a-f or 0-9" which is a colour code, and the repetition quantifier is between zero and 2 occurrences, so it will match any of the 3 following cases:
eg. it will match if you have 3 consecutive colour codes but not if there are characters in between. If this is what you want then great. If you need it to match colour codes which are spaced out, then it gets complicated very quickly. Expand the spoiler if you still want to try:
You can use the metacharacter "." (full stop) to match any single character and use a quantifier to get it to eat up more than one character, what you really want is for it to match any number of characters including none (which would be {0,}) and fortunately there's a pre-defined quantifier "*" (asterisk) which does this.
We also use the special quantifier "?" which means {0,1} to allow both matches to succeed or fail.
but you'll notice that this seems to match even with more than 2 colour codes? This is because by default the * quantifier is "greedy" and will consume as many characters as possible. this means it consumes the whole string until it finds a colour code but won't stop there if there is a longer string that will still match! This means you need to tell it to be "ungreedy" and consume only as many characters as required to make the rest of the pattern a match. You use the modifier "?" to do this (which gets confusing because regex uses "?" in so many different ways).
We can clean this up a little now because we have repetition in our pattern:
Unfortunately this will still match for more than 2 colour codes, because it will match once it finds 2 codes, but if there are more in the string they will be ignored and won't cause the pattern to fail. What we must do now is only allow the match to succeed if no more colour codes can be found in the string, to do this, use a negative lookahead assertion (which unfortunately raises yet another (different) usage of "?"):
I'm not even sure if this will work because I'm not in a position to test it right now, it may need some tweaking. But that's the gist of it. I can't think of a simpler way to be honest.
Thanks!
EDIT:
Another Question, how can i use the STORE Command?
Macro/Keybind mod Wiki
STORE currently only stores places, so the only valid first parameter is "place", the second parameter is the name of a place to store. The current coordinates are used:
STOREOVER behaves exactly the same as STORE but overwrites the place if a place with a matching name is found:
[g] [TAG] CLAN.NICK ?
with so many tags, i'm sure you also have color codes..., there's no way to ignore them i'm afraid..
you could capture a line though, so we know where the colour codes are
put this on onchat
go onto the server and have someone with all those tags say "capturetg"
If some of those tags are optional then find someone that has none of them, and have him say "capturengt"
then go to your globalvars.xml and copy&paste us what @&capture (and @&capture2) contains
Try pressing them when you're in the sneak+macro activate menu (the one with the keys)
if it works correctly, it should open that button for editing
it's generally a good idea to press the button you want to bind to instead of clicking on it, but it takes some getting used to
'Cause tomorrow spring is here
It detects your name when you say AFK..., hopefully though, you usually have some brackets around the name of the player who talks, so you should make it check for your name, surrounded ONLY by spaces or punctuation
"[,.\s\b]alan[,.!?\s\b]"
This should go without saying, but this script will run whether you're really AFK or not, so you should have another trigger to turn it off
i'll just presume you left that unmentioned because it wasn't relevant
'Cause tomorrow spring is here
I began minecraft ~July 7 2011 1.7.3 Beta
My username used to be Creative_Dalek but is now Dalek since 2/4/2015
Wait..., so..., it didn't work, or it did?
Unfortunately, not right now, but something like that has been suggested a few times and would be great to have
especially if you can have an intermediate mode where chat is not displayed, but is received by scripts, and you can have those decide what to log you and what not to
'Cause tomorrow spring is here
Well, i just noticed i forgot to escape a few special characters..., but even with those it should react to
<user> chat chat alan, chat
and the like...
[,\.\s\b]alan[,\.!\?\s\b] <- with ? and . escaped
'Cause tomorrow spring is here
You have a space following the comma.
ECHO("I'm not here");
ENDIF;
How i create a macro to only response if have (theiago and you) on same message? Example: Theiago, where you are?
Are you sure you want those keywords?, it would be very unreliable..., for example
"you need to talk to theiago about that"
"i'm not here"
"I'm not sure where you are, but theiago is here..."
"i'm not here"
Also, it won't reply to
"theiago, where'd ya go?"
"where's theiago?"
"theiago, come here"
"Theia, are you afk again?"
etc.
anyway...
do the same as before for both words, but put a (.+?) between them
OR
have 2 IFMATCHES, one for either word
IFMATCHES(\btheiago\b(.+?)\byou\b)
Echo(I'm not here)
ENDIF
---or---
IFMATCHES(\btheiago\b)
IFMATCHES(\byou\b)
Echo(I'm not here)
ENDIF
ENDIF
'Cause tomorrow spring is here