stevin05 / CraftScan

MIT License
5 stars 2 forks source link

Named placeholders functionality in greeting messages #24

Closed Almie closed 1 month ago

Almie commented 1 month ago

Added functionality to support named placeholders in custom greeting messages.

Before:

My alt %s can craft %s.

After:

My alt {crafter} can craft {item}.

This allows more extensive customization of greeting messages, such as changing the order of placeholders or using the same placeholder multiple times.

The warning and error messages in the UI have been adjusted to reflect these changes: Wow_2DrQQGwLWw

Fixes #23

Let me know if you'd like me to change anything.

stevin05 commented 1 month ago

Thanks! Looks like a nice way to do it.

This breaks existing users that have saved custom greetings doesn’t it? In Utils.lua, there is an UpgradePersistentConfig function or something like that. Can automatically replace %s’s with the correct named tag in what users have saved.

Another option would be to leave the original string.format line around your FString calls so any %s’s continue to work as before. They’d then hopefully get all the warning flags the first time they go to edit the greetings again.

I would probably go the upgrade route, but as long as people aren’t logging in after updating and having their messages go out with %s in them.

Almie commented 1 month ago

Thank you for the feedback, that is a good point.

I have adjusted UpgradePersistentConfig to replace %s in existing configs. I have also added another warning message to the UI if a user tries using a %s placeholder.

Let me know if you think this addresses the issue. Thanks!