# Storyscript
[中文版请点击此处 (View Chinese Edition)](README_zh.md)
## Introduction and Design Ideas
Storygscript is a set of scripting systems for expressing AVG stories and is one of the official modules of AVG.js. Similar to the scripting system of other AVG engines, it is executed in the order of text; grammatically, it is quite similar to BKEngine's scripting system, but simpler.
The previous AVG script, including the entire game of all the program logic, but relatively Lua, Javasciprt and other mature programming language, the markup language syntax is very simple, on this basis to achieve the program logic, whether programmers or ordinary enthusiasts Are a troubled.
AVG.js AVG script has been stripped off the game UI, performance effects and other strong logic, and the rest is only a simple instructional code, which is the origin of the name Storyscript.
Storyscript aims to reduce the difficulty of learning, so that non-programmers can fully grasp their use, so that designers and other personnel to complete the production of game content and reduce unnecessary communication links.
For more information about AVG.js and Storyscript, please visit <https://avgjs.org>
## Installation and Usage
Storyscript has been built into the AVG.js project as the initial module. If you want to use it in AVG.js, please refer to the AVG.js tutorial.
If used in other projects, as follows:
**Installation**
```shell
npm install avg-storyscript
```
**Usage**
```javasciprt
import Story from 'avg-storyscript';
const story = new StoryScript();
story.load(scriptString);
for (const line of story) {
// do something
}
```
Refer to the test.js file for details.
## Syntax
StoryScript consists of **Content Script** and **Logical Script**.
Content script: changes in the game plot, such as print dialogue text, display characters, switch the background picture, play sound, etc.
Logic Script: Controls the direction of the game plot or provides convenient programming logic such as variable assignment, conditional branching, loops, etc.
### Content Script
**Basic**
```shell
[command flag param="value"]
```
For example
```shell
[bgm autoplay loop file="abc.ogg" volume=100]
```
Will be parsed as
```javasciprt
{
command: 'bgm',
flags: ['autoplay', 'loop'],
params: {
file: "abc.ogg",
volume: 100
}
}
```
### Logical Script
#### Statement
**LET**
```
#let foo = 123 // standard way
#bar = 456 // omit let
#let foobar // can not assign value (value will be null), thus `let` can not be omitted
```
**If**
```
#if foo > bar
// do something
#elseif foo == bar
// do something
#else
// do something
#end
```
Among them, `elseif` and`else` are optional.
**While**
```
#while i < 10
// do something
#end
```
Currently `break` and`continue` are not supported, but they are in TODO list :)
**Foreach**
```
#foreach child in children
// do something
#end
```
`children` is an array, there are some special circumstances, please read on.
#### Variables
Support for simple variable assignment and modify operations, and to meet the needs of AVG, different variables in the archive have different treatment.
**Global Archive Variables**
Variables that begin with `$` will be treated as global archive variables, meaning that once assigned, they will be read in any case, either by reading a new archive or by using a previous archive. You can use it to control the unlock CG appreciation, or support _New Game+_.
```
#let $gameclear = true;
```
**Single archive variable**
Variables that start with `%` are treated as single archive variables, meaning that they will only be valid in certain archives and will be overwritten when other archives are read. Usually used to control the route or favorability.
```
#let %girl_favor_num = 1;
```
**Common variables**
In other cases, the variable name is a normal variable, in the archive, only the archive point where the "block" and the parent "block" common variables will be saved (see below). Common variables are used only for single-file use. Do not use them to save favorability.
```
#let x = 0;
```
**Scopes**
Global archive variables and single archive variables are valid at any location, and are therefore considered global variables.
(NOTE: The global archive variable is completely unrelated to the global variable, the former is about how it is saved in the archive, while the other is about where it can be access in the game script)
For a normal variable, its scope is "block", such as an IF branch or the contents of the While statement, are a "block." The largest "block" is the "file", that is, even if you do not declare variables such as IF While, but outside of them, variables in the scope of the work is limited to the current script file.
没有合适的资源?快使用搜索试试~ 我知道了~
storyscript, 用于表示AVG故事的脚本系统,AVG.js的DSL.zip
共23个文件
js:17个
md:2个
babelrc:1个
需积分: 35 2 下载量 16 浏览量
2019-09-17
12:59:52
上传
评论
收藏 28KB ZIP 举报
温馨提示
storyscript, 用于表示AVG故事的脚本系统,AVG.js的DSL Storyscript中文版请点击此处( 查看中文版)介绍和设计思想Storygscript是一套用来表示AVG故事的脚本系统,它是类似于其他AVG引擎的官方模块之一,它与其他AVG引擎的脚本系统类似,它非常类似于系统,但是更容易实
资源推荐
资源详情
资源评论
收起资源包目录
storyscript.zip (23个子文件)
storyscript-master
.babelrc 31B
index.js 7KB
test.js 1KB
package.json 750B
ohm
bks.ohm.js 3KB
test
parser.test.js 14KB
README_zh.md 4KB
.gitignore 19B
webpack.config.js 1KB
README.md 5KB
actions
LogicBlock.js 3KB
story.js 2KB
index.js 1KB
base.js 2KB
Comment.js 851B
arithmetic.js 955B
keyvalue.js 1KB
Expression.js 1KB
Exp.js 763B
LICENSE.txt 10KB
libs
variable.js 4KB
block.js 4KB
parser.js 1KB
共 23 条
- 1
资源评论
weixin_38743737
- 粉丝: 376
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功