Minecraft Script to Tellraw Datapack Generator

Overview

Minecraft Script to Tellraw Datapack Generator

by CCpcalvin

Note by CCpcalvin

Note that it is my first project and it is the final project of CS50 in edX. I know that the syntax is quite difficult and I try to make it as simple as possible. Also, the coding is not elegant as well. I may try to make it cleaner if I have time. Feel free to download it and even help me to improve the coding since I am still a beginner in coding.


Table of Contents

What is this generator do?

tellraw is the command in Minecraft to print the message in Minecraft. This command is essential especially for making map since it can be used to tell the player about the progress of the map, or the dialogue between NPC, or anything else. This generator can turn a script into multiple functions in a datapack of a Minecraft map so that we can execute multiple tellrawfunctions in one command.

Quickstart

To use this generator, we need to install python3. We first need to create script.txt file inside the folder containing multiple .py files. This file is used to input the script. Now we may write some lines inside the script.txt such as

Calvin: hello
Even: hello world
Calvin: hello Even

By running python tellraw.py, it will create two folders, namely start and scene_1 folders. Then you need to put those two folders inside the data folder of the datapack (by the way you can change the name of these two folders to prevent crashes of the name). Then in Minecraft, after reloading the datapack, by running /function start:scene_1, then those messages will pop up on the screen one by one with constant time intervals.

Advanced Usage

Principle of this generator

You may visit this wiki page for some basic information about datapack and this wiki for the basic information of function in datapack. A .mcfunction file contains a chain of command that can be executed inside Minecraft at the same time. This generator can generate multiple .mcfunction files with integer names inside the scene_1 folders (actually this generator can generate multiple scene folders. More detail can be found below). For a pure tellraw-purpose datapack, a .mcfunction may look like:

4s ">
tellraw @a {"text":"Ryan: Hello World"}
schedule function scene_1:
   
     4s

   

Here , are the placeholders. The first line of the code is the tellraw command that prints Ryan: Hello World and the second line of the code is to tell Minecraft to run next .mcfunction file in 4 seconds. Therefore by running the heading .mcfunction file, the tellraw command will be executed in every 4 seconds. The command /function start:scene_1 basically is to tell Minecraft to execute the heading .mcfunction file.

Inside script.txt

Beyond tellraw, we can add more stuff inside script.txt. The program will run each line into one .mcfunction file. The basic format of each line in script.txt is


   
     \ 
    
      \ 
     
       \ ... 

     
    
   

Here , , are the placeholders containing different actions to perform in one .mcfunction file. Each function has the format = , . is the placeholder of string to tell what command to be added inside a .mcfunction file. If we omit the = , then the program will automatically consider the string inside an argument is something to print out by tellraw. For example,

tell()=" Ryan: Hello World "

and

Ryan: Hello World

will generate the same .mcfunction file. Note that tell is the tag to indicate tellraw command.

There are many in this program. They will be discussed below.

Also, notice that a blank new line and \t in script.txt will be ignored in this program.

Behavior of delimiter

The program will use \ as the delimiter. You can change another symbol in symbol in the config file.

Changing input file

You can change the input file by running python tellraw.py . The third argument can be omitted and it will set script.txt as the input file.

List of functions available:

Beware that the space bar cannot be omitted. Only can be replaced. You can replace the empty string for .

Tellraw text:

We can use tell( )=" " or tellraw( )=" " or omit the tag to indicate that it is a tellraw command. Note that the space cannot be omitted. The advantage to use a tag instead of omitting it is we can change the font and the text color by some optional arguments. For example,

tell(c=Blue, b)=" Even " \ :Hello \ tell(i, u, c=#28D7CC, click(run=/weather clear))=" World "

to print:

There are lots of optional arguments in this function:

  1. Font related

    • c= or color= : to change the color. can be a word or a hex color code. Only word inside the list: [Red, Green, Blue, White, Yellow, Dark_Red, Dark_Green, Dark_Blue, and Gold] is accepted, and it is case-insensitive.
    • b or bold: to have bold text
    • i or italic: to have italic text
    • u or underlined: to have underlined text
    • s or strikethrough: to have strikethrough text
    • o or obfuscated: to have obfuscated text
  2. Event-related

    • click( = ) : to control what action to be performed when click the text. There are a few possible actions to be performed in this program
      • open: to open a url. should a url.
      • run: to run a command as the player who clicks the text. should be a command
      • suggest: to suggest a command to the player who click the text. should be a command
      • copy: to copy any string to the player's clipboard. can be any string.

Note that the program will read the line from left to right. Make sure to arrange the function in order. Also, you can print line-break with \n as the message.

Changing time interval

We use t= or time= to indicate how much time to wait to execute the next .mcfunction file. Without this tag, the function will automatically take 4 seconds to execute the next file. For example,

Even: Hello World \ t=2s
Calvin: Hello Even \ t=35t
Ryan: Hello everyone \ t=2d

We need to indicate the unit in time. There are three possible units: t, s, d. t stands for tick (roughly 20 ticks for 1 second. This can be changed by gamerule command), s stands for second and d stands for Minecraft-day (roughly 20 minutes).

Title

Sometimes you may want to use title instead of tellraw. We can use title( )=" "</code> to indicate the main title. If we want to add subtitle, we can use sub( )=" ") or subtitle( )=" " .

sub(c=black, o)=" The doom's day " \ title(in=20, out=20, dur=80, c=blue, b, u)=" Chapter 0 " \ t=5s

Both commands accepts the same font-related optional arguments as tellraw. Note that we must provide:

  • in=: to indicate the fade-in duration. The unit is tick and it must be an integer.
  • out=: to indicate the fade-out duration. The unit is tick and it must be an integer.
  • dur=: to indicate the duration of title that is visible and not in fade in time and fade out time. The unit is tick and it must be an integer.

Running another command

Sometimes you may want to execute some commands other than tellraw or title command, in that case, we can use run=. For example,

Even: Give you some healing \ t=3s
Calvin: Thanks you \ run=effect give @a minecraft:regeneration 5 1 true

Then at the same time that print "Calvin: Thanks you", it also gives the regeneration to all the players.

Comment

Sometimes you may want to comment on some commands. The way to do it is to use -- -- . The program will ignore the whole sequence. It can also be used to a new line.

-- Even appear and talk to Ryan --
Even: Hello Ryan \ t=2s \-- Even should face to Ryan --\
Ryan: Hello Even\ t=3s 

Ending the dialogue

Sometimes you may want to end the dialogue(more precisely ending the chain of command). You can use end tag. For example:

Even: Hello Calvin \ end 
Calvin: Hello Even

Although the program will also produce 2.mcfunction that contain a tellraw command, "Calvin: Hello Even" will not print out because of the end tag in the first line.

Writing command in multiple lines

Sometimes you want to add lots of things in one .mcfunction. To have a good and clean style, we can use cont or tag at the end of the line to indicate that functions in the next line should also be written in the same .mcfunction as the pervious line. For example:

-- Boss fight start --
tell(c=red)=" Boss "\ :Let's get started!! \ cont 
	run=function trackboss:start \-- Start tracking boss health --\ cont 
	run=function bossbar:on \-- Enable bossbar and write the boss' health to bossbar --\ cont 
	run=function boss_fight_bgm:start \-- Start bgm --\ end 

will give out a .mcfunction file that contains:

tellraw @a ["", {"text": "boss", "color": "red"}, ":Let's get started!!"] 
function trackboss:start
function bossbar:on
function boss_fight_bgm:start

Creating a new folder

For a long script, you may not want to put all .mcfunction in the same folder. We can use create= to tell the program to create a new folder and put the remaining .mcfunction to the new folder. Make sure that you do not have the folder with the same name, otherwise, the program will replace the origin folder to new folder or exit depend on the value of REPLACE. Note that is case-insensitive and the program will turn all characters to lowercase since namespaces in Minecraft do not allow any uppercase letter.

create=scene_1 \ cont 
-- Even appear and talk to Ryan --
Even: Hello Ryan \ t=2s \-- Even should face to Ryan --\
Ryan: Hello Even\ end 

create=scene_2 \ cont
-- Boss fight start --
tell(c=red)=" Ryan " \ :Let's get started!! \ cont 
	run=function trackboss:start \-- Start tracking boss health --\ cont 
	run=function bossbar:on \-- Enable bossbar and write the boss' health to bossbar --\ cont 
	run=function boss_fight_bgm:start \-- Start bgm --\ end 

This tag also add a function in start folder so that by running \function start:scene_2 to execute the heading of scene 2.

Config File Settings

We can change the behaviour of the program in config.txt file.

Changing the delimiter

Write DELIMITER=" " to change the delimiter

Automating apply the style to text

You may want to automatically apply the particular text style for particular word. To do this, we write:

" ">
tell(
     
      )=" 
      
        "

      
     

in config.txt file. The is the same as the optional argument in tell tag. For example:

tell(c=red, b)=" Ryan " 
tell(c=green, u)=" Even "

In this case, the program will turn all "Ryan" to red bold text and all "Even" to green underlined text.

Replacing existed file

By default, the program will exit when there is a crash of the folder name. By writing REPLACE = "yes" in config.txt, it will replace the existed file instead of exiting.

Python fitting assistant, cross-platform fitting tool for EVE Online

pyfa What is it? Pyfa, short for python fitting assistant, allows you to create, experiment with, and save ship fittings without being in game. Open s

1.4k Dec 22, 2022
BUBBLE SHOOT - Pygame (python)

BUBBLE-SHOOT---Pygame BUBBLE SHOOT - Pygame (python) Bubbleshooter This is a Bubble shooter Game made with pygame. The arrow is controlled by the arro

ROBIN JONEY 1 Nov 12, 2021
Open source translation for the Tsukihime Remake game

Tsukihime-Translation Open source translation for the Tsukihime Remake game prepared by Clovermoon and Tsukihimates. Copyright Disclaimer under Sectio

118 Jan 01, 2023
A programme which basically has the same function as the actual Rock paper scissors game.

A programme which basically has the same function as the actual Rock paper scissors game.

1 Feb 11, 2022
Wordle is a web-based word game. Players have six attempts to guess a five-letter word;

Wordle is a web-based word game. Players have six attempts to guess a five-letter word; feedback is given for each guess, in the form of colored tiles, indicating when letters match or occupy the cor

Abhishek 2 May 21, 2022
For educational purposes, a simple script that assists in solving the word game Wordle.

WordleSolver For educational purposes, a simple script that assists in solving the word game Wordle. Instructions Pick your first word from the sugges

Christian De Leon 2 Mar 25, 2022
A simple hangman game for beginners trying to learn python

Hangman Game This is a simple hangman game for beginners trying to learn python. I have tried to keep it as simply as possible. Sample output Here is

1 Oct 13, 2021
Python Knots and Crosses game, with customizable markers and more!

Knot-and-Crosses Python Knots and Crosses game, with customizable markers and more! Features: Ability to change your marker Ability to change how many

4 Nov 07, 2021
MinMax Algo , Python

Write a PYTHON program to play the game of TIC-TAC-TOE on a 3×3 board with alternate inputs from user and computer.

Naman Anand 1 Nov 26, 2021
Discord based board game, Sneks and Ladders

sneks-and-ladders Discord based board game, Sneks and Ladders intro This is the code-base for the Discord based game, Sneks and Ladders, as used for s

Yohei Nakajima 3 Nov 04, 2022
A Tetris Game for programming education

Tetris Game プログラミング学習を目的とした、ブロックを操作してスコアを競うゲームです。 FAQはこちら。 tutorialはこちら。 実行環境準備 Mac環境 Finder→Application→Utility→Terminalから、ターミナルを起動して以下コマンドを実行する。 # i

11 Dec 01, 2022
Rudimentary CMD based implementation of the Tic Tac Toe game

Packages used: questionary random os (Requires Python 3.8 as walrus operators are used in the script) Contains the .py file (tictactoe.py) and an exe

Ashwin 1 Oct 15, 2021
A zombie game using Kinetic. You can control players using fingers

This is Eden Park's portpolio: Works, projects and practices This repository can be used to show the potential employers to check my works, code and p

Eden Park 4 May 16, 2022
TetrisAI - Tetris AI Bot using computer vision to play game automatically

Tetris AI Tetris AI Bot using computer vision to play game automatically bot.py

11 Aug 29, 2022
This is a two player snake game

Trake This is a two player snake game How to play the game There is food and two players. You try to eat food to become large and gain points. Player

Grrub 1 Dec 19, 2021
用于 blivechat 的图形界面

blivechat GUI 用于 blivechat 的图形界面。 有朋友在搞 Vtuber,像 blivechat 类似的项目能通过自定义 CSS 的方式在 OBS 上添加一个非常好看的聊天栏。但是想要在桌面端看到弹幕的话得要再开一个浏览器页面,十分不方便。就想写一个背景透明的浮窗浏览器。 挺喜欢

Silence 11 Dec 29, 2022
A full featured game of falling pieces using python's pygame library.

A full featured game of falling shapes using python's pygame library. Key Features • How To Play • Download • Contributing • License Key Features Sing

Giovani Rodriguez 7 Dec 14, 2022
Datamining of 15 Days of (free) Games at the Epic Games Store (EGS).

EGS: 15 Days of Games This repository contains Python code to data-mine the 15 Days of (free) Games at the Epic Games Store (EGS). Requirements Instal

Wok 9 Dec 27, 2022
This is the card game like HearthStone and Magic

Territory War How to use it use pip3 to install django and channels: pip3 install Django pip3 install channels go to CardGame/first/consumers.py and g

Caesar 3 Oct 24, 2022
Code d'un jeu en python par Graveen (avec mes modifications)

ATTENTION Vous ne devez pas copier coller le code sans le comprendre, apprennez déjà, le python et pygame, et seulement ensuite, vous pourrrez l'utili

TheBigWolfy 7 Nov 02, 2022