Site Logo


Sparen's Danmakufu ph3 Tutorials Lesson 21 - Customizing Replay Save Files

The video for this lesson is TresserT's Reisen. A true mind trip. Enjoy, and please Koishi appropriately.

Part 1: What will be Covered in this Lesson?

In this lesson, I will discuss Replay Save scripts, which are called after the user decides to save a replay in an End Scene.

You must read the previous lesson - Lesson 20 - before starting with this tutorial, as this lesson is its logical continuation. We will assume that you are familiar with menus, manipulating text objects, and other things that have already been covered.

Part 2: What are Replay Save Scripts?

We've discussed many types of scripts already - Pause, End Scene, and so on. Reply Save screens are another integral feature that should be implemented by all scripters. Especially since the default one looks rather horrible and doesn't let you cancel out of a replay once you accidentally hit the 'Save Replay' button in the End Scene.

We set a custom Replay Save Scene in our System file with SetReplaySaveSceneScriptPath(), the same way as with Pause and End Scenes. This will replace the default.

The very first thing you should do is change the font. The next thing to do is change the Japanese in the strTextIn and strTextView variables to English or your language of choice (終 translates to 'end', 終了 translates to 'finished').

One thing to note, however, is the presence of brackets [ and ] in strTextIn and strTextView. Unfortunately, I highly recommend removing them and replacing them with spaces " ", because they are highly problematic (Danmakufu recognizes them as special characters, etc.). Simply remove them and add two empty spaces before your new 'End'.

Alternatively, [osb] and [csb] seem to provide the [ and ] characters, respectively if used in a string, similarly to [r]. (Thanks to Uruwi/Fluffy8x)

The reason why they work OK in the default replay save script is because strTextIn is used only for array length operations and indexing (it contains the actual characters input into your replay name), and strTextView is used exclusively for what you see displayed as the options, except that it uses a different character set to prevent bad things from happening.

Now, let's take a look at the Replay Save Script's structure, as well as how it works.

Part 3: What is inside a Replay Save Script?

The default Replay Save Scene contains a number of functions and variables to be aware of. To start, the final constants MENU_INDEX_SELECTION and MENU_NAME_ENTRY, which are used to tell the script which menu you are on (selecting a replay slot to save the replay in, or in the name entry menu).

The first of these menus is controlled via TReplayIndexSelection, while the latter is controlled by TNameEntry.

TReplayIndexSelection, as you may have guessed, handles selecting which replay slot to save your replay in. It functions as a menu that displays various information about a replay. If you look at the individual menu items, created by TMenuItem, the text showed has the replay number, as well as name, date/time, and the score of the replay. These are all saved in replays by default.

Note the 'by default'. If you decide to make a full game or a rather complex stage/boss with various other features (will require a package), you can choose to display other things as well, using Replay Comments and Common Data.

Anyways, if no replay exists at a given slot, "No Data" is appended. And additionally, note that hitting right/left will allow you to access another page of replays! No, you are not limited to 10 replays per script. You can have significantly more by default in Danmakufu. The hard number is REPLAY_INDEX_DIGIT_MAX - REPLAY_INDEX_DIGIT_MIN + 1, which is equal to 99.

TNameEntry is where you input your name. There are two arrays for the characters used, and using the strTextIn array, characters can be viewed and accessed, selected, and then added to your name. Here you can set the maximum name length (defaults to 8) and default name (defaults to "No Name"), and if you implement CommonData to save a player's input name, you can start out with the previously input name (you will have to implement this yourself).

Beyond these two tasks, there really isn't anything else noteworthy about a Replay Save Script. Just follow standard procedure when dealing with scripts if you try to use a custom one.

Part 4: How do I use Custom Replay Save Scripts?

As with other scripts, you can choose to use a custom Replay Save Script. As usual, put them in a directory within your script, and link to it from the System File using a relative path. For example:

    SetPauseScriptPath(GetCurrentScriptDirectory() ~ "./Pause.dnh");
    SetEndSceneScriptPath(GetCurrentScriptDirectory() ~ "./EndScene.dnh");
    SetReplaySaveSceneScriptPath(GetCurrentScriptDirectory() ~ "./ReplaySaveScene.dnh");

Some things you will probably want to do are change the font used, allow for the user to cancel out of TNameEntry, etc.

If you decide to handle Replay Comments, however, things get a little hairy. In TNameEntry, you'll have to, before calling SaveReplay(), SetReplayInfo(REPLAY_COMMENT, <your stuff here>). If you have multiple fields, I suggest delimiting using "/", though this can and will make storing paths difficult. We will likely discuss this in a later tutorial.

Quiz: Replay Save Scripts

1) What is the number of replays that can be stored for a given script?

A. 10
B. 99
C. 50

2) How do you escape the [ character in Danmakufu?

A. \[
B. [osb]
C. [csb]

Summary

  • Replay Save Scenes run when the option to save a replay is selected from an End Scene
  • Replay Save Scenes have two parts - choosing a replay slot, and name input + saving the replay
  • Replay Save Scenes allow for customizing what information (CommonData, Replay Comments) gets saved to a replay

Sources and External Resources

N/A