Skip to content
Damnae edited this page Nov 12, 2020 · 7 revisions

Log

Saves a message to a dialog of the effect. Logs are typically used to keep better track of your variables and specific method behavior, such as debugging. It behaves like println in other programming languages.

Log(string message)

You can find the content of the log by clicking the leaf icon next to the script's name in the effect list (It will be replaced by a bug icon if the script failed to execute).

Assert

An assertion is a statement that expects a condition – if the condition is false, then the effect will fail execution and throw an exception at the offending line. You can also add a custom message to provide more details for the failure.

Assert(bool condition)
Assert(bool condition, string message)

Random

Generates a random number from minValue to maxValue exclusive. Variations such as minimum, maximum, or generating double values are also possible. If only the maximum is specified, then the minimum will automatically be 0. To generate different sets of random numbers, change the random seed configurable for the effect.

Random(int minValue, int maxValue)
Random(int maxValue)
Random(float minValue, float maxValue)
Random(float maxValue)
Random(double minValue, double maxValue)
Random(double maxValue)

File Loading

storybrew also supports loading image files, called Bitmaps, or arbitrary files. These methods are instrumental in that.

Loading a Bitmap

storybrew can load up an image file and convert it to the Bitmap class as specified in System.Drawing. For more details about the class and what can be manipulated, refer to MSDN's documentation. The supported file types are BMP, GIF, JPEG, PNG, TIFF.

Image files can be obtained from the project or mapset folder. These methods return Bitmaps, so be sure to have an appropriate variable to assign them.

GetProjectBitmap(string path)
GetMapsetBitmap(string path)

Normally, with file loading, the file must be disposed after you finish using it. However, there is no need to dispose the bitmap after you finish, as the script will do that for you.

The script will refresh automatically if a bitmap opened this way is modified.

Loading an Arbitrary File

Opens a file in read-only mode.

The script will refresh automatically if a file opened this way is modified.

OpenProjectFile(string path)
OpenMapsetFile(string path)

Contrarily to bitmaps, you are responsible for disposing them. Here's an example:

using (var stream = OpenProjectFile("file.txt"))
using (var reader = new StreamReader(stream, System.Text.Encoding.UTF8))
{
    var contents = reader.ReadToEnd();
    
    ...
}