User Tools

Site Tools


development:technical-details:patches:maniac:new-maniac-commands

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
development:technical-details:patches:maniac:new-maniac-commands [2026/10/09 11:53] – [Console] carbonaradevelopment:technical-details:patches:maniac:new-maniac-commands [2026/10/09 16:52] (current) – [Zoom Screen] carbonara
Line 68: Line 68:
  
 Notes: Notes:
-  * Output saves are subject to the file output limit of the patch (not more than ~3 file writing per second): if the file output limit is reached, the [[modified-maniac-commands#file-output-is-available|Conditional Branch: File output is available]] will be reported as true until it becomes possible again to write files.+  * Output saves are subject to the file output limit of the patch (not more than ~3 file writing per second): if the file output limit is reached, the [[modified-maniac-commands#file-output-is-available|Conditional Branch: File output is available]] will be reported as false until it becomes possible again to write files.
  
 It can be written as follow with the common TPC syntax: <code>@save[1].save .res v[2]</code> It can be written as follow with the common TPC syntax: <code>@save[1].save .res v[2]</code>
Line 221: Line 221:
 ===== Control Shared Save ===== ===== Control Shared Save =====
  
-FIXME+//Player status: Supported //✅//; Global save status is set to be opened on boot if it exists, no file output limit.// 
 + 
 +The Control Shared Save command (共有セーブの操作, known as Control Global Save in previous versions) allows to save switches and variables in a file named ''Save.lgs'', that will be able to be read and written while playing from any save file. 
 + 
 +When using the command, there are two different global save locations that need to be distinguished: 
 +  * The **global save**, which consists of the area where the data is temporarily written in memory and altered by the various functions of the command. 
 +  * The ''Save.lgs'' file, which is the actual file written in the game folder that can be read and written on. It will always be referred as ''Save.lgs'' in the documentation of this command to avoid confusion with the global save. 
 + 
 +Additionally, the global save can have two statuses, opened and closed: 
 +  * If set to opened, and that the game is closed either by the user or by using the Exit Game command, the content of the global save will be copied to the ''Save.lgs'' file. 
 +    * The ''Save.lgs'' file will not be updated if the game is forcefully closed by e.g. the Task Manager, or if a major game crash occurs (simple error messages from the engine properly write data). 
 +  * If set to closed, exiting the game will not alter the ''Save.lgs'' file. 
 + 
 +Notes: 
 +  * The file ''Save.lgs'' is stored at the root of the game folder. 
 +  * Upon game boot or game reset, the content of the ''Save.lgs'' file is copied to the global save, and the global save status is set to closed. 
 +  * The output ''Save.lgs'' file is subject to the file output limit of the patch (not more than ~3 file writing per second): if the file output limit is reached, the [[modified-maniac-commands#file-output-is-available|Conditional Branch: File output is available]] will be reported as false until it becomes possible again to write files. 
 + 
 +==== Open ==== 
 + 
 +By using **Open**, the global save status will be set to opened. 
 + 
 +Common TPC syntax: <code>@gsave.open</code> 
 + 
 +Raw writing: <code>3016, "", 0</code> 
 + 
 +==== Close ==== 
 + 
 +By using **Close**, the content of the ''Save.lgs'' file will be copied to the global save, and the global save status will be set to closed. 
 + 
 +Common TPC syntax: <code>@gsave.close</code> 
 + 
 +Raw writing: <code>3016, "", 1</code> 
 + 
 +==== Save ==== 
 + 
 +By using **Save**, the content of the global save will be written on the ''Save.lgs'' file. 
 + 
 +Notes: 
 +  * The opened/closed status of the global save does not matter for saving. 
 + 
 +Common TPC syntax: <code>@gsave.save</code> 
 + 
 +Raw writing: <code>3016, "", 2</code> 
 + 
 +==== Save then Close ==== 
 + 
 +By using **Save then Close**, the content of the global save will be written on the ''Save.lgs'' file, and the global save status will be set to closed. 
 + 
 +Notes: 
 +  * The opened/closed status of the global save does not matter for saving. 
 + 
 +Common TPC syntax: <code>@gsave.saveAndClose</code> 
 + 
 +Raw writing: <code>3016, "", 3</code> 
 + 
 +==== Copy from Global Save ==== 
 + 
 +**Copy from Global Save** allows to copy values from the global save to switches and variables. 
 + 
 +The command has the following fields: 
 +  * Type: Whether switches or variables should be copied. 
 +  * Current Save Data: Position of the first switch or variable ID should receive the values from the global save, with the possility to use a constant or variable for the ID. 
 +  * Global Save Data: Position of the first switch or variable in the global save that should be copied, with the possility to use a constant or variable for the ID. 
 +  * Size: How many values should be copied, with the possibility to use a constant, variable or variable redirection. 
 + 
 +Notes: 
 +  * Switches and variables do not share their slot allocations, so you can use the same slot numbers without conflict. 
 +  * Using the command will set the global save status to opened. 
 +  * Using a null or negative size will not copy any value. 
 + 
 +Common TPC syntax for switches: <code>gs[2].copyTo s[1], 3</code> 
 +Common TPC syntax for variables: <code>gv[2].copyTo v[1], 3</code> 
 + 
 +Where: 
 +  * ''1'' corresponds to the position of the wanted value in the game data, with the possibility to use a constant or variable. 
 +  * ''2'' corresponds to the position of the wanted value in the global save, with the possibility to use a constant or variable. 
 +  * ''3'' corresponds to the size of the array, with the possibility to use a constant, variable or variable redirection. 
 + 
 +Raw writing: <code>3016, "", 4, b, c, d, e, f</code> 
 +  * ''3016'': Command code 
 +  * ''b'': Defines if the values to use are constants, variables or variable redirections: 
 +    * ''+1'' if the current game data position to use should be a variable. 
 +    * ''+16'' if the global save position to use should be a variable. 
 +    * ''+256'' if the size to use should be a variable. 
 +    * ''+512'' if the size to use should be a variable redirection. 
 +  * ''c'': Whether the type to use should be switches (0) or variables (1). 
 +  * ''d'': Value to use for the current game data position. 
 +  * ''e'': Value to use for the global save position. 
 +  * ''f'': Value to use for the size. 
 + 
 +==== Copy to Global Save ==== 
 + 
 +**Copy to Global Save** allows to copy switches and variables to the global save. 
 + 
 +The command has the following fields: 
 +  * Type: Whether switches or variables should be copied. 
 +  * Current Save Data: Position of the first switch or variable ID that should be copied to the global save, with the possility to use a constant or variable for the ID. 
 +  * Global Save Data: Position of the first switch or variable in the global save that should be written to, with the possility to use a constant or variable for the ID. 
 +  * Size: How many values should be copied, with the possibility to use a constant, variable or variable redirection. 
 + 
 +Notes: 
 +  * Switches and variables do not share their slot allocations, so you can use the same slot numbers without conflict. 
 +  * Using the command will set the global save status to opened. 
 +  * Using a null or negative size will not copy any value. 
 + 
 +Common TPC syntax for switches: <code>gs[2].copyFrom s[1], 3</code> 
 +Common TPC syntax for variables: <code>gv[2].copyFrom v[1], 3</code> 
 + 
 +Where: 
 +  * ''1'' corresponds to the position of the wanted value in the game data, with the possibility to use a constant or variable. 
 +  * ''2'' corresponds to the position of the wanted value in the global save, with the possibility to use a constant or variable. 
 +  * ''3'' corresponds to the size of the array, with the possibility to use a constant, variable or variable redirection. 
 + 
 +Raw writing: <code>3016, "", 5, b, c, d, e, f</code> 
 +  * ''3016'': Command code 
 +  * ''b'': Defines if the values to use are constants, variables or variable redirections: 
 +    * ''+1'' if the current game data position to use should be a variable. 
 +    * ''+16'' if the global save position to use should be a variable. 
 +    * ''+256'' if the size to use should be a variable. 
 +    * ''+512'' if the size to use should be a variable redirection. 
 +  * ''c'': Whether the type to use should be switches (0) or variables (1). 
 +  * ''d'': Value to use for the current game data position. 
 +  * ''e'': Value to use for the global save position. 
 +  * ''f'': Value to use for the size.
  
 ===== Set Picture ID ===== ===== Set Picture ID =====
Line 768: Line 892:
   * If a picture is currently being displayed and that its source file gets overwritten, the picture displayed will not change, and attempting to display another picture pulled from the same source file will display the new picture using the same display than the currently displayed picture, as its graphic will be pulled from the picture list.   * If a picture is currently being displayed and that its source file gets overwritten, the picture displayed will not change, and attempting to display another picture pulled from the same source file will display the new picture using the same display than the currently displayed picture, as its graphic will be pulled from the picture list.
     * Edited pictures through the Edit Picture or Edit Picture (Tile) commands no longer point to their original picture file, so they are not subject to this point. In the case of Edit Picture, it will work as long as the selected picture ID was targeted independently if pixels were actually written.     * Edited pictures through the Edit Picture or Edit Picture (Tile) commands no longer point to their original picture file, so they are not subject to this point. In the case of Edit Picture, it will work as long as the selected picture ID was targeted independently if pixels were actually written.
-  * Output pictures are subject to the file output limit of the patch (not more than ~3 file writing per second): if the file output limit is reached, the [[modified-maniac-commands#file-output-is-available|Conditional Branch: File output is available]] will be reported as true until it becomes possible again to write files.+  * Output pictures are subject to the file output limit of the patch (not more than ~3 file writing per second): if the file output limit is reached, the [[modified-maniac-commands#file-output-is-available|Conditional Branch: File output is available]] will be reported as false until it becomes possible again to write files.
  
 ==== Game Screen ==== ==== Game Screen ====
Line 846: Line 970:
 //Player status: Unsupported// ❌ //Player status: Unsupported// ❌
  
-FIXME+The Script command (スクリプト) allows to execute JavaScript code. 
 + 
 +The Maniac Patch executable comes bundled with [[https://bellard.org/quickjs/|QuickJS Javascript Engine]] to be able to execute JavaScript code, and as such follows its [[https://bellard.org/quickjs/quickjs.pdf|syntax and features]]. Note that the os and std functions are not present in the Maniac Patch implementation of QuickJS, due to their potential dangerous use. 
 + 
 +Additionally, the following JavaScript commands can be used to alter switches, variables and string variables: 
 +  * <code>s[123] = 1</code> to alter the status of a switch (here, 123), with 0 to set it OFF and 1 to set it ON. The switch ID can be replaced by a variable (''s[v[123]]''). 
 +  * <code>v[123] = 456</code> to change the value of a variable (here, 123 being set to 456). The variable ID can be replaced by a variable (''v[v[123]]''). 
 +  * <code>t[123] = 'hello'</code> to change the text of a string variable (here, 123 being set to hello). The string variable ID can be replaced by a variable (''t[v[123]]''). 
 + 
 +The command has the following fields: 
 +  * Source Text: Code to execute, with the possibility to have it come from the command, from a string variable or from a string variable redirection. 
 +  * Variable that receive return value: Switches, switch redirections, variables, variable redirections, string variables and/or string variable redirections that should receive output values from the executed code, with as many output values as wanted. For instance, if you only execute the code ''[1, "a", 2]'' and that you set the output to be switch 10, string variable 20 and variable 30, the switch 10 will receive the value ON, the string variable 20 the value a and the variable 30 the value 2. 
 + 
 +FIXME //Provide more examples and info on using JavaScript and making it communicate with the engine.// 
 + 
 +Notes: 
 +  * If a command with an incorrect syntax is executed, the console will be opened and will display an error highlighting the syntax issue. This does not halt the game. 
 + 
 +Internally, the command comes with two different command codes, ''3030'' and ''3031'', with ''3030'' used for the first line of a script and ''3031'' used for the next lines of a same script. This is similar to the Show Text and Comment commands, where their first line and their other lines use different command codes. Using ''3031'' commands without starting with a ''3030'' command first will not do anything. 
 + 
 +TPC only offers editing the first command code: the second command code is impossible to edit through the Maniac Patch or TPC, and can only be deleted. 
 + 
 +TPC syntax of the first command code: <code>@js [s[1], s[v[2]], v[3], v[v[4]], t[5], t[v[[6]]] .run "code"</code> 
 + 
 +Where: 
 +  * ''code'' corresponds to the JS code to execute, with the possibility to replace it by a string variable or string variable redirection. 
 +  * <code>''[s[1], s[v[2]], v[3], v[v[4]], t[5], t[v[[6]]]</code> corresponds to the variables that should receive any output values. It is possible to set none by removing the brackets entirely. 
 + 
 +Raw writing for the command code 3030: <code>3030, "code", a, b, 0, 0, e, f, g</code> 
 +  * ''code'': If the code is set to come from the command, code to execute. 
 +  * ''a'': Whether the code to use should come directly from the command (0), from a string variable (1) or from a redirection of string variable (2). 
 +  * ''b'': If the code does not come from the command, value to use for the code. 
 +  * ''e'': How many values should be set as outputs. 
 +  * ''f'': Type of the selected output: 
 +    * ''0'': Switch 
 +    * ''1'': Switch redirection 
 +    * ''2'': Variable 
 +    * ''3'': Variable redirection 
 +    * ''4'': String variable 
 +    * ''5'': String variable redirection 
 +  * ''g'': Value to use for the selected output. 
 + 
 +The values ''f'' and ''g'' are repeated up until the number of selected outputs. 
 + 
 +Raw writing for the command code 3031: <code>3031, "code"</code> 
 +  * ''3031'': Command code 
 +  * ''code'': JavaScript code to execute.
  
 ===== Zoom Screen ===== ===== Zoom Screen =====
Line 878: Line 1048:
   * Setting the Scale to a value above 24000 will not do any zoom.   * Setting the Scale to a value above 24000 will not do any zoom.
   * If the layer is set to a value not on the [1;10] range, no zoom will occur.   * If the layer is set to a value not on the [1;10] range, no zoom will occur.
 +  * The zoom only affects the overworld, it does not affect battles and menus.
   * The zoom properties are kept in the save file.   * The zoom properties are kept in the save file.
  
development/technical-details/patches/maniac/new-maniac-commands.1791546806.txt.gz · Last modified: by carbonara