Skip to content
This repository was archived by the owner on Jan 9, 2025. It is now read-only.

Commit 2d0753b

Browse files
committed
add README
1 parent f7eaeb4 commit 2d0753b

File tree

2 files changed

+314
-0
lines changed

2 files changed

+314
-0
lines changed

README.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# Storyscript
2+
3+
[中文版请点击此处 (View Chinese Edition)]()
4+
5+
## Introduction and Design Ideas
6+
7+
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.
8+
9+
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.
10+
11+
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.
12+
13+
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.
14+
15+
For more information about AVG.js and Storyscript, please visit <https://avgjs.org>
16+
17+
## Installation and Usage
18+
19+
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.
20+
21+
If used in other projects, as follows:
22+
23+
**Installation**
24+
25+
```shell
26+
npm install avg-storyscript
27+
```
28+
29+
**Usage**
30+
31+
```javasciprt
32+
import Story from 'avg-storyscript';
33+
const story = new StoryScript();
34+
story.load(scriptString);
35+
for (const line of story) {
36+
// do something
37+
}
38+
```
39+
40+
Refer to the test.js file for details.
41+
42+
## Syntax
43+
44+
StoryScript consists of **Content Script** and **Logical Script**.
45+
46+
Content script: changes in the game plot, such as print dialogue text, display characters, switch the background picture, play sound, etc.
47+
48+
Logic Script: Controls the direction of the game plot or provides convenient programming logic such as variable assignment, conditional branching, loops, etc.
49+
50+
### Content Script
51+
52+
**Basic**
53+
54+
```shell
55+
[command flag param="value"]
56+
```
57+
58+
For example
59+
60+
```shell
61+
[bgm autoplay loop file="abc.ogg" volume=100]
62+
```
63+
64+
Will be parsed as
65+
66+
```javasciprt
67+
{
68+
command: 'bgm',
69+
flags: ['autoplay', 'loop'],
70+
params: {
71+
file: "abc.ogg",
72+
volume: 100
73+
}
74+
}
75+
```
76+
77+
### Logical Script
78+
79+
#### Statement
80+
81+
**LET**
82+
83+
```
84+
#let foo = 123 // standard way
85+
#bar = 456 // omit let
86+
#let foobar // can not assign value (value will be null), thus `let` can not be omitted
87+
```
88+
89+
**If**
90+
91+
```
92+
#if foo > bar
93+
// do something
94+
#elseif foo == bar
95+
// do something
96+
#else
97+
// do something
98+
#end
99+
```
100+
101+
Among them, `elseif` and`else` are optional.
102+
103+
**While**
104+
105+
```
106+
#while i < 10
107+
// do something
108+
#end
109+
```
110+
111+
Currently `break` and`continue` are not supported, but they are in TODO list :)
112+
113+
**Foreach**
114+
115+
```
116+
#foreach child in children
117+
// do something
118+
#end
119+
```
120+
121+
`children` is an array, there are some special circumstances, please read on.
122+
123+
#### Variables
124+
125+
Support for simple variable assignment and modify operations, and to meet the needs of AVG, different variables in the archive have different treatment.
126+
127+
**Global Archive Variables**
128+
129+
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+_.
130+
131+
```
132+
#let $gameclear = true;
133+
```
134+
135+
**Single archive variable**
136+
137+
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.
138+
139+
```
140+
#let %girl_favor_num = 1;
141+
```
142+
143+
**Common variables**
144+
145+
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.
146+
147+
```
148+
#let x = 0;
149+
```
150+
151+
**Scopes**
152+
153+
Global archive variables and single archive variables are valid at any location, and are therefore considered global variables.
154+
155+
(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)
156+
157+
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.

README_zh.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# Storyscript
2+
3+
## 简介及设计思想
4+
5+
Storyscript 是一套用于表达 AVG 剧情的脚本系统,是 AVG.js 的官方模块之一。与其他 AVG 引擎的脚本系统类似,它也是依照文本顺序依次执行;语法上,与 BKEngine 的脚本系统颇为类似,但更为简单。
6+
7+
以往的 AVG 脚本,包含了整个游戏全部的程序实现,但相对 Lua、Javasciprt 等成熟的程序语言,其类似标记语言的语法却十分简陋,在这个基础上实现程序逻辑无论对程序员还是普通的爱好者都是一份困扰。
8+
9+
AVG.js 已经将游戏UI、演出效果等强逻辑内容从 AVG 脚本中剥离,剩下的只有简单的指令性代码,这便是 Storyscript 之名的由来。
10+
11+
Storyscript 致力于降低学习难度,让非程序员完全能够掌握其使用方法,使策划、剧本、演出师等人员能够自行完成游戏内容的制作,减少不必要的沟通环节。
12+
13+
有关 AVG.js 及 Storyscript 的详细信息请访问 <https://avgjs.org>
14+
15+
## 安装与使用
16+
17+
Storyscript 已作为初始模块内置于 AVG.js 工程中,若你想要在 AVG.js 中使用它,请参考 AVG.js 相关教程。
18+
19+
下面只介绍在其他工程中的使用方法:
20+
21+
**安装**
22+
23+
```shell
24+
npm install avg-storyscript
25+
```
26+
27+
**使用**
28+
29+
```javasciprt
30+
import Story from 'avg-storyscript';
31+
const story = new StoryScript();
32+
story.load(scriptString);
33+
for (const line of story) {
34+
// do something
35+
}
36+
```
37+
38+
详细请参考 test.js 文件
39+
40+
## 语法简介
41+
42+
Storyscript 脚本系统分为**内容脚本****逻辑脚本**
43+
44+
内容脚本:表示游戏剧情的变化,如打印对话、显示立绘、切换背景图片、播放声音等
45+
46+
逻辑脚本:控制游戏剧情的走向或提供一些方便的程序功能,如变量赋值、条件分支、循环等
47+
48+
### 内容脚本
49+
50+
**基本语法**
51+
52+
```shell
53+
[command flag param="value"]
54+
```
55+
56+
command: 指令名<br>
57+
flag: 标记<br>
58+
param: 参数
59+
60+
例如
61+
62+
```shell
63+
[bgm autoplay loop file="abc.ogg" volume=100]
64+
```
65+
66+
将被解析为
67+
68+
```javasciprt
69+
{
70+
command: 'bgm',
71+
flags: ['autoplay', 'loop'],
72+
params: {
73+
file: "abc.ogg",
74+
volume: 100
75+
}
76+
}
77+
```
78+
79+
### 逻辑脚本
80+
81+
#### 语句
82+
83+
**LET**
84+
85+
```
86+
#let foo = 123 // 标准方式
87+
#bar = 456 // 可省略 let
88+
#let foobar // 可不赋值(值为null),此时 let 不可省略
89+
```
90+
91+
**If**
92+
93+
```
94+
#if foo > bar
95+
// do something
96+
#elseif foo == bar
97+
// do something
98+
#else
99+
// do something
100+
#end
101+
```
102+
103+
其中,`elseif``else` 都是可选的。
104+
105+
**While**
106+
107+
```
108+
#while i < 10
109+
// do something
110+
#end
111+
```
112+
113+
暂不支持 `break``continue`,它们还在 TODO 列表中 : )
114+
115+
**Foreach**
116+
117+
```
118+
#foreach child in children
119+
// do something
120+
#end
121+
```
122+
123+
`children` 是一个数组,这里有一些特殊的情况,请往下阅读。
124+
125+
#### 变量
126+
127+
支持简单的变量赋值和修改操作,同时为适应 AVG 游戏的需求,不同的变量在存档时有不同的处理。
128+
129+
**全局存档变量**
130+
131+
`$` 开头的变量将被视为全局存档变量,意思是说,它一旦被赋值将在任何情况下都能被读取,无论是读取了新的档案还是使用以前的档案。你可以用它来控制CG鉴赏的解锁,或是标明周目数。
132+
133+
```
134+
#let $gameclear = true;
135+
```
136+
137+
**单存档变量**
138+
139+
`%` 开头的变量将被视为单存档变量,意思是说,它将只在某些特定的存档中有效,读取其他档案后将被覆盖。通常用来控制路线或好感度。
140+
141+
```
142+
#let %girl_favor_num = 1;
143+
```
144+
145+
**普通变量**
146+
147+
其他情况下的变量名都是普通变量,在存档中,只有存档点所在的「块」及父「块」中的普通变量将被保存(见下)。普通变量仅用于单文件内使用,请勿用于保存好感度等。
148+
149+
```
150+
#let x = 0;
151+
```
152+
153+
**作用域**
154+
155+
全局存档变量和单存档变量在任何位置都有效,故可视为全局变量(注:全局存档变量和全局变量完全没有联系,前者是说其在存档中的保存方式,后者是说其在游戏脚本中何处可以读取)
156+
157+
对于普通变量,它的作用域是「块」,如一个 IF 分支中的内容或 While 语句中的内容,均为一个「块」。最大的「块」是「文件」,也就是说,即使你不在 IF While 等语句块中声明变量,而是在它们的外面,变量起作用的范围也仅限于当前的脚本文件。

0 commit comments

Comments
 (0)