FEATURE: Scripting language enhancement: creating methods/functions/libraries and object properties

Hi,

I would love to avoid code duplication (especially for customization templates).

In existing programming languages, like Java, it would be nice to be able to create our own methods/functions and libraries. Creating methods/functions help authors to reuse code created across episodes and stories in the Writing Portal.

Use case example:

As an author, I want to let the reader customized the character across episodes of my story.

Suggested feature

I could create a method called “customizationTemplate” in a library (saved into my portal, which is accessible to every story created). Then, on each chapter, instead of copy-pasting the template, I only need to call the method created, like:

customizationTemplate(@characterName)

In the method signature (inside parenthesis), we could pass a character reference by example. Or a String (like the name of a character), and more.

We would be nice also to get access to object properties to validate the state of a background or character, ex:

if (@characterName.isGenericFemale) {

} elif (@characterName.isPlusSizeFemale) {

}

As of today:

If I want to implement that, I have to copy-paste the customization template across chapters. Copy-pasting code bloat the chapter code and makes the maintenance of the chapter harder if we have to modify the template later on (to add new hairstyles and stuff).

And we can’t evaluate properties of a character, background or overlay because this concept doesn’t exists.

Benefits:

  • Code reuse
  • Avoid errors by copy-pasting reusable portion of code across chapters
  • Author can reuse code in any stories they create.

I believe this could make a significant impact on scripting to reduce lines of code and promote code reuse.

10 Likes

Support!

Support! :grin:

This was kind of confusing a first, but I think I get what you’re saying now. So Support!

Support! :star_struck: