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 14:05] – [Control Shared Save] carbonaradevelopment:technical-details:patches:maniac:new-maniac-commands [2026/10/09 16:52] (current) – [Zoom Screen] carbonara
Line 970: 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 1002: 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.1791554741.txt.gz · Last modified: by carbonara