Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Translation::GenerateName() #5175

Merged
merged 1 commit into from
Jan 10, 2025
Merged

add Translation::GenerateName() #5175

merged 1 commit into from
Jan 10, 2025

Conversation

myk002
Copy link
Member

@myk002 myk002 commented Jan 8, 2025

Also available from Lua as "dfhack.generateName(...)"

Fixes: #5166

@@ -953,6 +953,10 @@ can be omitted.

Convert a ``df.language_name`` (or only the last name part) to string.

* ``dfhack.GenerateName(name,language,type,major_selector,minor_selector)``
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be feasible to provide an additional signature of dfhack.GenerateName(name, language, type) that chooses appropriate selectors based on the language_name_type? I can write the LuaApi glue if you write the cpp.

Copy link
Member

@quietust quietust Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no single set of rules for how the major/minor selectors are chosen - sometimes they're taken from the global list and sometimes some are taken from the entity definition, and sometimes it uses the major/minor selectors and sometimes it uses the major selector both times.

Copy link
Member

@lethosor lethosor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a naming suggestion on Discord. Not sure if it's worth implementing here or not.

I've felt for a long time that we ought to move this stuff to a dfhack.translation module, to match C++
we could alias the old dfhack.TranslateName = dfhack.translation.translateName or something like that, and make the case in the new API consistent with the other APIs

@myk002
Copy link
Member Author

myk002 commented Jan 9, 2025

Could you resolve the changelist conflicts? It seems like I can't push updates to your branch

@myk002
Copy link
Member Author

myk002 commented Jan 9, 2025

I've felt for a long time that we ought to move this stuff to a dfhack.translation module, to match C++
we could alias the old dfhack.TranslateName = dfhack.translation.translateName or something like that, and make the case in the new API consistent with the other APIs

captured in #5180

Also available from Lua as "dfhack.generateName(...)"
@quietust
Copy link
Member

quietust commented Jan 9, 2025

I've confirmed that the function works correctly from C++ (the StrangeMood plugin successfully generated the artifact name "Mosusthilség", "Roomtarnished"), and it also seems to function correctly from Lua if you provide the correct parameters (I ran dfhack.GenerateName(name, 0, df.language_name_type.Artifact, df.global.world.raws.language.word_table[0][1], df.global.world.raws.language.word_table[1][1]) and got reasonable-looking names).

@myk002 myk002 merged commit 8ab9939 into DFHack:develop Jan 10, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add dfhack.GenerateName API
3 participants