Creating a lookup table of datamaps in Harlowe/Twine

Game Development Asked by the_e on January 4, 2021

I’m attempting to procedurally-generate a list of linked Passages in Harlowe 3 and am running into that lovely wall of simplified programming that is presented to the developer. The thing is that I just want to prototype a simple story without converting everything over to Sugarcube/Snowman.

What I am trying to do and am struggling with is figuring out how to generate an Array of Passages and link them together. I am absolutely OK with creating temporary lookup tables to link things together, however I’m struggling with the syntax for it.

My current feeling is that something like this should work, but I can’t wrap my head around the API reference for this kind of activity. The following is a pseudo-code attempt at what I’m trying to accomplish … it doesn’t work straight up but is an amalgamation of what I’ve been trying.

(set: $rooms to (a:))
(set: $num_rooms to range(1,20))
(for: each _iter, $num_rooms)[
  (set: $rooms to $rooms + (a: (dm: "title", "Room " + _iter, "Description", "Room " + _iter + " Description"))))

(set: $lookup to (dm:))
(for: each $room, $rooms):
  (for: each $room2, $rooms)):
    (if: $room is not $room2):
      <!-- random chance that it links up, example here to set the 'left' passage -->
      (set: $lookup to $lookup + (dm: "Room1_Left", $room2))      

Then later on, pull up:

[[Go left | $lookup->Room1_Left]]

The issue is that I am struggling with some of the syntax here. The above code doesn’t work for me and I’m struggling with coercing it into the ‘ideal’ format.

If this is completely infeasible then that is fine, but I’m fairly certain I can hack this in with the correct syntax. (Future projects I’d switch over to Sugarcube, but I want to try and give this the old college try before I completely dump it and refactor).


I got frustrated and switched over to Sugarcube (and 15 minutes into reading documentation/examples I’m already beyond where I got with Harlowe). HOWEVER I’m going to leave this question up for now as I can see it being exceedingly valid for non-programmers to extend their IF games. If a good answer rolls along I’ll try it out in my local project.

Add your own answers!

Related Questions

Best way to save game data in Unity

1  Asked on February 28, 2021 by tair-galili


Unity – Sprite vertices in 3D world

1  Asked on February 24, 2021 by muckington


How to represent a modular FSM for AI using ECS?

2  Asked on February 22, 2021 by christian-ivicevic


get access to Transform of a Clone in Unity

1  Asked on February 21, 2021 by amin007


Box2d on authoritative server for Unity client

0  Asked on February 19, 2021 by antonio-agustin


How to Send Voice over Unity Networking – UNET

1  Asked on February 12, 2021 by muhammad-faizan-khan


Mathf.Clamp not Working Properly

1  Asked on February 3, 2021 by shubhendra-chaddha


SetTrigger Only Works In Start and Not OnTriggerEnter

1  Asked on February 3, 2021 by kit-k


How do I detect image clicks in Dark GDK?

1  Asked on February 2, 2021 by bobman


FIx color banding in unity

0  Asked on February 1, 2021


OnMouseOver not registering collisions

3  Asked on January 29, 2021 by hyperific


Call native code from Unity iOS build error

1  Asked on January 29, 2021 by atlantis


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir