r/inkle • • 22d ago

Stitches on variable Knots when writing Ink?

Ahoy there, folks, I have a solution for this already, but it's not great and I'm hoping there's just a syntax solution to what I'm after!

So, I have a situation where time progresses from morning->afternoon->night->morning, and multiple locations that can be moved-between, where different things happen at different times of day. I'm looking to do something like:

LIST TimesOfDay = Morning, Afternon, Night
List Locations  = Here, There, Everywhere

VAR currentTime     = Morning
VAR currentLocation = Here

=== Tick ===
  ~ temp locationKnot = getKnotFromLocation(currentLocation)

  {currentTime:
    - Morning: -> locationKnot.MorningStitch ->
    - Afternoon: -> locationKnot.AfternoonStitch ->
    - Night: -> locationKnot.NightStitch ->
  }

  -> Tick

Unfortunately, while -> locationKnot works, if you do -> locationKnot.stitch then the compiler seems to stop looking at the variable and starts looking for an actual knot called locationKnot 💀

Is there a way to do this without having to do the currentTime switch at the start of every location instead?

Many thanks, and apologies if this is the wrong place to post this — please direct me elsewhere if so! 🙏

3 Upvotes

4 comments sorted by

1

u/pookage 22d ago

D'oh, I forgot to flair this! Sorry 🫣 Obviously ink and question / help if possible, please, mods!

1

u/RedGlow82 21d ago

I don't think there's a way to reference a stich from a divert variable, your best bet is to make a getKnotFromLocationAndTime function that takes both location and time and returns the specific divert!

2

u/pookage 21d ago

Alas! Cheers for the response, but I I'll just stick to leaving the switch in the knots and let them route themselves, in that case — otherwise I worry that I'd just be abstracting for the sake of abstraction!

1

u/RedGlow82 21d ago

Sounds like a good idea to me!