JoshuaGrams / tiny-qbn

A storylets library for Twine2/Sugarcube.
https://joshuagrams.github.io/tiny-qbn/
Other
48 stars 3 forks source link

Having a display name/internal name for cards? #6

Open fracoul opened 3 years ago

fracoul commented 3 years ago

With regular SurgarCube links or actions, one can use a short, internal name for a given passage (Grocery) while displaying a friendlier, longer message to the reader:

[[Go buy milk|Grocery]]

(A multilingual story could also display dynamic links according to the reader's choice of language, without having to change the original passages' names.)

I might be missing something but with TinyQBN's cardcolumn or cardlist commands, available cards seem to be displayed only as the destination passage's name or content (and nothing else).

In other words, is there a way to have a card named:

:: Grocery [card req-whatever-variable]

and have the cardcolumn command display "Go buy mik" or "Aller acheter du lait" to the reader?

JoshuaGrams commented 3 years ago

That was what the "cards with covers" stuff was supposed to be for: when you want to display something other than the passage name.

The basic idea is that you pass "cover" as the second argument to <<cardlist>> (or "coverbox" for <<cardcolumn>> or <<cardrow>>). When it displays a card' it will set a temporary variable _qbn_cover.

Then you wrap your whole Grocery passage in an <<if>> command to divide it into two parts:

<<if _qbn_cover>>[[Go buy milk|Grocery]]<<else>>\
normal passage content here
<</if>

And then of course it's normal Twine content so you can put images or whatever else you want in the "cover" part. It does require you to put that <<if>> statement in any cards that might be displayed this way, which isn't ideal.


Depending on how you need this to work (for instance, is the Grocery link always going to say "Go buy milk" or will that change throughout the game?) I can certainly think of other ways to code things that might be easier to work with, but they probably wouldn't be general-purpose enough to go in the library... But I can certainly try to dream up some other code snippets for your story if you'd like.

fracoul commented 3 years ago

Thanks! My understanding was that covers were mostly for previewing not-yet-available cards but, yes, that'd do the trick.

One reason to be excited about TinyQBN is that it separates code and content pretty neatly. So, while using covers definitely work, having to write every card's content inside an else statement doesn't look as straightforward.

I don't expect some custom-made features here but I guess that many authors would love to use "linkbox" for "cardcolumn" and have a custom link name as a property that could be set and reset with a single line of code.

JoshuaGrams commented 3 years ago

You can also have a separate passage for the link/cover. I find that to be pretty clunky in the Twine editor but it's not too bad if you're using Twee-format text files.

:: Go buy milk [card req-whatever-variable]
<<goto "Grocery">>

But yeah, I understand why the feature would be valuable, I've just never been sure how to design it: there are so many possibilities. So...maybe I'll talk through it out loud here and see if you have suggestions on how you'd like it to work as an author:

Would you want the display name to be on the card, or at the point of display? Because I think of [[display name->passage name]] as being a thing that changes to fit in with the text around it: maybe you have a big front porch on your spooky old house and you can [[climb the front steps|porch]] or [[go back outside|porch]] or [[squeeze out the window|porch]] depending on where you are. But that makes much less sense if you're showing a hand of cards that might be drawn from a large deck. Part of the benefit of storylets is that you can expand the story without having to worry about updating each place that might use a given card.

So it feels like it should be on the card. And it would be easy enough to allow a display name in a /*QBN ... */ comment in the passage, and have <<linkto>> and <<linkbox>> check for it.

But then it still feels ilke you might want to change the display name to fit the text that surrounds it when it's displayed. So how do you do that? Or how do you do more complicated things?

Well, OK, for more complicated things you can always fall back to having "diisplay cards" or "cover cards" as a separate passage and then make a widget that displays the contents if a card is tagged display or cover or something, and otherwise links to it. It'd be a little bit of a nuisance to write the widget in the first place, but then it'd be easy to author, just clunky to navigate the extra passages in the Twine editor. But it works. So forget that for the moment.

Back to "how do you change the display name in a particular place?" So you declare the default display name on the card. We keep a dictionary of those. Then you might want to change it globally/permanently: maybe you have a "private detective" who becomes "Nick Charles" once you've been introduced. That's easy enough: just have access to the display name dictionary so you can change them at any time.

But it's not so great if you want to just change it in one place. You'd have to change it and then remember to change it back. So...hmm... Oh, you just need a temporary dictionary that overlays the default one. You could either pass it in directly or have a command to say "temporarily refer to Grocery as 'Go buy milk'" and then the next time you display storylets it would forget all the temporary names and go back to the default ones. Yeah, I could make that happen.


So...thoughts? Does any of that make sense?

fracoul commented 3 years ago

A goto might work as a workaround with Twee, but could it cause some issues with reader's history and back button?

Your thoughts definitely make sense. To me, the purpose of cards is to be self-contained: if cards deal with the conditions of their own availability, the most relevant way is to define their display names within their content, in a /*QBN ... */.

Since display names would be treated as properties, being able to redefine them "from the outside" would also be appreciable. Personally, I'd choose a persistent state: once redefined, the display name remains the same until further notice.

This said, I'm not sure that this kind of redefinition would be used more than occasionally in actual stories. So the permanent/non permanent changes debate might not be such a big deal.

JoshuaGrams commented 3 years ago

Oh, bother. I always forget that goto leaves junk in the history, sorry.

And...cool. So maybe I'm overcomplicating things. We have a big maintenance project on the farm that'll probably keep me busy through the weekend, but I'll have a think and see if I can bang something out early next week.

fracoul commented 3 years ago

(Please remember that I'm still reviewing my options here and that my story has yet to be written. There's no need to rush or to bend your project to my will before being sure that it would fit other authors expectations…)

JoshuaGrams commented 3 years ago

Oh, sure. It was always clear that it would be nice to have a way to change the name of a linked card but it seemed complicated so I put off figuring out a good way to do it.

I hope you find something that fits your story, and if you run across other storylet-adjacent tools that seem promising I'd love to hear about them.