Minecraft command formatter

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
RandomGgames
Posts: 6
Joined: 28 Mar 2017, 07:12
Location: USA
Contact:

Minecraft command formatter

22 Jul 2018, 01:17

Take a command like this in Minecraft:

Code: Select all

tellraw @s [{"text":"Welcome back ","color":"yellow"},{"selector":"@s","color":"yellow"}]
That tells the player that ran the command
Welcome back "@s"

The script attached does this to the command when the correct amount of characters are input:

Code: Select all

tellraw @s 
	[
		{
			"text":"Welcome back ",
			"color":"yellow"
		},
		{
			"selector":"@s",
			"color":"yellow"
		}
	]
Note: This script was made to be used in Notepad++ along with the following settings set:
  • Auto-Completion > Auto-Completion > Enable auto-completion on each input > off
    MISC. > Auto-indent > on
Unknown things may occur if the window is unselected, something is clicked, or you press keys. Thus, while the script is doing it's thing, DON'T TOUCH.

Note: This script does not check whether it is inside a pair of quotes (yet)... so it might mess some stuff up if you have any of these inside a pair of quotes (or any combination of them)
  • [
    ]
    {
    }
    ,
Here's the script:

Code: Select all

;----------------------
;Created by RandomGgames / Gianluca O.
#SingleInstance, force
SetTitleMatchMode, 2
;----------------------

;SetBatchLines, 100ms
Inputbox, loop, MC Command Formatter, How many characters are there?
Loop, %loop%
	{
		send, {shift down}{right}{shift up}{lcontrol down}c{lcontrol up}{right}
		if clipboard = ,
			{
				if previous = }
					{
						send, {enter}{backspace}
						previous = },
					}
				else if previous = ]
					{
						send, {enter}{backspace}
						previous = ],
					}
				else
					{
						send, {Enter}
						previous = ,
					}
			}
		else if clipboard = [
			{
				send, {left}{enter}{tab}{right}{enter}{tab}
				previous = [
			}
		else if clipboard = ]
			{
				send, {left}{enter}{backspace}{right}
				previous = ]
			}
		else if clipboard = {
			{
				if previous = [
					send, {enter}{tab}
				else if previous = ,
					send, {enter}{tab}
				else if previous = },
					send, {left}{tab}{right}{enter}{tab}
				else
					send, {left}{enter}{tab}{right}{enter}{tab}
				previous = {
			}
		else if clipboard = }
			{
				if previous = }
					send, {left}{enter}{backspace 2}{right}
				else if previous = ]
					send, {left}{enter}{backspace 2}{right}
				else
					send, {left}{enter}{backspace}{right}
				previous = }
			}
		else
			previous = 
	}

Suggestions always appreciated in the comments. As always, don't take credit for the script. Partial credit is always appreciated if edits are made.
-Random

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 129 guests