EasyRPG / Player

RPG Maker 2000/2003 and EasyRPG games interpreter
https://easyrpg.org/player/
GNU General Public License v3.0
989 stars 185 forks source link

Variable Substitution: Options for enabling substution in command strings & for applying {fmt}-style number formatting #3220

Open florianessl opened 4 months ago

florianessl commented 4 months ago

This PR enables two new features:

These two features require setting new liblcfs fields which are specified as follows:

System,easyrpg_var_substitution_in_commands,f,Boolean,0xDC,False,0,0,Enables substitution of '\v' '\n' '\a' inside string parameters of interpreter commands
System,easyrpg_var_substitution_formatting,f,Boolean,0xDD,False,0,0,Enables '{fmt}'-style format specifiers for usage inside variable substitution

Example: Graphics customization

Consider you want to dynamically change an actor graphic or faceset depending on some settings.

With this branch you can just use any pre-existing command like this:

com.string: "Actor\v[123:02d]"

... which evaluates to "Actor01.png", "Actor02.png", ..., "Actor[xx].png" depending on the value of Variable '123'

florianessl commented 4 months ago

Oh, haven't thought about the reference not working there. Stupid me. I'l look into how I can improve this without any unnecessary copying, and unit-tests for the formatting were definitely on my mind, I'm just working on several branches right now and am constantly shifting my focus :D

I'm working on an extensive test suite for my three main branches, which hopefully will cover all sorts of use cases: "ScopesVars", "MapInitTrigger" & this one. So, no need to go over any of those while this is still a work-in-progress (also, I'm on holiday for two weeks, so it will take some time.)