The Ultimate Site of Worms Armageddon

Worms: Armageddon => General discussion => Wormkit Modules => Topic started by: Kradie on August 27, 2020, 02:22 PM

Title: wkmacros
Post by: Kradie on August 27, 2020, 02:22 PM
Hi, could it be possible to make a module which allows the user to assign different keys that will trigger text and sentences? It could be useful in situation in the host room where you have to explain the rules, provide links to an update, modules, or whatever. Yes I know about the up key, but it is more convenient to have a text readied and written in a notepad file, just like wkRemapKeys.
 Sometime it can be very annoying and tiring typing a bunch of stuff only to see the user just leaves and never to return.

Anyone know it can be done and possible can do it?

Thanks.
Title: Re: wkmacros
Post by: Kaleu on August 27, 2020, 11:44 PM
Someone once created an autohotkey script to type rules, it's easy to do.
Title: Re: wkmacros
Post by: Kradie on August 30, 2020, 01:12 PM
Someone once created an autohotkey script to type rules, it's easy to do.
Would be nice if someone actually did make this true.
Title: Re: wkmacros
Post by: GrO on August 30, 2020, 02:22 PM
...the easiest workaround is to keep long rule's descriptions in a txt files, then just ctrl+c, ctrl+v
Title: Re: wkmacros
Post by: Kradie on August 30, 2020, 04:12 PM
...the easiest workaround is to keep long rule's descriptions in a txt files, then just ctrl+c, ctrl+v
I didn't know about this. Thanks. ::)
Title: Re: wkmacros
Post by: GrO on August 30, 2020, 11:30 PM
...the easiest workaround is to keep long rule's descriptions in a txt files, then just ctrl+c, ctrl+v
I didn't know about this. Thanks. ::)
...sarcasm unnecessary, some new users may not know and read this one day :)
Title: Re: wkmacros
Post by: Kradie on August 31, 2020, 12:19 AM
My apologize, I didn't think as far this could be useful for guests and new users.

Listen to me random reader! I know you are there! I am sorry for my sarcasm!  ;D

Anyway, the point of this module was convenience, not type a bunch of rules and have it ready for copy paste. Then you have to minimize per sentence to copy. It is crazy. Unless if you run in windows or have multimonitor setup. Which not all have or want.

Title: Re: wkmacros
Post by: GrO on August 31, 2020, 07:10 AM
Then you have to minimize per sentence to copy.
...huh? Simple text processing and still so many mysteries? :D

Didn't you know you can copy new-line-chars (or 'enters' - see the picture attached)? You can copy the whole text before running the game for your convenience and you don't need multi-monitors to minimize the game at all - what are you talkin' about man???

So many useless sarcasm in you, who needs it when you don't know the basics...

Regards.


*edit*

Someone once created an autohotkey script to type rules, it's easy to do.
Would be nice if someone actually did make this true.
...he said it's easy to do and it's actually true, just made a simple script with 3 examples (also attached it):

Code: [Select]
; "!j" = "Alt"+"j"    ; if you want to use "Ctrl" instead, just swap:
; "!" with "^" (omit the quotes)
;
; codepage := 65001    ; uncomment start of this line for UTF-8 encoding,
;                              remember to save the script as 'Unicode big endian'
;
; to produce a literal commas or percent signs, you need to use so-called
; escape sign before each, example (omit the quotes):    "`," and "`%"
;
; "`n" makes a new line like "Enter"
!j::
  Send, Shopper rules:`n- crate before attack`,`n- kill the leader`,`n- attack from rope.
  Send, {Enter}
Return

!k::
  Send, Forts rules:`n- no invading`,`n- no fishing.
  Send, {Enter}
Return

!l::
  Send, Get the latest updates from:`nhttps://worms2d.info/Updates
  Send, {Enter}
Return
Title: Re: wkmacros
Post by: Kradie on August 31, 2020, 01:54 PM
Thank you for your effort though. But it's not really what I meant.

Sorry to have wasted your time.

Peace.


Title: Re: wkmacros
Post by: GrO on August 31, 2020, 02:13 PM
Thank you for your effort though. But it's not really what I meant.

Sorry to have wasted your time.

Peace.
Hi, could it be possible to make a module which allows the user to assign different keys that will trigger text and sentences? It could be useful in situation in the host room where you have to explain the rules, provide links to an update, modules, or whatever.
...the script does exactly what you wanted, you can add more keys and more lines for each key, you can even use some different functions for one key simultaneously, it can also replace wkRemapKeys, and you can extend the script as you wish according to your needs.

I know you want some good uncle to write a no0b-proof module for you, but one likes waitin', the other likes doin', and no time was wasted, because time is an illusion, the script was very simple, and I still believe this thread may be useful for someone else in the future...

Regards... ;D
Title: Re: wkmacros
Post by: Kradie on August 31, 2020, 03:54 PM
Cheers! ;D
Title: Re: wkmacros
Post by: StepS on August 31, 2020, 06:32 PM
There was a module for 3.6.29.0 called wkCinusAutoText but it has not been updated since and I think it only worked during the game, not in lobbies. It also predates the chat anti-flood.
You can paste multi-line text in lobbies as already said.
Title: Re: wkmacros
Post by: Albus on September 01, 2020, 11:39 AM
I'm trying to find something like that. This function would be nice for both the lobby and the chat during the game.
Title: Re: wkmacros
Post by: GrO on September 01, 2020, 03:10 PM
I'm trying to find something like that. This function would be nice for both the lobby and the chat during the game.
...you can't send multi-line text with the in-game chat and there are at least 2 ways I posted, allowing you to play with text sending (and even more using AutoHotKey app)...

...anyway, there's no sense to make another module with functionality you can easily achieve by some other methods, and the notepad>ctrl+c>ctrl+v method seems to be quite easy to use, and such functionality was never essential to the game - you want more - use the AutoHotKey soft... :)
Title: Re: wkmacros
Post by: Kaleu on September 02, 2020, 02:13 AM
Then you have to minimize per sentence to copy.
...huh? Simple text processing and still so many mysteries? :D

Didn't you know you can copy new-line-chars (or 'enters' - see the picture attached)? You can copy the whole text before running the game for your convenience and you don't need multi-monitors to minimize the game at all - what are you talkin' about man???

So many useless sarcasm in you, who needs it when you don't know the basics...

Regards.


*edit*

Someone once created an autohotkey script to type rules, it's easy to do.
Would be nice if someone actually did make this true.
...he said it's easy to do and it's actually true, just made a simple script with 3 examples (also attached it):

Code: [Select]
; codepage := 65001    ; uncomment start of this line for UTF-8 encoding,
;                              remember to save the script as 'Unicode big endian'
;
; to produce a literal commas or percent signs, you need to use so-called
; escape sign before each, example (omit the quotes):    "`," and "`%"
;
j::
  Send Hi`, rules please...
  Send {Enter}
Return

k::
  Send Hi`, you know forts?
  Send {Enter}
Return

l::
  Send Get the latest version from:`nhttps://worms2d.info/Updates
  Send {Enter}    ; "`n" makes a new line
Return

Your script is not working for me, it's in an infinite loop of sending the first sentence, I had to call Ctrl+Alt+Del hahah.
I think it's behaving like that because you forgot to use comma after the Send command.
Code: [Select]
^j::
Send, Hello World.
return

Thank you for your effort though. But it's not really what I meant.

Sorry to have wasted your time.

Peace.

It's exactly what you asked for. It's not a wk module but it's a perfect workaround.
What phrases do you want to be written and what hotkeys will trigger it? Write it down, or replace the commands and sentences from my script (Read till the end.)


I'm trying to find something like that. This function would be nice for both the lobby and the chat during the game.

Call me in Discord, I will customize a script for you. :)

::

I tried doing it myself and it worked pretty well. I made a script with multiple functions, I had nothing else in mind but nevermind, it's up to your necessities. I made this to be used just as an example.
Edit as much as you need.

Code: [Select]
~PgDn::Suspend, On
~PgUp::Suspend, off

::cak::Crate Before Attack`, Attack From Rope`, Kill The Leader
::wba::Wall Before Attack
::fba::Fly Before Attack
::cba::Crate Before Attack
::afr::Attack From Rope
::ktl::Kill The Leader
::stf::Start To Finish
::s2f::Start To Finish
::nk::No Knocking
::wfwr::Stand on a pictured weapon or tool to use it
::bngr::No straight bazookas`, No sitters`, Reaim before every shot`, No Darksiding
::fortr::No invading`, No fishing


return

^1::
Send, Hello`, welcome to my host. I saw that you are using an outdated version of Worms Armageddon`, to play this scheme you need to update your game to the latest version (currently 3.8) via this link:`nhttps://worms2d.info/Updates_(Worms_Armageddon)
Send, {Enter}

return



First function is basically a replacer for shorten version of rules if you need to explain them. However, if you need to type the actual shorten version of any rule you will need to pause the script by pressing "Page Down." And pressing "Page Up" will unpause the script again, this is to prevent conflict with in-game chat.

It will behave like that:
Let's pick wba as example here. If type wba your text will be replaced by Wall Before Attack‎‎‎‏‏‎ ‎as soon as you press Comma or Spacebar or Enter to send. This script also respects capital letters. If you type WBA the replaced text will be WALL BEFORE ATTACK‎‎‎‏‏‎.
You can check all the triggers in the source code above.

Second function is a trigger bind to Ctrl+1 to warn players that they are using an outdated version of Worms Armageddon and asking them to update it.
Ctrl is represented by "^". Any key can be assigned to send this sentence and multiple sentences can be replicated using this simple command.
Here you can find the autohotkey key list: https://www.autohotkey.com/docs/KeyList.htm

I hope this helps to make your own scripts, it's easy, all you have to do is replace text and hotkeys.
Don't forget to install AutoHotkey or the script won't work (unless it's an exe but then you would'nt be able to edit it.)

Feel free to ask any questions!


Edit: Added rules for bng (bngr), wfw (wfwr), fly shopper (fba), fort (fortr).
Title: Re: wkmacros
Post by: GrO on September 02, 2020, 02:05 PM
Your script is not working for me, it's in an infinite loop of sending the first sentence, I had to call Ctrl+Alt+Del hahah.
I think it's behaving like that because you forgot to use comma after the Send command.
...weird, I didn't test it though, but it doesn't differ from their examples: https://www.autohotkey.com/docs/commands/Send.htm#Repeating_or_Holding_Down_a_Key

...you're using the latest AHK version?

BTW, thank you for your advanced script, it may be very useful.

Regards...
Title: Re: wkmacros
Post by: Kaleu on September 03, 2020, 02:47 AM
Your script is not working for me, it's in an infinite loop of sending the first sentence, I had to call Ctrl+Alt+Del hahah.
I think it's behaving like that because you forgot to use comma after the Send command.
...weird, I didn't test it though, but it doesn't differ from their examples: https://www.autohotkey.com/docs/commands/Send.htm#Repeating_or_Holding_Down_a_Key

...you're using the latest AHK version?

BTW, thank you for your advanced script, it may be very useful.

Regards...

Yes I am using the lastest ahk :)
I used these guides, it's basically ther Beginner Tutorial.
https://www.autohotkey.com/docs/Tutorial.htm#s12

No need to thank, enjoy!
Title: Re: wkmacros
Post by: GrO on September 03, 2020, 08:22 AM
I've updated the example script (also attached it):

- now you need to hold "Alt" for binds to work (so the script won't interfere with chatting),
- added commas after 'Send' commands (thx to Kaleu),
- added some popular rules:

Code: [Select]
; INFO: "!j" = "Alt"+"j"    ; if you want to use "Ctrl" instead, just swap:
;                                      "!" with "^" (omit the quotes)
;
; codepage := 65001    ; uncomment the start of this line for UTF-8 encoding,
;                                  remember to save the script as 'Unicode big endian'
;
; to produce a literal commas or percent signs, you need to use so-called
; escape sign before each, example:    "`," and "`%"
;
; "`n"    ; makes a new line like "Enter"
;
!j::
  Send, Shopper rules:`n- crate before attack`,`n- kill the leader`,`n- attack from rope.
  Send, {Enter}
Return

!k::
  Send, Forts rules:`n- no invading`,`n- no fishing.
  Send, {Enter}
Return

!l::
  Send, Get the latest updates from:`nhttps://worms2d.info/Updates
  Send, {Enter}
Return


Yes I am using the lastest ahk :)
I used these guides, it's basically ther Beginner Tutorial.
https://www.autohotkey.com/docs/Tutorial.htm#s12

No need to thank, enjoy!
...dunno if you want it this way, but maybe you could use the below example to upgrade your script, so it'll eliminate the need of using the end-char to send the phrase:

Quote
:*:btw::by the way  ; Replaces "btw" with "by the way" without needing an ending character.


*edit*

...just tested my script and it's doing it's job really well, you can even send multi-line text with the in-game chat, while "`n" function works a little bit differently than I initially thought...

...it creates a totally new line, not another line in the same phrase, what bypasses the max characters limit that can be typed in one phrase - I like it :D
Title: Re: wkmacros
Post by: terion on September 03, 2020, 01:26 PM
wkTextMacros-v1
This module implements automatic text macros in both lobby and in-game chat.

Usage:
1) Upon first launch, the module will create a macros/ directory inside your WA installation dir.
2) Inside macros/ directory create a .txt file with the name of your desired command (for example, macros/rules.txt will be available as /rules command)
3) Edit this file with notepad and fill it with your desired text macro (save it as plaintext, ascii file)
4) When in lobby or in-game, type /macros to see a list of all available commands
5) Type the name of your command to send the text to all players

Notes:
- The text files are scanned and read on game launch and whenever you use /macros command. Thus macro file creation/modification/deletion will be reflected only when you type /macros command or restart the game.
- Text macros in lobby are sent as a single message and are limited to 1024 characters
- Text macros in-game are split by newline character into separate messages and are limited to 256 characters per line. Up to 3 text lines can be used in a single macro.
- Spamming text macros will trigger automatic /ignore by all players, so keep your macros short and use this module with moderation.
- Do not use space or other special characters in command names
- Do not use command names that overlap with bult-in game commands (/test, /version, etc)
- This module has been tested with WA version 3.8.0. It will not work with WA 3.7.2.2 and earlier versions. It might work with newer WA releases if no significant changes are made to lobby or game chat functions.
Title: Re: wkmacros
Post by: GrO on September 03, 2020, 02:17 PM
wkTextMacros-v1
This module implements automatic text macros in both lobby and in-game chat.
...really good work, thanks :)


*edit*

...I've tested it more and it doesn't print all lines from the text files. In my files the 1st line is empty, so I assume it shows 3 first lines of each file (the picture attached)
Title: Re: wkmacros
Post by: GrO on September 03, 2020, 03:36 PM
...I've made a few basic files for wkTextMacros-v1 module


*edit*

...btw, tested and it's working fantastic. Thanks again.

Regards...


*edit II*

I've tested it more and it doesn't print all lines in the in-game chat, as shown on the screenshot attached to the previous post (https://www.tus-wa.com/forums/worms-armageddon/wkmacros-32901/msg276815/#msg276815) (due to attachment count limitation).
Title: Re: wkmacros
Post by: GrO on September 03, 2020, 05:43 PM
...I've made another upgrade, so now my script prints marked text at AG, the green text in the Lobby and the green text within the in-game chat (see the screenshots attached):

Code: [Select]
; INFO: "!j" = "Alt"+"j"    ; if you want to use "Ctrl" instead, just swap:
;                                      "!" with "^" (omit the quotes)
;
; codepage := 65001    ; uncomment the start of this line for UTF-8 encoding,
;                                  remember to save the script as 'Unicode big endian'
;
; to produce a literal commas or percent signs, you need to use so-called
; escape sign before each, example:    "`," and "`%"
;
; "`n"    ; makes a new line like "Enter"
;
!j::
  Send, /me : Shopper rules:`n/me : - crate before attack`,`n/me : - kill the leader`,`n/me : - attack from rope.
  Send, {Enter}
Return

!k::
  Send, /me : Forts rules:`n/me : - no invading`,`n/me : - no fishing.
  Send, {Enter}
Return

!l::
  Send, /me : Get the latest updates from:`n/me : https://worms2d.info/Updates
  Send, {Enter}
Return

Title: Re: wkmacros
Post by: terion on September 03, 2020, 09:18 PM
...I've tested it more and it doesn't print all lines from the text files. In my files the 1st line is empty, so I assume it shows 3 first lines of each file (the picture attached)

This is an intentional limitation of the module to minimize the risk of being automatically muted by other players, as WA has built-in anti-flood mechanism. If you send multiple in-game chat messages in short time period, you will be automatically muted without any warning and your chat messages will be ignored by other players until the round ends or other players use /unignore command.
Title: Re: wkmacros
Post by: readyworm on September 06, 2020, 03:45 PM
Great work, Terion!