SRPG Studio

SRPG Studio

评价数不足
Programmer's Guide Scripts and Plugins
由 SapphireSoft 制作
Do you want to extend SRPG Studio using Plugin? This first guide is not difficult, so you can understand without you being a programmer.
   
奖励
收藏
已收藏
取消收藏
Check Script folder
1.Script and Plugin are slightly different in meaning. Script is a system of SRPG Studio. Plugin extends the system to your liking. To understand Plugin, first access the Script folder.


2. The contents of the Script folder are sorted by type. As you can imagine from the name, the attack folder contains code about the battle. In many cases, you need programming knowledge to understand the code, but some files are not so difficult. Let's access the constans folder.


3. The file constants-stringtable.js is easy to understand. Let's open it.



Even without programming knowledge, you will understand some meaning. If you change the text of this file you think that the text of the game will change as well.
Practice to create Plugin
1. You should not directly edit the contents of the Script folder. This is because the Script folder is initialized with updating SRPG Studio. If you extend the game system you have to create a plugin.


2. You will create a file in the Plugin folder. The file name is optional. If you want to disable Plugin, you put $ at the beginning of the file.


3. Basically, you have to write the following code in a text file. You can describe the area of "Write the code" freely.

(function() { // Write the code })();

4. The simplest Plugin is to customize StringTable. You can change the game text with the following code.

(function() { StringTable.UnitType_Ally = 'PARTNER'; })();

5. Let's run the map test.


6. Text changed from "ALLY" to "PARTNER".
Change the formula of battle
When changing text, it is best to use a StringTable object. So, how do you change the formula of battle? The answer is the AbilityCalculator object. This object is defined in singleton-calculator.js.


For example, the getCritical method calculates the critical rate. If you want to change the critical rate, override getCritical.

(function() { AbilityCalculator.getCritical = function(unit, weapon) { return weapon.getCritical(); }; })();

This code does not call getSki. In other words. critical is only activated when equipped with a weapon with a critical rate set.
How to use the console
The console is useful if you want to display debugging characters when running the game. You can display the console if you select "Show Console" in the "Debug" menu.


There are two ways to output characters to the console. The easiest way is to use the "Write to Console" event command.


However, if you are a script developer, basically use root.log.

root.log("test");

The argument is the character you want to output. If you write "test", "test" is output to the console. Practical code is as follows.

(function() { // Save original method before overriding method. // openTurnCycle is called when the player turn starts. var alias1 = PlayerTurn.openTurnCycle; // Override method. PlayerTurn.openTurnCycle = function() { // Call the original method. alias1.call(this); // Clear console. root.resetConsole(); // Output the log. // root.getCurrentSession().getTurnCount() returns the current turn. root.log('Turn ' + root.getCurrentSession().getTurnCount()); }; })();

If you use this plugin, the console will be updated each time you end the turn. You do not have to call root.resetConsole for problems. The results are as follows.

Where can I download Plugin?
Plugin developers may be uploading to Steam Workshop. You can download their Plugin by accessing Steam Workshop. For Steam Workshop it is better to see the guide "Steam Workshop Guide".
3 条留言
Atralane 2020 年 7 月 19 日 下午 7:46 
How would the code look if you wanted to add a new unit stat entirely?

For the example above (reworking how critical hits are determined), say you wanted a dedicated stat called "CRI" instead of drawing from the unit's SKI stat.
SapphireSoft  [作者] 2018 年 10 月 9 日 下午 8:29 
I added console information to this guide.
SuccubellaGames 2018 年 10 月 8 日 上午 12:49 
How can i open Console Window for debug? And how can i print something to Debug Window?