JujuAdams / Scribble

Efficient, internationalized, multi-effects text renderer for GameMaker
https://www.jujuadams.com/Scribble/
MIT License
335 stars 47 forks source link

v9 - Change main scribble() function to concat, add extra functions for cache-busting #406

Closed JujuAdams closed 1 year ago

JujuAdams commented 1 year ago

Current setup is function scribble(value, [uniqueID]). Most of the time, uniqueID is not used. However, it is very common for developers to want to build strings by concatenating many values together e.g. scribble("You have " + string(coins) + " coins and " + string(hearts) + " hearts."). This manual concatenation is inconvenient.

Proposal is to embrace concatenation as the default behaviour:

function scribble(value, ...)

Concatenates values together into a string for drawing e.g. scribble("You have ", coins, " coins and ", hearts, " hearts.")

Unique IDs are still critically important in some situations so we'd also need function scribble_unique(uniqueID, value, ...). If undefined is passed as uniqueID then a random number is generated (using an internal PRNG), guaranteeing a unique uniqueID.

biyectivo commented 1 year ago

Good idea. Another possibility would be to make use of the new string builder functionality if running on 2022.11+. Maybe have the option to use either?

JujuAdams commented 1 year ago

@biyectivo How would you use string_concat() / string_concat_ext() in this context?

biyectivo commented 1 year ago

I was referring to something like:

scribble(string("You have {0} coins and {1} hearts", coins, hearts));

maybe we could do:

scribble("You have {0} coins and {1} hearts", coins, hearts);

JujuAdams commented 1 year ago

I see, thank you

JujuAdams commented 1 year ago

Proposal largely met with positive reactions on Discord. Concerns against the change were

  1. Potentially annoying to transition over if the unique ID has been used a lot in Scribble 8
  2. May confuse new users as the exact behaviour of the functions, especially w.r.t. updating variables

The second point cannot adequately be addressed at this point. Point 1 can with the addition of a SCRIBBLE_LEGACY_FUNCTION macro