inkle / ink

inkle's open source scripting language for writing interactive narrative.
http://www.inklestudios.com/ink
MIT License
3.97k stars 482 forks source link

[Feature Request] Tags in Choices #372

Open oscan opened 6 years ago

oscan commented 6 years ago

I've seen it mentioned elsewhere, put just thought I'd put in my request/support/pleading for accessing tags in Choices.

Our current use case is we are using tags to define character expressions for lines of dialogue. e.g: Bob: Hi Jim! #EXP_Bob_happy #EXP_Jim_scared

This is fine and works as intended, characters change their expressions when stepping through lines.

But when it come to choices, as the player is cycling through the list of options in a carousel we'd like to preview the player characters expression that selecting the currently highlighted choice would produce.

Currently our Choices are very simple, just repeating the line once selected

so we'd just want to get the tags of the result in order to preview the expression

To work around this we're adding in custom tags on choices and parsing them out of the option text.

At some point we'd also like to attempt localisation by id tagging each line, so being able to tag Choice text in engine would be helpful there too.

Thanks, Owen

tentoumushi-dev commented 5 years ago

I'm currently working on a game where depending on the kind of choice, the choices are supposed to be displayed differently. Therefore I'm using a similar workaround since choice tags are still only available after the choice was taken. Imho that produces incredibly ugly code. A simple choice.getTags() would be amazing.

joningold commented 5 years ago

We hear the request but it has a bit of a gotcha, which is where should tag go on

On both the choice and the output text? Maybe.

Anyway for now I would put text directly into the choice if you need it there; and parse / regex it back out again.

... or similar.

Jon

You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/inkle/ink/issues/372#issuecomment-480248584, or mute the thread https://github.com/notifications/unsubscribe-auth/AA40o9eEl9vcAhN08C9cha0kCexw98hNks5vdzmdgaJpZM4P1W_u .

-- Jazz, in Three-Four Time: A Novel http://www.amazon.co.uk/dp/B004K1EYIE

nehvaleem commented 3 years ago

any update regarding this?

joningold commented 3 years ago

None so far! The recommended method is still marking up the text inside the choice itself.

elliotherriman commented 3 years ago

Hey! I actually found a method that I think works... quite nicely? Hosted right here in a gist. It's using InkJS, though it should be possible to use similar or identical methods using other implementations of Ink.

Basically, it grabs the first tag from every available choice, as long as that tag is on the same physical line the choice in your ink file. So this would return "tag"--

* choice #tag

And this wouldn't.

* choice #tag

(This last one would apply "tag" to all text in the choice, both before and after the choice is taken).

* choice[] trailing text #tag

As long as you're consistent with your tagging — that is, keep choice tags on the same line, and subsequent tags on the following line, then this'll work. I have a feeling that it isn't a perfect solution, but I haven't run into any problems yet.

MultiversalNomad commented 3 years ago

I can vouch that @elliotherriman's implementation seems to work for fetching tags from choices; I tested the implementation in my own project and I'm successfully able to use choice tags (I made some project-specific modifications in my implementation like being able to get an array of tags instead of a single tag, but the core idea is the same as the one described by @elliotherriman).

So it looks like choice tags are indeed possible as long as one is willing to write a small bit of code for it. I would recommend to either make this solution more accessible in Ink via some kind of function or just to leave the current behaviour as-is and allow people to code their own solutions. In other words, please don't remove the behaviour that allows for the implementation that @elliotherriman found 😛

elliotherriman commented 3 years ago

I don't think Jon was suggesting that this functionality isn't possible, only that it could cause issues in choices that use the square brackets, and are therefore split into two lines behind the scenes.

That said, I can't think of a single use case for needing different tags on a choice and output text. And even if there were, surely it would be up to the user to resolve that themselves-- theoretically maybe by using glue to recreate the effect of square brackets? Though I'm not sure how that works behind the scenes.

In the Ink 1.0 release post, or something posted around that time, I remember reading that the team felt a little weird exposing all the Ink functions by converting them from internal to public, but decided to do it anyway, because it seemed more important for the engine to be flexible and hackable. I'd consider this a similar situation. Probably a little rickety, maybe not what the developers intended, but absolutely useful to a number of creators. So I do really hope an official function is added, yeah.

bunniesvszombies commented 3 years ago

Hi! I was wondering if this would be a sensible use for timed responses. e.g.

Using elliotherriman's method, I think I can find a way to get the timer tag data into unity and remove the first choice after 5 seconds, and after all timers expire (10 seconds), a default response of "Freeze and stay silent" would be selected. Is there any better ways of making countdown timers for response choices in ink+unity?

elliotherriman commented 3 years ago

Is there any better ways of making countdown timers for response choices in ink+unity?

Probably only the ones outlined in the original post.

I'm actually working on supporting some common Twine features through a rewrite of the Ink web player-- so I'm happy to let you know once I've figured out the code for timed responses?

bunniesvszombies commented 2 years ago

Not sure if this helps anyone here, but there is a post about using External function, which should solve OP's issue, however would have to rewrite significant code to implement. Should work in choices(???)

ireth92 commented 2 years ago

The gist is no longer available. Does anyone still have the code? I need to add tags to my choices as well :(

elliotherriman commented 2 years ago

The gist is no longer available. Does anyone still have the code? I need to add tags to my choices as well :(

Hey! The version in that gist had a few issues — you can find an updated version here.

It's written as a patch for Calico, so if you're building something in Unity or the vanilla ink player, you'll need to adapt lines 28 to 55 (inclusive).

kodra-dev commented 1 year ago

What's the official solution to this?

elliotherriman commented 1 year ago

What's the official solution to this?

As of 1.1.1, runtime choice objects have a list of tags that can be accessed via whateverYourChoiceObjectIsNamed.tags. You can read more here.

kodra-dev commented 1 year ago

Oh, okay, I see. I shouldn't have been using the old version from Unity Asset Store.

CharlieHess commented 1 year ago

This issue should be closed based on the 1.1.1 release, no?