-
Notifications
You must be signed in to change notification settings - Fork 5
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
Link behavior objects/Syntactic sugar for phrase-cycling links. #78
Comments
Gonna spit some more design thoughts here, with an eye out for potential gotcha's: Link syntax is extended generally like so:
Their class name corresponds to a JavaScript class that implements the ComplexLink interface. When the player visits a section with one or more complex links, a ComplexLink object of the specifically declared type will be instantiated for each complex link. ComplexLink instances are deleted when the current section changes, but there are good arguments on both sides for whether these instances should be deleted when the current section gets refreshed. Maybe that's determined per each link type by implementing a ComplexLinks are all wrappers of an array of text. This text is declared in markdown by using the
(Hence there will need to be a way to escape a All ComplexLink objects are created with a list of the texts that the link was declared in Markdown with. The interface is like so:
|
Note to self: related to #51 |
It struck me today that we already have a form of customized link behavior: inline links. And the most internally consistent way to implement this, would be to refactor so anything in a link following the
|
What happened
When I was doing a lot of Twine work, one of the most common design patterns I used was a link that would start as one word, and clicking it would change the link through a series of alternate words/phrases. An excellent example is from Why I Run, where it's used as a kind of gender/avatar selection tool:
Implementing this kind of thing in Twine was always an ungodly mess.
Feature proposal
I just thought of what might be the snazziest syntactic sugar we could add to make this common task simple/beautiful in Fractive:
[text1/text2/text3]
to produce a link that starts by saying 'text1' and reveals the next phrase in the cycle whenever clicked. Or, to make a more extensible framework for links that transform their own text:
[text1/text2/text3]({!Core.CycleText})
where!
marks a link behavior macro that has both an initial condition (i.e. displaying only text1), and an event for being clicked (i.e. switching through the remaining options).Core.CycleText
would be an object with an init() function as well as an onClick() function. And we could define more such macros in the Core, and also allow users to implement their own more complicated link behaviors that involve more than just onClick.The text was updated successfully, but these errors were encountered: