Introduction

ONScripter (O-N-Scripter) is a program that interprets a script written for NScripter (Details) in its own way.

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

Source package

Latest release onscripter-20170814.tar.gz
Previous release onscripter-20161102.tar.gz

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

PlatformDistributor
Android (1.6 and later)ONScripter in Google Play
ONScripter on Android
Zaurus (SL-C700, etc.)SDL on Zaurus page
LinuxDebian Official Unstable (Sid)
Debian Official Testing (Jessie)
Debian Official Stable (Wheezy)
Debian Unofficial (Etch, Sarge, Woody, Potato)
Uncle Mion's ONScripter Corner (ONScripter-EN)
MacOSXHomebrew
ONScripter Launcher and Binary for Mac OS X
Uncle Mion's ONScripter Corner (ONScripter-EN)
WindowsKirisame no furu hini
Uncle Mion's ONScripter Corner (ONScripter-EN)
PNaClIdleTime (Playable on Google Chrome)
PSPonscripter_signed (signed, can work on the original FW)
PandoraPandora Handheld PC / ONScripter
iPhone, iPod touchiPodOns
NetWalkerQt beginner's memo
Brain (WindowsCE 6.0)ONScripter for Brain
NetBSDpkgsrc
OS2/Warppackages
Playstation3PS3 Linux de zisaku soft wo tanoshimo
WiiONScripter WiiBrew
FreeBSDOfficial FreeBSD package
Private 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 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, iPad, 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 anything 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 and you do not have to use the same version.

Required

Recommended

  • SMPEG-0.4.5
    SMPEG is required to play MPEG1 movie files. Either SMPEG or MAD is required to play MP3 music files.
  • ogg-1.2.0, vorbis-1.3.1 (The Ogg Vorbis CODEC Project)
    Ogg Vorbis is required to play Ogg Vorbis music files. 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.

Optional

  • mad-0.15.1b (MAD: Mpeg Audio Decoder)
    MAD is a MP3 decoding library using integer arithmetics only. If you want to play MP3 music files 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)
    Avifile is necessary if you want to play AVI files with avi command. It is enabled when USE_AVIFILE is defined and AVIWrapper.o is linked.

ONScripter is tested on Linux (Debian Jessie), Android (Sony (7.0)), iOS (iPad2), (sometimes Windows) before it is released.

Compilation

Unpack ONScripter package in an appropriate location. Type " make -f Makefile.Linux " on Linux, or type " nmake -f Makefile.Win " on Windows. 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 to the same location. Usually, you need a script file (0.txt or nscript.dat) and archive files (arc.sar or *.nsa or *.ns2). If there are multiple archive files such as arc1.nsa to arc9.nsa, you need to copy them as well. In some games, images and sounds are placed outside archive files. In that case, you also need to copy them all. The easiest way is to copy the directory including sub-directories where a game is installed.

[Required] Following Displaying Kanji using TrueType font, put a Japanese TrueType font file renamed as "default.ttf".

[Optional] If you want to use sound files instead of CD audio tracks, follow Using sound files instead of CD audio and put 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 is writable.

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 higher 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 information 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 Choose the CD-ROM drive number to use if there are many. [default: 0]
-f,--font file Set a TTF font file. [default: default.ttf in the current directory]
--registry file Set a registry file.
--dll file Set a dll file.
-r,--root path Set 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 the archives to fit in the screen when compiled with PDA_WIDTH or PDA_AUTOSIZE defined. Along with the compressed archives as mentioned in Compression of archives, ONScripter will run faster by avoiding the need for resizing. Note that image files outside the archives are resized as before.
--render-font-outline Render the outline of a text in black (or white if the color of the text is dark) using the outline rendering function supported in SDL_ttf since 2.0.10. Text will be clearly shown.
--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, MacOSX), smartphone (Android, iPhone), etc. To do this, you need to prepare game data on all platforms and move all output files generated from ONScripter (or NScripter) from one platform to another.

NScripter or ONScripter generates/updates following files. Some may not be generated depending 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 newer version of NScripter (or ONScripter) is released. So, ONScripter generates a save file having extra information about the version number of a save file in the header. A save file without a version number is also generated under "sav" directory if it exists and it is compatible with a save file generated from the latest NScripter. Note that the version number of a save file is different from the version number (e.g. 20120225) of ONScripter.

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

From ONScripter to ONScripter

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

From NScripter to ONScripter

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

From ONScripter to NScripter

Copy all the above mentioned modified files excluding 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 from the latest NScripter (nscr.exe released in 2011/12/15) are supported. ONScripter doesn't load save files generated from older version of NScripter.
  • Compatibility between the latest NScripter and ONScripter is not guaranteed, but there has been no problem as far as I know.
  • Use the above mentioned latest NScripter from the beginning if you use both ONScripter and NScripter. In that case, be sure to make "sav" directory in advance.

Reading from the registry

getreg command reads data from the registry of Windows. ONScripter emulates this command by reading from registry.txt (text file) that describes the data.

The format of registry.txt is as follows. Letters are case sensitive. Be careful not to have extra spaces. If you use Kanji characters, use Shift JIS code set.

[the second argument of getreg command (excluding quotation marks around)]
the third argument of getreg command = string to be compared (including quotation marks around)

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"

You can share a registry file among games if ONScripter is launched with --registry option. Without --registry option, it looks for registry.txt in the current directory.

Loading DLL

exec_dll command executes DLL (Dynamic Link Library) that is built to run on Windows. ONScripter emulates this command by reading from dll.txt (text file) that describes the relationship between the name of a DLL and its return value. So, DLL is not executed and the return value is fixed.

The format of dll.txt is as follows. Letters are case sensitive. Be careful not to have extra spaces. If you use Kanji characters, use Shift JIS code set.

[Name of DLL]
str = "string" (string value received in getret command)
ret = integer (integer value received in getret command)

Example of dll.txt

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

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

You can share a dll file among games if ONScripter is launched with --dll option. Without --dll option, it looks for dll.txt in the current directory.

Online modification of volume and variables

This is a temporary function and might be modified or removed in the future.

It is enabled by setting '--edit' option when launching ONScripter.

If you press z key when waiting for key-in, you will enter edit mode and the title bar becomes as follows.

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

If you further press any of m, s, v, n key, you will enter sub edit mode where you can change corresponding variables. You can escape from edit mode by pressing ESC key.

If you press 'n' key, you have to choose a variable first and then change its value.

You can use '0' to '9', '-', BackSpace, Esc, Return keys when you change numeric variables. '-' key is accepted when you are editting a numeric variable and the value is 0. If the value is other than 0, you need to clear the value by pressing BackSpace key and then press '-' key.

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. When playing MIDI, a temporary file "tmp.mus" is created because SDL_mixer can only load MIDI data from a file.

Playing MIDI using a software sound module on Unix (tested on Linux and Zaurus) (default)
Playing MIDI using timidity, a software sound module incorporated in SDL_mixer. In this case, you need to download a set of sound patches timidity.tar.gz and expand them under, for example, /usr/local/lib/.
Playing MIDI on Windows
You need to download a set of sound patches timidity.tar.gz and expand them under c:\.
Playing MIDI using a hardware sound module on Unix (tested on Linux)
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

The screen size of Linux Zaurus (320x240) or PSP (360x270) is smaller than the size expected in the script. By resizing the images in the archives beforehand, you can keep the size of the archives small and use the storage efficiently. Images with SPB format are stored as BMP format unless -e option is specified.

Usage

sarconv                    src_screen_width dst_screen_width src_SAR_filename dst_SAR_filename
nsaconv [-e] [-ns2] [-ns3] src_screen_width dst_screen_width src_NSA_filename dst_NSA_filename

src_screen_width can be 640 or 800.

dst_screen_width can be any width such as 176(iPod), 320(QVGA), 360(PSP), 384(PSP), 640(VGA).

Examples

Converting a SAR archive from 640x480 to 320x240.

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

Converting a NSA archive from 800x600 to 320x240.

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

Converting a NSA (ns2) archive from 800x600 to 640x480.

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

You have to manually distinguish the version (1 or 2 or 3) of NSA archive. The use of ns2 command in the script indicates version 2, while the use of ns3 command indicates version 3. If you cannot check the script, please try without -ns2 first. If it fails, please try with -ns2 or -ns3.

The option -e compresses wav and bmp files in nbz format. This sets a special value, incompatible with NScripter, in the flag that represents compression type. This extension may conflict with an extension by NScripter in the future. その時はそれを回避するようにコンバータを修正し、再コンバートすることで解決できます。その場合でも、save file 等には一切影響がありませんので、Zaurus で使用される方はこのオプションを付けてコンバートすることをお勧めします。wav を bzip2 で圧縮するので、wav を多用するゲームではかなりアーカイブが小さくなります。デメリットとしては、bzip2 の復号を行うため若干遅くなりますが、気が付かない程度です。

The option -j converts bmp files to jpeg files while keeping the filenames unchanged. Except, bmp files using palette color are not converted.

The option -q sets the quality of jpeg compression ranging from 0 to 100. Small value indicates low quality but small file size. The default value is 75.

The option --disable-rescale is required when a rescaled archive is used.

You can enjoy a game in 320x240 resolution on Linux if ONScripter is compiled with -DPDA.

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

This feature is an extension to NScripter proposed by Chend (chendo[at]gmail.com). He has contributed to ONScripter greatly by proposing specifications and sending patches.

コンパイル時に 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