Script

The *script command allows for JavaScript to be used directly in a ChoiceScript game. *script命令允许在ChoiceScript游戏中直接使用JavaScript。

As ChoiceScript works on top of JavaScript there should be no errors if it is used correctly, however, the *script command and other JavaScript elements are beyond the scope of this wiki and ChoiceScript in general, and is not supported by Choice of Games, the ChoiceScript Development team, nor the ChoiceScript community. Additionally, as the *script command requires prior knowledge of JavaScript, unless you are already proficent in JavaScript, the *script command should be avoided. 由于ChoiceScript构建于JavaScript之上,若使用得当则不应出现错误。然而,*script指令及其他JavaScript元素已超出本维基乃至ChoiceScript的整体范畴,且不受Choice of Games公司、ChoiceScript开发团队及ChoiceScript社区的技术支持。此外,由于*script指令要求使用者具备JavaScript基础知识,除非您已精通JavaScript,否则应避免使用该指令。

Usage 用法

A basic use of *script is as follows: *script指令的基础用法示例如下:

*temp terminale
*set terminale false
*label menu
[b]CSS Demo[/b]
*choice
 *if (terminale = false) #Change to Computer Terminal CSS
   *set terminale true
   *script changeDisplay("terminal")
   *goto menu
 *if (terminale) #Change to Story CSS
   *set terminale false
   *script changeDisplay("story")
   *goto menu

Then, in a javascript file (it is recommended that you declared another file in index.html and use that instead of one of the preexisting files to make updating and error checking easier): 随后在JavaScript文件中(建议您在index.html中声明独立文件并调用该文件,而非直接修改现有文件,以便于版本更新与排错):

This will make a choice which switches the style of the page between what is normally is, and an old fashioned computer terminal, with a black background and green text. 此操作将创建一个选项,用于在常规页面样式与老式计算机终端样式(黑底绿字)之间切换页面风格。

In short, with *script, anything that JavaScript can do, ChoiceScript can also do, so long as you already know JavaScript. 简而言之,只要您已掌握JavaScript,*script就能实现JavaScript所能完成的一切操作。