스크립트로 시작하기
Link to 스크립트로-시작하기
CraftTweaker uses a custom scripting Language called ZenScript
, ZenScript is read from .zs
files that are stored in the <gamedir>/scripts
folder, if you aren't sure where this folder is, just run /ct scripts
when in the game and the folder will open.
ZenScript는 "하향식" 스크립팅 언어입니다. 즉, imports
는 파일의 가장 위에 위치해야 하고, 변수 선언
도 파일의 상단에 위치해야 하지만, 제약은 없고 어디에서나 변수
를 정의 할 수 있습니다. 그러나, 선언이 이루어지기 전에 해당 변수
는 액세스 할 수 없습니다.
Script files have the .zs
suffix, make sure that it isn't .zs.txt
!
What are scripts
Link to what-are-scripts
Scripts are stored in <gamedir>/scripts
and are loaded when the player joins a world, much like previous versions of CraftTweaker (excluding 1.12), Scripts CAN be reloaded, just run /reload
.
When joining a server, the server sends their scripts to the client, and the client runs those scripts. This does mean that a client without any scripts, can join a server and get the changes (useful if you need to disable an item on the server but don't want to force clients to download extra files!)
첫 번째 스크립트 작성
Link to 첫-번째-스크립트-작성
To get started with Scripts, you can create a very basic file, called hello.zs
in the <gamedir>/scripts>
folder; If you aren't sure where the folder is, just run /ct scripts
and it should open!
hello.zs
파일에 다음 코드를 입력하세요.
ZenScript Copyprintln("Hello world!");
Now load up Minecraft and and take a look at the <gamedir>/logs/crafttweaker.log
file (or run /ct log
to have the file open in your default text editor).
The crafttweaker.log
file is located in <gamedir>/logs
and can be read by any program that can read plaintext files.
It is recommended to use VSCode, Sublime Text or Notepad++ to edit script files, however any program will do.
When choosing a program to use to edit scripts, take a look at what Syntax highlighters are available, most common text editors have ZenScript highlighting support through the use of a plugin.
craftweaker.log 파일
Link to craftweakerlog-파일
crafttweaker.log
파일의 출력내용에는 다음과 같은 특정 구문을 사용합니다.
Copy[HH:MM:SS.ms][TYPE] <message>
위이 구문을 이용한 예제의 출력은 다음과 같습니다.
Copy[14:58:06.697][INFO] Hello world!
주석은 스크립트 파일을 더 읽기 쉽고 이해하기 쉽게 만드는데 도움을 줍니다.
ZenScript는 다음과 같은 세 가지 유형의 주석을 지원합니다.
한 라인: // 한 줄 주석입니다.
또 다른 한 라인: # 이것 또한 한줄 주석입니다.
복수 라인:
Copy/* 이건
복수 라인의
주석입니다. */
Just note, that #
comments are also used for PreProcessors, so while they are still valid comments, they could cause unwanted side effects.
The next step
Link to the-next-step
Now you know the absolute basics of how to create scripts. Now, what you do is up to you! Feel free to browse the Docs for any pages that interest you.
However, if you're getting started, we recommend checking out the Tutorial tab, more specifically the Crafting Table Tutorial as well as the Recipe Managers page for information on how to add and remove different kinds of recipes.