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

[WIP] add snippet expand to items #38251

Closed

Conversation

cosmiccoincidence
Copy link
Contributor

@cosmiccoincidence cosmiccoincidence commented Feb 22, 2020

Summary

SUMMARY: Content "Adds snippet expansion to item descriptions."

Purpose of change

Adds the ability to reference name and city tags in item descriptions.

Testing

I have not tested this, as I'm still trying to learn how to build the game :/

Additional context

I also plan to use this feature in the near future on my upcoming packages for more immersive descriptions.

Credit goes to @anothersimulacrum. (Thanks boss!)

@Qrox
Copy link
Contributor

Qrox commented Feb 23, 2020

IIRC snippet expansion selects from a tag randomly every time it expands a snippet, so this would cause you too see different text every time you view an item's description?

@cosmiccoincidence
Copy link
Contributor Author

cosmiccoincidence commented Feb 23, 2020

As I understood it would allow for snippets to be referred to in item descriptions. So an item description could use things like <full_name> or < city>

@Qrox
Copy link
Contributor

Qrox commented Feb 23, 2020

It would, but snippet_library::expand calls random_from_category to randomly select a replacement for a tag, which means the item description would have different replacement text the next time you view it.

Also, tags like <full_name> or <city> aren't actually handled in snippet_library::expand, but are handled in replace_city_tag and replace_name_tags in output.cpp,

@cosmiccoincidence
Copy link
Contributor Author

cosmiccoincidence commented Feb 23, 2020

Well excuse my ignorance then, I do not have any coding knowledge myself, I received some help with this by someone else.

Seems signs and graffiti use:

        replace_city_tag( signtext, cityname );
        replace_name_tags( signtext );
        return signtext;

Would it be as simple as including this string in the dynamic description?

@cosmiccoincidence cosmiccoincidence changed the title add snippet expand to items [WIP] add snippet expand to items Feb 23, 2020
@Qrox
Copy link
Contributor

Qrox commented Feb 23, 2020

Sign and graffiti text are saved as static text once generated, but item descriptions are translated and displayed on spot, so you'll need to save the city name and random name in an item and replace them on spot in the item info function. As for other tags, their replacement probably need to be saved as snippet ids, but that brings the problem of how to handle it when the tags in the description change in a later version.

One simpler but imperfect solution would be saving the generated dynamic description in another member of item and display that when it's present. I believe artifact description does this so you can probably check out the artifact code to do this. Description generated this way won't update when switching the language, but would allow using tags in them. You'll need to make sure it's specified in a separate json entry though, to ensure it doesn't mess with normal item descriptions.

@ZhilkinSerg ZhilkinSerg added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc. 0.E Feature Freeze labels Feb 26, 2020
@cosmiccoincidence
Copy link
Contributor Author

I'm gonna attempt to look at this and/or outsource help again but since this is a bit 'above my pay grade' and I'm currently a bit busy I put it as WIP and will come back to it at some point, hopefully soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Info / User Interface Game - player communication, menus, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Snippets Only Reference Each other on Signs/Dialogue
4 participants