FancyMenu [Fabric] [MOVED TO NEW PROJECT]

FancyMenu [Fabric] [MOVED TO NEW PROJECT]

17M Downloads

"Truncate Text" placeholder

CeruleanDerpo opened this issue ยท 0 comments

commented

It would be nice to have an option to truncate text in acruon scripts and this mod's string scripting system in the "Advanced" category of placeholders. It would look something like this:

{"placeholder":"truncate","values":{"string":"whatever_string","from":"last_character_to_delete","to":"last_character_to_keep"}

The use of negative numbers would count the characters backwards. (Character 1 is the last character)

Some examples

We have the string "Hello, world!"
We would truncate it like this:

{"placeholder":"truncate","values":{"string":"Hello, world!","from":"7","to":"11"}

And it would return the value world.

If the numbers were negative like in this example:

{"placeholder":"truncate","values":{"string":"Hello, world!","from":"0","to":"-2"}

It would return Hello, wor.
If "to" was positive it would have returned He.

Why this would be useful

This would be useful in more advanced cases where a user is trying to program some way to store Json in a variable, it would allow for storing multiple values in arrays in a FancyMenu variable, by truncating the final brackets, adding the added data, and adding the brackets back in, like in this more advanced case:

cool_variable_name:{"placeholder":"truncate","values":{"string":"{"placeholder":"getvariable","values":{"name":"cool_variable_name"}}","from":"0","to":"-1"}}

This action script essentially creates a save button, which opens a lot of possibilities