/// The name of the player.
<<declare $playerName = "Player">>
/// The number of gold pieces that the player has.
<<declare $gold = 0>>
/// Is the door to the dungeon unlocked?
<<declare $doorUnlocked = false>>
[!信息]
如果您添加带有三个斜杠的注释 /// 在声明上方,Visual Studio Code 扩展等编辑器工具将使用它来解释变量在其他地方使用时的含义。
例如,这是一个具有以下声明的变量:
/// What day number it is. Starts on day 0, ends on day 3.<<declare $day = 0 as number>>
当您在 Visual Studio Code 中将鼠标悬停在其上时,将出现一个弹出窗口,其中显示说明:
// Set some initial values in some variables<<set $myCoolNumber to 7>><<set $myFantasticString to "wow, text!">>// Now change them!<<set $myCoolNumber to 8>><<set $myFantasticString to "incredible!">>
这是有效的,因为虽然每个变量的值发生变化,但类型却没有变化。但是,以下代码将不起作用:
// Set some initial values in some variables<<set $myCoolNumber to 7>><<set $myFantasticString to "wow, text!">>// This will NOT work, because you can't change types!<<set $myCoolNumber to "8">><<set $myFantasticString to 42>>