inkle / inky

An editor for ink: inkle's narrative scripting language
http://www.inklestudios.com/ink
2.42k stars 296 forks source link

[Feature request] Time Since option for choices (Similar to TURNS_SINCE) #473

Open Inkynoob739 opened 1 year ago

Inkynoob739 commented 1 year ago

Hello!

I would like to request a feature that might be cool to add. There should be a way to make specific choices appear after a certain amount of time, along with other uses. Like, if a player waits for 2 minutes without picking a choice, another appears and they can pick that. I think it would be similar to TURNS_SINCE, but like TIME_SINCE.

For example...

===first_knot===
 * [normal choice] -> knot
 * [also normal choice] -> knot 
  * {TIME_SINCE(-> first_knot) = 00:02:00} [secret choice] -> knot

(The 00:02:00 would mean 2 minutes)

I think it would be cool to see. Thanks.

robinsloan commented 1 year ago

Just chiming in here as a fellow Ink user:

The Ink interpreter doesn't have any concept of "clock time", and it also doesn't directly control the display of text, so I don't think this feature is a good fit at the language level.

However, it would be easy (and cool!) to implement this on the display side of an application. For example, if you were rendering your choices in HTML+CSS, you could apply a CSS animation that kept the text hidden for the specified amount of time. If it was me, I would implement this using Ink tags, something like:

===first_knot===
 * [normal choice] -> knot
 * [also normal choice] -> knot 
 * [secret choice #wait=120] -> knot

Then, in (for example) JavaScript, I'd do something like this:

story.currentChoices.forEach( choice => {
  let choiceElement = document.createElement("p");
  choiceElement.innerHTML = choice.text;
  choice.tags?.forEach( tag => {
    if (tag.includes("wait") {
      choiceElement.className = "wait";
      // this class would be defined in the page's CSS, and would have an appropriate CSS animation
    }
  }

  // here you would append choiceElement to the correct place in the document, etc.
}

I hope that's at least mildly helpful!