Introduction

ONScripter (O-N-Scripter) is a program that interprets a script written for NScripter (Details) on its ownway.

Reports on new platforms, bugs, requests and patches are welcome at any time. Please visit [Bug Tracking System] (in Japanese). Before you submit a report, please uncheck the box at the middle of the last section. You can also send a report directly to me via e-mail. The e-mail address is found at the bottom of this page.

Source package

Binary package (Android and Zaurus packages are tested by ME)

PlatformDistributor
Android (1.6 or later)ONScripter on Android
Zaurus (SL-C700, etc.)SDL on Zaurus page
LinuxDebian Official Unstable (Sid)
Debian Official Testing (Wheezy)
Debian Official Stable (Squeeze)
Debian Unofficial (Etch, Sarge, Woody, Potato)
Uncle Mion's ONScripter Corner (ONScripter-EN)
MacOSXONScripter Launcher and Binary for Mac OS X
Uncle Mion's ONScripter Corner (ONScripter-EN)
WindowsKirisame no furu hini
ONScripter/SDL for Win32 (MinGW)
Uncle Mion's ONScripter Corner (ONScripter-EN)
PSPKirisame no furu hini
iPhone, iPod touchiPodOns
NetWalkerQt beginner's memo
Brain (WindowsCE 6.0)ONScripter for Brain
NetBSD, DragonFly BSDpkgsrc
pkgsrc-wip-jp memo (pkgsrc-wip/wip-jp/onscripter)
OS2/WarpNekomimi na programming kakuto nikki (packages)
Playstation3PS3 Linux de zisaku soft wo tanoshimo
WiiONScripter WiiBrew
FreeBSDPrivate Ports for FreeBSD
DreamcastONScripter for Dreamcast
Let me know if you have others

ONScripter-EN is an extended version of ONScripter developed by Uncle Mion san that handles English scripts in a better way. It supports more NScripter commands and it can handle ordinary Japanese scripts as well.

Features

  1. It can load/save a save file compatible with the latest NScripter (2011/12/15). Please see How to share save files on different platforms for details.
  2. Mouse operations can be performed by keyboard short-cuts.
  3. Music files (MP3, Ogg) can be played instead of CD Audio tracks.
  4. It has been reported that ONScripter runs on Windows, Linux, MacOS X, MacOS 9, Android(1.6 or later), iPhone, PSP, Zaurus (SL-5500,SL-A300,SL-B500,SL-C700), FreeBSD, Solaris(on SPARC), Tru64 UNIX, OS/2Warp, iPod, PocketPC, Playstation3, Wii, GP2X, NetWalker and Dreamcast. For other platforms where Requirements are satisfied, I'm sure it can be complied and run.
  5. Not all the commands and specifications of NScripter are supported. If you find something wrong, please send a report to me.

How to run

Requirements

The required programming languages and libraries are listed below. The version number in the list are those of my environment, but you do not have to use the same version.

Required

Recommended

  • ogg-1.2.0, vorbis-1.3.1 (The Ogg Vorbis CODEC Project)
    It is required if you want to play Ogg vorbis music. It is enabled by default in Makefile.Linux and Makefile.ArmLinux included in the source package. Tremor vorbis can be used instead that decodes music using integer arithmetics only.

Not required

  • mad-0.15.1b (MAD: Mpeg Audio Decoder)
    It is a MP3 decoding library using integer arithmetics only. If you want to play MP3 music on Android or Zaurus, it must be necessary. To use MAD, SDL_mixer library must be built with MAD enabled instead of SMPEG.
  • avifile-0.7.48 (avifile)
    If you want to play AVI files using avi command, it is required. It is enabled when USE_AVIFILE is defined and AVIWrapper.o is linked.

ONScripter is tested on Windows, Linux, Android (HTC Desire (2.3)) before it is released.

Compilation

Unpack ONScripter package in an appropriate location. Then, type " make -f Makefile.Linux " on Linux, or type " nmake -f Makefile.Win " on Windows. Please note that the path to the header files and libraries for bzip2, SDL, SMPEG, etc., should be modified in Makefile depending on your environment.

Run

[Required] Copy the necessary archives of a game in the same location. Usually, you need a script file (0.txt or nscript.dat) and an archive file (arc.sar or arc.nsa). If there are other archive files such as arc1.nsa to arc9.nsa, you need to copy them. In some games, images and sounds are placed outside archive files. In that case, you also need to copy them to a directory of the same name. The simplest way is to copy all the files under the game directory.

[Required] Following Displaying Kanji using TrueType font, place a Japanese TrueType font file named "default.ttf"

[Optional] If you want to use sound files instead of CD audio tracks, follow Using sound files instead of CD audio and place sound files.

[Required] Run ONScripter. It reads from nscript.dat and archives in the same directory, and the game will start. Since ONScripter outputs save files and status files in the same directory, please be sure that the directory has write permission.

ToDo

  1. (High) Lua support
  2. (Middle) Apply "windoweffect" when "windowerase" is performed on mouse right click
  3. (Middle) Store the image obtained by "bgcopy" when storing save files
  4. (Middle) Deal with the case where shadow of characters is overlapped to other characters
  5. (Low) "english" command support to handle an English script
  6. (Low) Verify "existspbtn" which is implemented as "spbtn"
  7. (Low) Clean up of code
だめーエンジン開発・移植日記(仮)
Akizuki Katane san's diary who ported ONScripter to various platforms.
技術屋きさらの箱庭
Kisara san's diary who maintained the bug tracking system for ONScripter in the past.

Miscellaneous

Keyboard shortcut

All operations including mouse operations can be performed by keyboard short-cuts, though the shortcut keys defined in the script have priority.

Key Description
space Same as mouse left click, except it behaves as if the area outside the button is clicked even if the mouse cursor is just on a button.
return Same as mouse left click.
escape Same as mouse right click.
p,k,↑ Move the mouse cursor onto the previous choice (button) at decision branch (button selection).
n,j,↓ Move the mouse cursor onto the next choice (button) at decision branch (button selection).
s Skip sentences to the next decision branch.
o Switch to one page display mode.
h,← Same as mouse wheel up.
l,→ Same as mouse wheel down.
f Switch between full screen mode and windowed mode.
a Enter into the auto read mode if automode or mode_ext is defined.
z Enter into the volume and variables modification mode if "--edit" is specified in the command line options.
1, 2, 3 Change the speed of drawing characters.
Shift + q Quit. (end command is issued)

Command line options

Options Description
-h,--help Show the help messages and exit.
-v,--version Show the version number and exit.
--cdaudio Use CD audio if available. Even if it is not available, sound files are not used instead. [default: use Music files instead of CD audio]
--cdnumber cd_number Specify CD-ROM drive number to use if there are many. [default: 0]
-f,--font file Specify a TTF font file. [default: default.ttf in the current directory]
--registry file Specify a registry file.
--dll file Specify a dll file.
-r,--root path Specify the directory where the script and archives are placed. [default: current directory]
--fullscreen Start in full screen mode.
--window Start in windowed mode.
--force-button-shortcut Ignore "getenter" and "useescspc" commands. In other words, "esc", "space" and "return" keys are forced to behave as a mouse click.
--enable-wheeldown-advance Advance the text on mouse wheel down when it waits for a click at the end of a sentence. If the behavior of waiting for a click is customized by "textgosub", this option has no effect.
--disable-rescale Do not rescale the images in an archive to fit in the screen when compiled with "-DPDA". ONScripter suppresses the internal conversion of images to lower resolution.
--edit Enable online modification of the volume and variables when "z" is pressed.

How to share save files on different platforms

You can share save files among different platforms such as desktop PC (Windows, Linux), smartphone (Android), etc. To do this, you need to setup the archives of a game on all platforms and move all updated files generated by ONScripter (or NScripter) from one platform to another.

NScripter or ONScripter generates/updates following files. Some files may not be generated and be missing dependent on games.

Output files Description
archive_path/gloval.savglobal variables
archive_path/envdataenvironmental variables
archive_path/kidoku.datalready-read texts
archive_path/NScrflog.datalready-read files
archive_path/NScrllog.datalready-read labels in a script
archive_path/save*.datsave files (those generated by ONScripter can not be read from NScripter, but those generated by NScripter can be read from ONScripter)
archive_path/sav/save*.datsave files compatible with NScripter (not warranted) generated by ONScripter
archive_path/other imagesScreenshots may be saved as images. Directory and name of images are dependent on games.

The format of a save file may change when a new version of NScripter (or ONScripter) is released. So, ONScripter generates a save file with the version number of the save file in the beginning. Save files without version number are also generated under "sav" directory if it exists and they are compatible with the save files generated by the latest NScripter. Note that the version number of save files is different from that of ONScripter.

ONScripter can load both save files with version number and those in the latest format without version number.

Move from ONScripter to ONScripter

Simply copy all the above mentioned modified files including save*.dat.
ONScripter_dir/* → ONScripter_dir/*

Move from NScripter to ONScripter

Simply copy all the above mentioned modified files including save*.dat.
NScripter_dir/* → ONScripter_dir/*

Move from ONScripter to NScripter

Copy all the above mentioned modified files except for save*.dat.
ONScripter_dir/* -> NScripter_dir/*
Copy save files under "sav" directory
ONScripter_dir/sav/save*.dat -> NScripter_dir/save*.dat

Notice

  • Save files generated by nscr.exe released in 2011/12/15 are supported as the latest format. Save files generated by the older version of NScripter are not supported.
  • Compatibility is not guaranteed, though there has been no problem as far as I know.
  • Because ONScripter cannot load save files generated by the older version of NScripter, please use the above mentioned latest NScripter from the beginning when you use both ONScripter and NScripter.
  • To use both ONScripter and NScripter, please make "sav" directory in advance.

Reading from the registry

getreg obtains the specified data from the registry of Windows. ONScripter realizes this function by reading from a text file named "registry.txt" where the data is written.

The format of "registry.txt" is as follows. It is case sensitive. Please do not insert extra spaces. If you use Kanji characters, please be sure that it is written in Shift JIS.

[the second argument of getreg (excluding quotation marks around)]
the third argument of getreg = 比較対象文字列(前後の""は必要です)

An example of "registry.txt"

[software\StudioOGA\ONScripter]
"INSTALL"="FULL"

[software\StudioOGA\のまど]
"Download log file"="c:\nomad_down.log"
"Upload log file"="c:\nomad_up.log"

ONScripter 起動時に --registry オプションを指定することで、 registry.txt を一カ所にまとめておくことができます。--registry を指定し ない場合は、現在のディレクトリの registry.txt を読みにいきます。

Loading DLL

exec_dll コマンドは Windows 上で実行可能な DLL (Dynamic Link Library) を実行します。ONScripter では、テキストファイル dll.txt に DLL 名とその戻値の対応を記述し、これを読み込むことでこの機能を実現しま す。従って、実際に DLL が実行されるわけではなく、また戻値は固定になり ます。

dll.txt の書式は次の通りです。大文字・小文字は区別されます。また余 計なスペース等を入れないようにして下さい。漢字が使われている場合、文字 コードが Shift JIS になることに注意してください。

[dll 名]
str = "文字列(getret で受け取ることのできる文字列戻値))" 
ret = 整数(getret で受け取ることのできる数字戻値)

dll.txt の例

[test.dll]
str = "山田/太郎/やまだ/たろう"
ret = 1

[test2.dll]
str = "StudioOGA"
ret = 2

ONScripter 起動時に --dll オプションを指定することで、dll.txt を一 カ所にまとめておくことができます。--dll を指定しない場合は、現在のディ レクトリの dll.txt を読みにいきます。

Online modification of volume and variables

これは暫定的なおまけ機能であり、今後変更されたり無くなったりする可能性があります。

ONScripter 起動時に --edit オプションを指定することで有効になります。

任意のキー入力待ち状態時に z キーを押すことで、編集モードに入ります。この時、title bar に

[EDIT MODE]  MP3 vol (m)  SE vol (s)  Voice vol (v)  Numeric variable (n)

と表示されるはずです。この状態で、m, s, v, n のい ずれかのキーを押すことで、それぞれの値を変更するサブモードに入ります。 また、Esc キーを押すことによってモードを抜けることができます。

数字変数の場合は、値変更の前にどの変数を変更するのかを選択します。

値変更サブモードでは、0 から 9 までの数字と -, BackSpace, Esc, リター ンキーが使えます。- キーは、対象が数字変数でかつ数字が0の時のみ有効に なります。既に数字が入力されている場合には、一旦 BackSpace で数字を全 部消してから - キーを押してください。

Displaying Kanji characters using TrueType font

Japanese TrueType font is required to display Kanji characters. For example, msgothic.ttc under c:\Windows\Fonts in Windows 7, or freely available TrueType fonts shown below can be used.

M+ and IPA compositional font
Re-distributable fonts based on M+ font and IPA font. Among them, I recommend Migu-2M-bold.ttf that is bold, beautiful and easy-to-read.
IPA font
Re-distributable Gothic and Mincho font.
Mika-chan font
Handwritten font.

Because SDL_ttf renders Kanji characters badly when TTF_STYLE_BOLD is enabled, ONScripter just ignores "bold" settings. If you use a small device like smartphones, it is better to use a bold TrueType font such as Migu-2M-bold.ttf mentioned above and HG Gothic E (HGRGE.TTC).

TrueType font file should be renamed to default.ttf and be placed in the same directory where a script file is placed before launching ONScripter.

Using sound files instead of CD audio

Create a directory named "cd" in the directory where scripts and archives are placed, and put sound files as follows.
cd/track01.xxx
cd/track02.xxx
cd/track03.xxx
...
cd/track14.xxx
...
MP3, OGG and WAV format are supported. Please change the above "xxx" according to the format of the sound files.

The behavior of a command to play the first CD audio track, i.e. play "*1", is changed to play "track01.mp3". This is the default behavior unless "--cdaudio" option is specified. In case of missing sound files, "play" command is just ignored.

Playing MIDI

MIDI is played by SDL_mixer. At that time, a temporary file "tmp.mus" is created because SDL_mixer can only load MIDI data from a file.

Unix系(動作確認は Linux と Zaurus)でソフトウェア音源で演奏する場合(デフォルト)。
SDL_mixer に取り込まれている timidity を使用してソフトウェア音源で演奏します。この場合、MIDIの音色データtimidity.tar.gzをダウンロードして /usr/local/lib/ 以下に展開してください。
Windows の場合。
timidity.tar.gzをダウンロードして c:\ 以下に展開してください。 これをしなくても MIDI が鳴ったと思っていたのですが、こうしないと落ちるようです。
Mac OS X の場合。
ONScripter for Mac OS X(かつらさん)のバイナリに添付されている外部プログラムを利用して演奏が可能です。(当方未確認)
Unix系(動作確認は Linux)で外部 MIDI 音源を利用して演奏する場合。
playmidi 等の外部音源を使用できる MIDI player をインストールし、環境変数 MUSIC_CMD を設定してください。(例 MUSIC_CMD=/usr/bin/playmidi)
当方では、シリアル接続で外部音源を繋ぎ、MUSIC_CMD に '/usr/bin/midiplay -q -o /dev/ttyS0' を設定して動作確認をしています。
playmidiは、カーネルで認識される MIDI ポートに対してしか演奏できませんが、midiplayはシリアルに直接出せます。
シリアルポートをMIDIポートにする patchを使えば、playmidi でもシリアル接続音源を使えそうですが、未確認です。

Compression of archives

昔のZaurus (320x240) や PSP (360x270) などは画面の大きさが小さいた め、あらかじめアーカイブ中の画像ファイルを画面サイズに合わせて小さくし ておくことにより、アーカイブサイズを縮小し、少ない記憶デバイスを有効活 用することができます。なお、SPB 圧縮の画像は、後述の -e オプションを指 定しない場合 BMP 形式として格納されます。

使い方

sarconv                    変換元画面幅 変換先画面幅 変換元SARファイル名 変換先SARファイル名 
nsaconv [-e] [-ns2] [-ns3] 変換元画面幅 変換先画面幅 変換元NSAファイル名 変換先NSAファイル名 

変換元画面幅は 640 か 800 のいずれかを指定してください。

変換先画面幅は 176(iPod), 320(QVGA), 360(PSP), 384(PSP), 640(VGA) などが指定できます。

使用例

画面のサイズが 640x480 で拡張子が sar のアーカイブを 320x240 にする 場合

> sarconv 640 320 arc.sar zaurus_dir/arc.sar
...

画面のサイズが 800x600 で拡張子が nsa のアーカイブ(バージョン1) を 320x240 にする場合

> nsaconv [-e] 800 320 arc.nsa zaurus_dir/arc.nsa
> nsaconv [-e] 800 320 arc1.nsa zaurus_dir/arc1.nsa
...

画面のサイズが 800x600 で拡張子が nsa のアーカイブ(バージョン2) を 640x480 にする場合

> nsaconv [-e] -ns2 800 640 arc.nsa zaurus_dir/arc.nsa
> nsaconv [-e] -ns2 800 640 arc1.nsa zaurus_dir/arc1.nsa
...

NSA アーカイブのバージョン1と2と3の区別は手動です。スクリプトで ns2 コマンドが使われていればバージョン2、ns3 コマンドが使われていればバージョン3です。スクリプトが確認できない場合は、まず -ns2 を付けずに試し、うまくいかなかったら -ns2 もしくは -ns3 を付けて試してください。

-e オプションを付けると、wav と bmp ファイルを nbz 圧縮します。これを行うと、NSA アーカイブの圧縮の種類を示すフラグに ONScripter 独自の値を設定します。この独自拡張については、本家が将来アーカイブの仕様を拡張したときにバッティングする可能性がありますが、その時はそれを回避するようにコンバータを修正し、再コンバートすることで解決できます。その場合でも、save file 等には一切影響がありませんので、Zaurus で使用される方はこのオプションを付けてコンバートすることをお勧めします。wav を bzip2 で圧縮するので、wav を多用するゲームではかなりアーカイブが小さくなります。デメリットとしては、bzip2 の復号を行うため若干遅くなりますが、気が付かない程度です。

-j オプションを付けると、ファイル名はそのままで bmp ファイルを jpeg に変換します。ただし、パレットカラーの bmp ファイルは bmp のまま変換されます。

-q オプションで jpeg で圧縮する際の品質(0〜100)を指定することができます。小さい値を指定すると、品質が悪くなりますが、圧縮後のサイズが小さくなります。デフォルトとは75です。

サイズを小さくしたアーカイブを使うときは、onscripter に --disable-rescale オプションを指定してください。
なお、Linux 等でも、-DPDA をつけてコンパイルすることにより、320x240 画 面でゲームを実行することができます。

Problem of chattering MP3 music on Windows platform

Windows でコンパイル済の SMPEG のバイナリを持ってくると、MP3 によっては音がぶつぶつとぎれて演奏されます。これは、SMPEG を MSVC でコンパイルする時の最適化の問題で、下記の通りに MSVC の global optimization を一部抑制する指定をし、自分でコンパイルすることで解決できます。

修正するファイル: audio/mpeglayer3.cpp
関数 layer3reorderandantialias の前後に、下のように #pragma 指定を追加 する。

#pragma optimize( "g", off )
void MPEGaudio::layer3reorderandantialias(int ch,int gr,
                                          REAL  in[SBLIMIT][SSLIMIT],
                                          REAL out[SBLIMIT][SSLIMIT]){
  ......
}
#pragma optimize( "g", on )

How to write an English novel

これは Chend さん(chendo[at]gmail.com)からの要望に基づく ONScripter 独自の拡張です。これまで、仕様の提案やパッチなど多くの協力をしていただ きました。

コンパイル時に ENABLE_1BYTE_CHAR を定義することで、`(back quote) 以 降行末もしくは別の ` までを、1byte 文字で記述されたテキスト文とみなし て表示するようにします。この間では半角スペースが表示として有効になりま すが、テキスト内の変数表示は無効になり、また色・時間指定も開始位置によっ ては無効になります。テキスト途中で色を変える場合は、/ で行を分けるなど してください。ただし、クリック待ち(@)改ページ待ち(\)直後の強制クリック 文字を無視(_)は有効です。

将来本家で ` に何か機能を割り振った場合には、削除もしくは別の文字に 変更される可能性があります。現状のように ENABLE_1BYTE_CHAR の指定の有 無で使い分けられるようにするかもしれませんが、保証の限りではありません。

また、コンパイル時に ENABLE_1BYTE_CHAR と合わせて FORCE_1BYTE_CHAR を指定すると、全ての表示を半角にすることが可能になります。具体的には、 上記に加えて、右クリックメニューの表示が英語になり、また数字変数の表示 が半角になります。

以下にスクリプト例を書きます。

*define 
clickstr `.?"`, 2 
savename `Save the scene`, `Load the scene`, "Memory "
rmenu `Save to file`,save,`Load from file`,load
game
 
*start
`Hi, this was test.
`Hi, this is test again.
`_"He said so."
`_"She said so."
`Does it work??
br
selgosub `Say "Turn to the right."`, *right, 
`Say "Turn to the left."`, *left ,
"`Do nothing.", *nothing
end 

*right
`You turned to the right.
return

*left
`You turned to the left.
return

*nothing
`You didn't do anything.
return

Memo

event_mode

The values in the table below are used exclusively.

ValueDescriptionExample
IDLE_EVENT_MODENot clickable wait.wait
WAIT_BUTTON_MODEWait for selection using ButtonLink (image).btnwait, select, right-click menu
WAIT_INPUT_MODE Wait for clickable user input.delay, click, @, \, text rendering, screen effect

The values in the table below are used conjunction with the values in the table above.

ValueDescriptionExample
WAIT_TIMER_MODEWait for the specified time, animation is processed while waitingMost cases except for screen efffect and text rendering.
WAIT_VOICE_MODEWait until voice is finihsed.automode, btntime2 only
WAIT_TEXT_MODEWait at the end of text.@, \, select
WAIT_RCLICK_MODEWait for right click.lrclick

Order of rendering layers

In the table below, the lower layer is hidden by the upper layer. The initial value of "humanz" is 499.

Text is always rendered at the top when appeared.

Normal"windowback" is used
Button
Cursor
Text window and textNumeric label
Numeric labelBar
BarSprite (from humanz to 0)
** monochrome and negation effect **Text window and text
Sprite2 (from 255 to 0)Sprite2 (from 255 to 0)
Sprite (from humanz to 0)** monochrome and negation effect **
Tachi-e (standing characters)
Sprite (from 999 to humanz+1)
Background