User Tools

Site Tools


mtr_addon:nte:js:start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
mtr_addon:nte:js:start [2023/10/08 14:36] weryskokmtr_addon:nte:js:start [2024/02/06 13:08] (current) – added source weryskok
Line 1: Line 1:
 ====== JavaScript Support ====== ====== JavaScript Support ======
-NTE supports fully customizable control of rendering and other features using JavaScript code. This page lists the various functions, objects, etc. provided when using JavaScript in NTE.+NTE supports fully customizable control of rendering and other features using JavaScript. This page lists the various functions, objects, and types provided when using JavaScript with NTE.
  
 ===== Why Overcomplicate Everything? ===== ===== Why Overcomplicate Everything? =====
-The main purpose of this feature is to implement dynamic displays on trains, but you have to keep in mind that the interface of the displays, the logic of operation, and so on, varies greatly from city to city and from train to train around the world.+The main purpose of this feature is to implement dynamic displays on trains with the intent to support many different types and displays found in trains all over the world.
  
-If a simple format was chosen, it would not be possible to flexibly reproduce the actual interface, and there would be a lot of requests and complaints; if a more complex format was developed to implement the logicthe result would be something like JSbut not as easy to learn and use as JS. So in the end it was decided to use the JS runtime to maximize flexibility.+By simplifying this process, it would be too hard to accurately reproduce how the system looks and works in real life and a lot of people would complain. This more complicated format is designed to let all sorts of logic and display types be implemented in the game without limiting creators too much. The downside to this is that nowall creators who want to create things will have to learn JavaScript to make use of these features.
  
-===== How To Edit .js Files? ===== +===== How To Edit JavaScript Files? ===== 
-Any text editor will do, such as Notepad3 or Notepad++. You may want to use something like Visual Studio Code. Using IDEA/Visual Studio will probably be unnecessary.+A JavaScript file (.js) can be edited in a variety of editors. It is recommended to have a text editor that supports JavaScript [[wp>Syntax_highlighting|Syntax Highlighting]] like Notepad++ or Sublime textWhile a full IDE (like Visual Studio Code or IntelliJ) is not recommended, it can also be used as a basic text editor.
  
-This article assumes that you have some basic understanding of JavaScript, so it won't delve into the basic syntax and other aspects of JavaScript here, you can learn JavaScript from resources on the web, such as [[https://javascript.info/|here]]. Reminder: JavaScript has nothing to do with Java.+This rest of this article assumes that you have basic understanding of JavaScript and JavaScript types, so it won't delve into the basic syntax and other aspects of it here. You can learn JavaScript from resources on the web, such as [[https://javascript.info|here]].
  
 ===== Type Annotation ===== ===== Type Annotation =====
-As you know, values ​​in JS have different types. When calling a function, you must pass parameters of the appropriate type, and the result it returns will also have a type. In this article, the parameter and return types of the provided functions are denoted in a form similar to TypeScript. For example:+As you know, values ​​in JS have different types. When calling a function, you must pass parameters of the appropriate type, and the result it returns will also have a type. In this article, all of the functions have their parameter and return types stated. For example:
   * <code javascript>static Resources.id(idStr: String): ResourceLocation</code>   * <code javascript>static Resources.id(idStr: String): ResourceLocation</code>
     * ''static'' means that you don't need to create an object to use this function, you can call ''Resources.id("aaa:bbb")'' directly.     * ''static'' means that you don't need to create an object to use this function, you can call ''Resources.id("aaa:bbb")'' directly.
Line 62: Line 62:
   * <code javascript>static include(path: ResourceLocation): void</code>   * <code javascript>static include(path: ResourceLocation): void</code>
     * Loads and runs the JS file by location in the resource pack. For example, ''include(Resources.id("mtr:path/absolute.js"))''.     * Loads and runs the JS file by location in the resource pack. For example, ''include(Resources.id("mtr:path/absolute.js"))''.
 +
 +===== Source =====
 +* https://www.zbx1425.cn/nautilus/mtr-nte/#/js-general
mtr_addon/nte/js/start.1696775806.txt.gz · Last modified: 2023/10/08 14:36 by weryskok